From 6e3df3df0827bd0547b1ff7d4883f46695789e10 Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Thu, 12 Dec 2024 14:48:23 -0800 Subject: [PATCH] Get npm run lint working --- .eslintignore | 2 - .markdownlint-cli2.cjs | 4 +- eslint.config.js | 52 +++++++++++-------- package-lock.json | 39 +++++++++++++- package.json | 2 + src/index.js | 2 +- .../no-unnecessary-components.test.js | 8 +-- 7 files changed, 75 insertions(+), 34 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index c409f7b3..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -**/dist/** -**/node_modules/** diff --git a/.markdownlint-cli2.cjs b/.markdownlint-cli2.cjs index 1748cb9a..4dea7ab5 100644 --- a/.markdownlint-cli2.cjs +++ b/.markdownlint-cli2.cjs @@ -16,11 +16,11 @@ const options = githubMarkdownOpinions.init({ 'no-hard-tabs': false, 'first-line-heading': false, 'no-space-in-emphasis': false, - 'blanks-around-fences': false + 'blanks-around-fences': false, }) module.exports = { config: options, customRules: ['@github/markdownlint-github'], - outputFormatters: [['markdownlint-cli2-formatter-pretty', {appendLink: true}]] + outputFormatters: [['markdownlint-cli2-formatter-pretty', {appendLink: true}]], } diff --git a/eslint.config.js b/eslint.config.js index 8ca18bbe..aaf1d78f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,21 +1,23 @@ -const eslintPlugin = require('eslint-plugin-eslint-plugin') +const eslintJs = require('@eslint/js') const github = require('eslint-plugin-github') +const globals = require('globals') +const pluginJest = require('eslint-plugin-jest') module.exports = [ github.getFlatConfigs().recommended, - eslintPlugin.configs['flat/recommended'], + eslintJs.configs.recommended, { languageOptions: { parserOptions: { ecmaVersion: 'latest', }, - }, - env: { - commonjs: true, - node: true, + globals: { + ...globals.commonjs, + ...globals.node, + }, }, rules: { - 'import/no-commonjs': 'off', + 'importPlugin/no-commonjs': 'off', 'no-shadow': 'off', 'no-unused-vars': [ 'error', @@ -24,19 +26,27 @@ module.exports = [ }, ], }, - overrides: [ - { - files: ['**/*.test.js'], - env: { - jest: true, - }, - }, - { - files: ['.eslintrc.js'], - rules: { - 'filenames/match-regex': 'off', - }, + ignores: ['**/dist/**', '**/node_modules/**'], + }, + { + files: ['**/*.test.js'], + languageOptions: { + globals: { + ...pluginJest.environments.globals.globals, }, - ], - } + }, + }, + { + files: ['.eslint.config.js', '.markdownlint-cli2.cjs'], + rules: { + 'filenames/match-regex': 'off', + 'github/filenames-match-regex': 'off', + }, + }, + { + files: ['src/url.js', 'src/rules/new-color-css-vars.js'], + rules: { + 'importPlugin/extensions': 'off', + }, + }, ] diff --git a/package-lock.json b/package-lock.json index 732f7055..ba8d6892 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,18 +21,20 @@ "devDependencies": { "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.9", + "@eslint/js": "^9.16.0", "@github/markdownlint-github": "^0.6.3", "@github/prettier-config": "0.0.6", "@types/jest": "^29.5.13", "@typescript-eslint/rule-tester": "8.18.0", "eslint": "^9.16.0", + "eslint-plugin-jest": "^28.9.0", "eslint-plugin-prettier": "^5.2.1", "jest": "^29.7.0", "markdownlint-cli2": "^0.14.0", "markdownlint-cli2-formatter-pretty": "^0.0.7" }, "peerDependencies": { - "eslint": "^9.16.0" + "eslint": "^8 || ^9" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -3560,6 +3562,32 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-plugin-jest": { + "version": "28.9.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.9.0.tgz", + "integrity": "sha512-rLu1s1Wf96TgUUxSw6loVIkNtUjq1Re7A9QdCCHSohnvXEBAjuL420h0T/fMmkQlNsQP2GhQzEUpYHPfxBkvYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "engines": { + "node": "^16.10.0 || ^18.12.0 || >=20.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0", + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0", + "jest": "*" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + }, + "jest": { + "optional": true + } + } + }, "node_modules/eslint-plugin-jsx-a11y": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.2.tgz", @@ -10306,6 +10334,15 @@ } } }, + "eslint-plugin-jest": { + "version": "28.9.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.9.0.tgz", + "integrity": "sha512-rLu1s1Wf96TgUUxSw6loVIkNtUjq1Re7A9QdCCHSohnvXEBAjuL420h0T/fMmkQlNsQP2GhQzEUpYHPfxBkvYQ==", + "dev": true, + "requires": { + "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "eslint-plugin-jsx-a11y": { "version": "6.10.2", "resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.2.tgz", diff --git a/package.json b/package.json index 0a3154cf..790a0f05 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,8 @@ "@github/markdownlint-github": "^0.6.3", "@github/prettier-config": "0.0.6", "eslint": "^9.16.0", + "@eslint/js": "^9.16.0", + "eslint-plugin-jest": "^28.9.0", "eslint-plugin-prettier": "^5.2.1", "jest": "^29.7.0", "markdownlint-cli2": "^0.14.0", diff --git a/src/index.js b/src/index.js index b3b3a3f4..afacf2a3 100644 --- a/src/index.js +++ b/src/index.js @@ -24,5 +24,5 @@ module.exports = { configs: { recommended: require('./configs/recommended'), }, - getFlatConfigs: getFlatConfigs + getFlatConfigs, } diff --git a/src/rules/__tests__/no-unnecessary-components.test.js b/src/rules/__tests__/no-unnecessary-components.test.js index 820f3e57..cd9fe16d 100644 --- a/src/rules/__tests__/no-unnecessary-components.test.js +++ b/src/rules/__tests__/no-unnecessary-components.test.js @@ -25,15 +25,9 @@ const ruleTester = new RuleTester({ parser: tseslint.parser, parserOptions: { tsconfigRootDir: path.resolve(__dirname, 'fixtures'), - projectService: { - allowDefaultProject: ['*.ts*'], - }, + project: path.resolve(__dirname, 'fixtures', 'tsconfig.json'), }, }, - defaultFilenames: { - ts: 'file.ts', - tsx: 'File.tsx', - }, }) jest.retryTimes(0, {logErrorsBeforeRetry: true})