From e1d881e056c4f492d9edf149e2fd0cc72a76a038 Mon Sep 17 00:00:00 2001 From: GZolla <43836485+GZolla@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:06:41 -0800 Subject: [PATCH 1/2] fix: Update to eslint9 --- .eslintrc.json | 3 --- eslint.config.js | 26 ++++++++++++++++++++++++++ package.json | 11 +++++++---- test/.eslintrc.json | 3 --- 4 files changed, 33 insertions(+), 10 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 eslint.config.js delete mode 100644 test/.eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index fcf2d2f..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "brightspace/browser-config" -} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..da5713e --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,26 @@ +import { fileURLToPath } from 'node:url'; +import { FlatCompat } from '@eslint/eslintrc'; +import { includeIgnoreFile } from '@eslint/compat'; +import js from '@eslint/js'; +import path from 'node:path'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); +const gitignorePath = path.resolve(__dirname, '.gitignore'); + +export default [ + includeIgnoreFile(gitignorePath), + ...compat.extends('brightspace/browser-config').map(config => ({ + ...config, + files: ['**/*.js', '**/*.html'], + })), + ...compat.extends('brightspace/testing-config').map(config => ({ + ...config, + files: ['test/**/*'], + })), +]; diff --git a/package.json b/package.json index 16433ee..df8e346 100644 --- a/package.json +++ b/package.json @@ -12,16 +12,19 @@ "author": "D2L Corporation", "license": "Apache-2.0", "scripts": { - "lint": "eslint . --ext .js,.html", + "lint": "eslint .", "test": "npm run lint && npm run test:unit", "test:unit": "d2l-test-runner" }, "devDependencies": { "@brightspace-ui/testing": "^1", "@web/dev-server": "^0.4", - "eslint": "^8", - "eslint-config-brightspace": "^1.0", - "sinon": "^19" + "eslint": "^9", + "eslint-config-brightspace": "^1.2.1", + "sinon": "^19", + "@eslint/compat": "^1", + "@eslint/eslintrc": "^3", + "@eslint/js": "^9" }, "files": [ "/src" diff --git a/test/.eslintrc.json b/test/.eslintrc.json deleted file mode 100644 index 9c6a0b6..0000000 --- a/test/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "brightspace/testing-config" -} From d477138022686bbf72075b12950ff698a638d378 Mon Sep 17 00:00:00 2001 From: GZolla <43836485+GZolla@users.noreply.github.com> Date: Fri, 22 Nov 2024 11:54:37 -0800 Subject: [PATCH 2/2] Use new shared config --- eslint.config.js | 32 +++++++------------------------- package.json | 2 +- 2 files changed, 8 insertions(+), 26 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index da5713e..0542298 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,26 +1,8 @@ -import { fileURLToPath } from 'node:url'; -import { FlatCompat } from '@eslint/eslintrc'; -import { includeIgnoreFile } from '@eslint/compat'; -import js from '@eslint/js'; -import path from 'node:path'; +import { addExtensions, browserConfig, setDirectoryConfigs, testingConfig } from 'eslint-config-brightspace'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); -const compat = new FlatCompat({ - baseDirectory: __dirname, - recommendedConfig: js.configs.recommended, - allConfig: js.configs.all -}); -const gitignorePath = path.resolve(__dirname, '.gitignore'); - -export default [ - includeIgnoreFile(gitignorePath), - ...compat.extends('brightspace/browser-config').map(config => ({ - ...config, - files: ['**/*.js', '**/*.html'], - })), - ...compat.extends('brightspace/testing-config').map(config => ({ - ...config, - files: ['test/**/*'], - })), -]; +export default addExtensions(setDirectoryConfigs( + browserConfig, + { + 'test': testingConfig + } +), ['.js', '.html']); diff --git a/package.json b/package.json index df8e346..d9b5857 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@brightspace-ui/testing": "^1", "@web/dev-server": "^0.4", "eslint": "^9", - "eslint-config-brightspace": "^1.2.1", + "eslint-config-brightspace": "^2", "sinon": "^19", "@eslint/compat": "^1", "@eslint/eslintrc": "^3",