From 08b3d57903fae1b754a2bcef5306f5a660cdea90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Apr 2024 07:27:06 +0000 Subject: [PATCH 1/6] chore(deps-dev): bump eslint from 8.57.0 to 9.0.0 in the lint group Bumps the lint group with 1 update: [eslint](https://github.com/eslint/eslint). Updates `eslint` from 8.57.0 to 9.0.0 - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.57.0...v9.0.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-major dependency-group: lint ... Signed-off-by: dependabot[bot] --- package-lock.json | 165 +++++++++++++++++++++++++++++++++++----------- package.json | 2 +- 2 files changed, 129 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0a54757c9..86a5280f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "@typescript-eslint/eslint-plugin": "^7.5.0", "@typescript-eslint/parser": "^7.5.0", "babel-plugin-styled-components": "^2.1.4", - "eslint": "^8.57.0", + "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-typescript": "^3.6.1", "eslint-mdx": "^3.1.5", @@ -2477,15 +2477,15 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", - "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.0.2.tgz", + "integrity": "sha512-wV19ZEGEMAC1eHgrS7UQPqsdEiCIbTKTasEfcXAigzoXICcqZSjBZEHlZwNVvKg6UBCjSlos84XiLqsRJnIcIg==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.6.0", - "globals": "^13.19.0", + "espree": "^10.0.1", + "globals": "^14.0.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", "js-yaml": "^4.1.0", @@ -2493,19 +2493,60 @@ "strip-json-comments": "^3.1.1" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, + "node_modules/@eslint/eslintrc/node_modules/espree": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.0.1.tgz", + "integrity": "sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww==", + "dev": true, + "dependencies": { + "acorn": "^8.11.3", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/@eslint/js": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", - "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.0.0.tgz", + "integrity": "sha512-RThY/MnKrhubF6+s1JflwUjPEsnCEmYCWwqa/aRISKWNXGZ9epUwft4bUMM35SdKF9xvBrLydAM1RDHd1Z//ZQ==", "dev": true, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@floating-ui/core": { @@ -3156,12 +3197,12 @@ } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.14", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", - "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", + "version": "0.12.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.12.3.tgz", + "integrity": "sha512-jsNnTBlMWuTpDkeE3on7+dWJi0D6fdDfeANj/w7MpS8ztROCoLvIO2nG0CcFj+E4k8j4QrSTh4Oryi3i2G669g==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^2.0.2", + "@humanwhocodes/object-schema": "^2.0.3", "debug": "^4.3.1", "minimatch": "^3.0.5" }, @@ -3170,9 +3211,9 @@ } }, "node_modules/@humanwhocodes/config-array/node_modules/@humanwhocodes/object-schema": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", - "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", "dev": true }, "node_modules/@humanwhocodes/module-importer": { @@ -9547,41 +9588,37 @@ } }, "node_modules/eslint": { - "version": "8.57.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", - "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.0.0.tgz", + "integrity": "sha512-IMryZ5SudxzQvuod6rUdIUz29qFItWx281VhtFVc2Psy/ZhlCeD/5DT6lBIJ4H3G+iamGJoTln1v+QSuPw0p7Q==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.57.0", - "@humanwhocodes/config-array": "^0.11.14", + "@eslint/eslintrc": "^3.0.2", + "@eslint/js": "9.0.0", + "@humanwhocodes/config-array": "^0.12.3", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", - "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.2.2", - "eslint-visitor-keys": "^3.4.3", - "espree": "^9.6.1", + "eslint-scope": "^8.0.1", + "eslint-visitor-keys": "^4.0.0", + "espree": "^10.0.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", - "file-entry-cache": "^6.0.1", + "file-entry-cache": "^8.0.0", "find-up": "^5.0.0", "glob-parent": "^6.0.2", - "globals": "^13.19.0", "graphemer": "^1.4.0", "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", @@ -9595,7 +9632,7 @@ "eslint": "bin/eslint.js" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -12263,16 +12300,16 @@ } }, "node_modules/eslint-scope": { - "version": "7.2.2", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", - "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.0.1.tgz", + "integrity": "sha512-pL8XjgP4ZOmmwfFE8mEhSxA7ZY4C+LWyqjQ3o4yWkkmD0qcMT9kkW3zWHOczhWcjTSgqycYAgwSlXvZltv65og==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" @@ -12368,6 +12405,60 @@ "url": "https://github.com/chalk/supports-color?sponsor=1" } }, + "node_modules/eslint/node_modules/eslint-visitor-keys": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.0.0.tgz", + "integrity": "sha512-OtIRv/2GyiF6o/d8K7MYKKbXrOUBIK6SfkIRM4Z0dY3w+LiQ0vy3F57m0Z71bjbyeiWFiHJ8brqnmE6H6/jEuw==", + "dev": true, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/espree": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.0.1.tgz", + "integrity": "sha512-MWkrWZbJsL2UwnjxTX3gG8FneachS/Mwg7tdGXce011sJd5b0JG54vat5KHnfSBODZ3Wvzd2WnjxyzsRoVv+ww==", + "dev": true, + "dependencies": { + "acorn": "^8.11.3", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.0.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/eslint/node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/espree": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", diff --git a/package.json b/package.json index b87b191b9..118b51ca4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@typescript-eslint/eslint-plugin": "^7.5.0", "@typescript-eslint/parser": "^7.5.0", "babel-plugin-styled-components": "^2.1.4", - "eslint": "^8.57.0", + "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-typescript": "^3.6.1", "eslint-mdx": "^3.1.5", From 7fc1a02160129e2159168a9ec9543cbd984ed6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= Date: Mon, 8 Apr 2024 09:53:26 +0200 Subject: [PATCH 2/6] migrate the ".eslintignore" file --- .eslintignore | 7 ------- .eslintrc.js | 9 +++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index e76b10b57..000000000 --- a/.eslintignore +++ /dev/null @@ -1,7 +0,0 @@ -.cache/ -.github/ -.idea/ -/public/ -/config/ -node_modules/ -build/ diff --git a/.eslintrc.js b/.eslintrc.js index 0c845916b..e08976732 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -103,4 +103,13 @@ module.exports = { }, }, ], + ignorePatterns: [ + '.cache/', + 'node_modules/', + 'public/', + 'build/', + '.github/', + '.idea/', + '/config/', + ], }; From bd58cecda319606cacb971766a84685603109647 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= Date: Mon, 8 Apr 2024 17:02:49 +0200 Subject: [PATCH 3/6] WIP : migrate to v9 --- .eslintrc.js | 115 --------------------------- eslint.config.mjs | 193 ++++++++++++++++++++++++++++++++++++++++++++++ package-lock.json | 45 ++++++++--- package.json | 5 +- 4 files changed, 230 insertions(+), 128 deletions(-) delete mode 100644 .eslintrc.js create mode 100644 eslint.config.mjs diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index e08976732..000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright 2021 Bonitasoft S.A. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -module.exports = { - plugins: ['notice', 'import'], - extends: [ - 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. - ], - parserOptions: { - ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features - sourceType: 'module', // Allows for the use of imports - }, - overrides: [ - // javascript & typescript - { - files: ['*.js', '*.jsx', '*.ts', '*.tsx'], - rules: { - 'notice/notice': [ - 'error', - { - templateFile: 'config/license-header.js', - onNonMatchingHeader: 'replace', - }, - ], - 'no-console': ['error', { allow: ['warn', 'error'] }], - }, - }, - // typescript - { - files: ['*.ts', '*.tsx'], - parser: '@typescript-eslint/parser', // Specifies the ESLint parser - extends: [ - 'plugin:@typescript-eslint/recommended', // Uses the recommended rules from the @typescript-eslint/eslint-plugin - 'plugin:prettier/recommended', // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array. - 'plugin:import/recommended', - 'plugin:import/typescript', - ], - settings: { - 'import/resolver': { - typescript: { - alwaysTryTypes: true, // always try to resolve types under `@types` directory even it doesn't contain any source code, like `@types/unist` - project: './tsconfig.json', - }, - }, - }, - parserOptions: { - // This setting is required if you want to use rules which require type information - // https://typescript-eslint.io/packages/parser/#project - project: ['./tsconfig.json'], - }, - rules: { - // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs - '@typescript-eslint/explicit-function-return-type': [ - 'warn', - { - allowExpressions: true, - allowTypedFunctionExpressions: true, - }, - ], - '@typescript-eslint/explicit-member-accessibility': [ - 'error', - { - accessibility: 'no-public', - }, - ], - '@typescript-eslint/consistent-type-exports': [ - 'error', - { - fixMixedExportsWithInlineTypeSpecifier: true, - }, - ], - '@typescript-eslint/consistent-type-imports': ['error'], - '@typescript-eslint/dot-notation': 'error', - '@typescript-eslint/require-await': 'error', - '@typescript-eslint/no-floating-promises': 'error', - '@typescript-eslint/no-misused-promises': 'error', - '@typescript-eslint/restrict-plus-operands': 'error', - }, - }, - // markdown - { - files: ['*.mdx'], - parser: 'eslint-mdx', - extends: 'plugin:mdx/recommended', - // optional, if you want to lint code blocks at the same time - settings: { - 'mdx/code-blocks': true, - // optional, if you want to disable language mapper, set it to `false` - // if you want to override the default language mapper inside, you can provide your own - //'mdx/language-mapper': {}, - }, - }, - ], - ignorePatterns: [ - '.cache/', - 'node_modules/', - 'public/', - 'build/', - '.github/', - '.idea/', - '/config/', - ], -}; diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..78527d9c4 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,193 @@ +/** + * Copyright 2021 Bonitasoft S.A. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import noticePlugin from "eslint-plugin-notice"; +import importPlugin from "eslint-plugin-import"; +import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import tseslint from 'typescript-eslint'; +// import eslintPluginImport from 'eslint-plugin-import'; +import * as eslintPluginMdx from 'eslint-plugin-mdx' +import eslintParser from '@typescript-eslint/parser'; + + + +const typeScriptExtensions = ['.ts', '.cts', '.mts', '.tsx']; + +const allExtensions = [...typeScriptExtensions, '.js', '.jsx']; + + +/** @type {import('eslint').Linter.FlatConfig[]} */ +export default [ + eslintPluginPrettierRecommended, // Enables eslint-plugin-prettier, eslint-config-prettier and prettier/prettier. This will display prettier errors as ESLint errors. + + { + plugins: { + notice: noticePlugin, + import: importPlugin + }, + languageOptions: { + parserOptions: { + ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features + sourceType: 'module', // Allows for the use of imports + }, + }, + ignores: [ + '.cache/', + 'node_modules/', + 'public/', + 'build/', + '.github/', + '.idea/', + '/config/', + ], + }, + + // File-pattern specific overrides + // javascript & typescript + { + files: ['*.js', '*.jsx', '*.ts', '*.tsx'], + rules: { + 'notice/notice': [ + 'error', + { + templateFile: 'config/license-header.js', + onNonMatchingHeader: 'replace', + }, + ], + 'no-console': ['error', { allow: ['warn', 'error'] }], + }, + }, + + // typescript + /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */ + ...tseslint.configs.recommended.map(conf => ({ + ...conf, + files: ['**/*.ts', '**/*.tsx'], + })), + { + files: ['**/*.ts', '**/*.tsx'], + // ...eslintPluginImport.configs.recommended, // To uncomment when it will support flat config + // ...eslintPluginImport.configs.typescript, // To uncomment when it will support flat config + + // To remove when eslintPluginImport will support flat config + plugins: { import: importPlugin }, + ///////////////////////////////////////////////////////////////// + + settings: { + // To remove when eslintPluginImport will support flat config + 'import/extensions': allExtensions, + 'import/external-module-folders': ['node_modules', 'node_modules/@types'], + 'import/parsers': { + '@typescript-eslint/parser': typeScriptExtensions, + }, + ///////////////////////////////////////////////////////////////// + + + + 'import/resolver': { + // To remove when eslintPluginImport will support flat config + node: { + extensions: allExtensions, + }, + ///////////////////////////////////////////////////////////////// + + + typescript: { + alwaysTryTypes: true, // always try to resolve types under `@types` directory even it doesn't contain any source code, like `@types/unist` + project: './tsconfig.json', + }, + }, + }, + languageOptions: { + parserOptions: { + // To remove when eslintPluginImport will support flat config + sourceType: 'module', + ecmaVersion: 2018, + ///////////////////////////////////////////////////////////////// + + + parser: eslintParser, + + // This setting is required if you want to use rules which require type information + // https://typescript-eslint.io/packages/parser/#project + project: ['./tsconfig.json'], + }, + }, + rules: { + // To remove when eslintPluginImport will support flat config + // analysis/correctness + //'import/no-unresolved': 'error', + // 'import/namespace': 'error', + // 'import/default': 'error', + // 'import/export': 'error', + + // red flags (thus, warnings) + // 'import/no-named-as-default': 'off', + // 'import/no-named-as-default-member': 'off', + // 'import/no-duplicates': 'warn', + + // 'import/named': 'off', + ///////////////////////////////////////////////////////////////// + + + // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs + '@typescript-eslint/explicit-function-return-type': [ + 'warn', + { + allowExpressions: true, + allowTypedFunctionExpressions: true, + }, + ], + '@typescript-eslint/explicit-member-accessibility': [ + 'error', + { + accessibility: 'no-public', + }, + ], + '@typescript-eslint/consistent-type-exports': [ + 'error', + { + fixMixedExportsWithInlineTypeSpecifier: true, + }, + ], + '@typescript-eslint/consistent-type-imports': ['error'], + '@typescript-eslint/dot-notation': 'error', + '@typescript-eslint/require-await': 'error', + '@typescript-eslint/no-floating-promises': 'error', + '@typescript-eslint/no-misused-promises': 'error', + '@typescript-eslint/restrict-plus-operands': 'error', + }, + }, + + // markdown + { + ...eslintPluginMdx.flat, + // optional, if you want to lint code blocks at the same + processor: eslintPluginMdx.createRemarkProcessor({ + lintCodeBlocks: true, + }), + }, + { + ...eslintPluginMdx.flatCodeBlocks, + rules: { + ...eslintPluginMdx.rules, + // if you want to override some rules for code blocks + 'no-var': 'error', + 'prefer-const': 'error', + }, + }, +] +; diff --git a/package-lock.json b/package-lock.json index 86a5280f4..d0fd49c71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,8 +27,6 @@ "devDependencies": { "@types/chroma-js": "^2.4.4", "@types/react": "^18.2.74", - "@typescript-eslint/eslint-plugin": "^7.5.0", - "@typescript-eslint/parser": "^7.5.0", "babel-plugin-styled-components": "^2.1.4", "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", @@ -53,7 +51,8 @@ "husky": "^9.0.11", "lint-staged": "^15.2.2", "prettier": "^3.2.5", - "typescript": "^5.4.3" + "typescript": "^5.4.4", + "typescript-eslint": "^7.5.0" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -25799,12 +25798,12 @@ "dev": true }, "node_modules/ts-api-utils": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.0.3.tgz", - "integrity": "sha512-wNMeqtMz5NtwpT/UZGY5alT+VoKdSsOOP/kqHFcUW1P/VRhH2wJ48+DN2WwUliNbQ976ETwDL0Ifd2VVvgonvg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.3.0.tgz", + "integrity": "sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==", "dev": true, "engines": { - "node": ">=16.13.0" + "node": ">=16" }, "peerDependencies": { "typescript": ">=4.2.0" @@ -26003,9 +26002,9 @@ } }, "node_modules/typescript": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.3.tgz", - "integrity": "sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==", + "version": "5.4.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.4.tgz", + "integrity": "sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -26015,6 +26014,32 @@ "node": ">=14.17" } }, + "node_modules/typescript-eslint": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-7.5.0.tgz", + "integrity": "sha512-eKhF39LRi2xYvvXh3h3S+mCxC01dZTIZBlka25o39i81VeQG+OZyfC4i2GEDspNclMRdXkg9uGhmvWMhjph2XQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/eslint-plugin": "7.5.0", + "@typescript-eslint/parser": "7.5.0", + "@typescript-eslint/utils": "7.5.0" + }, + "engines": { + "node": "^18.18.0 || >=20.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.56.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/ua-parser-js": { "version": "1.0.36", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.36.tgz", diff --git a/package.json b/package.json index 118b51ca4..fa371ee3a 100644 --- a/package.json +++ b/package.json @@ -38,8 +38,6 @@ "devDependencies": { "@types/chroma-js": "^2.4.4", "@types/react": "^18.2.74", - "@typescript-eslint/eslint-plugin": "^7.5.0", - "@typescript-eslint/parser": "^7.5.0", "babel-plugin-styled-components": "^2.1.4", "eslint": "^9.0.0", "eslint-config-prettier": "^9.1.0", @@ -64,7 +62,8 @@ "husky": "^9.0.11", "lint-staged": "^15.2.2", "prettier": "^3.2.5", - "typescript": "^5.4.3" + "typescript": "^5.4.4", + "typescript-eslint": "^7.5.0" }, "lint-staged": { "*.{js,ts,tsx,mdx}": [ From 08dea4a21c195fc240af74a617a2cb9fcfbada09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= Date: Tue, 9 Apr 2024 13:50:39 +0200 Subject: [PATCH 4/6] fix warning --- eslint.config.mjs | 3 --- package.json | 6 +++--- src/components/CookieConsentBanner.tsx | 1 - src/sections/home/Newsletter.tsx | 5 +---- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 78527d9c4..fdefa8512 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -23,12 +23,9 @@ import * as eslintPluginMdx from 'eslint-plugin-mdx' import eslintParser from '@typescript-eslint/parser'; - const typeScriptExtensions = ['.ts', '.cts', '.mts', '.tsx']; - const allExtensions = [...typeScriptExtensions, '.js', '.jsx']; - /** @type {import('eslint').Linter.FlatConfig[]} */ export default [ eslintPluginPrettierRecommended, // Enables eslint-plugin-prettier, eslint-config-prettier and prettier/prettier. This will display prettier errors as ESLint errors. diff --git a/package.json b/package.json index fa371ee3a..9ac9e9efc 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "serve": "gatsby serve", "clean": "gatsby clean", "check-types": "tsc -p . --noEmit", - "lint": "eslint \"*/**/*.{js,ts,tsx,mdx}\" --max-warnings 0 --fix", - "lint-check": "eslint \"*/**/*.{js,ts,tsx,mdx}\" --max-warnings 0", + "lint": "npx eslint \"*/**/*.{js,ts,tsx,mdx}\" --max-warnings 0 --fix", + "lint-check": "npx eslint \"*/**/*.{js,ts,tsx,mdx}\" --max-warnings 0", "prepare": "husky" }, "dependencies": { @@ -67,7 +67,7 @@ }, "lint-staged": { "*.{js,ts,tsx,mdx}": [ - "eslint --fix" + "npx eslint --fix" ] } } diff --git a/src/components/CookieConsentBanner.tsx b/src/components/CookieConsentBanner.tsx index 4561450c6..c0f8738ca 100644 --- a/src/components/CookieConsentBanner.tsx +++ b/src/components/CookieConsentBanner.tsx @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -// eslint-disable-next-line @typescript-eslint/triple-slash-reference /// import { CookieManager } from '../helper'; diff --git a/src/sections/home/Newsletter.tsx b/src/sections/home/Newsletter.tsx index 2d27b895c..36aaeddd5 100644 --- a/src/sections/home/Newsletter.tsx +++ b/src/sections/home/Newsletter.tsx @@ -153,10 +153,7 @@ const Form: FC = props => { Date: Tue, 9 Apr 2024 16:54:50 +0200 Subject: [PATCH 5/6] remove old parser --- eslint.config.mjs | 3 --- 1 file changed, 3 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index fdefa8512..7416c72a9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,7 +20,6 @@ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended' import tseslint from 'typescript-eslint'; // import eslintPluginImport from 'eslint-plugin-import'; import * as eslintPluginMdx from 'eslint-plugin-mdx' -import eslintParser from '@typescript-eslint/parser'; const typeScriptExtensions = ['.ts', '.cts', '.mts', '.tsx']; @@ -116,8 +115,6 @@ export default [ ///////////////////////////////////////////////////////////////// - parser: eslintParser, - // This setting is required if you want to use rules which require type information // https://typescript-eslint.io/packages/parser/#project project: ['./tsconfig.json'], From dc8f2873530ba1784e1a44dd188f91ea97e47ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Souchet=20C=C3=A9line?= Date: Fri, 12 Apr 2024 14:52:18 +0200 Subject: [PATCH 6/6] add @eslint/js --- eslint.config.mjs | 7 +++---- package-lock.json | 2 +- package.json | 1 + 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 7416c72a9..50fd82e25 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -17,6 +17,7 @@ import noticePlugin from "eslint-plugin-notice"; import importPlugin from "eslint-plugin-import"; import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'; +import eslint from '@eslint/js'; import tseslint from 'typescript-eslint'; // import eslintPluginImport from 'eslint-plugin-import'; import * as eslintPluginMdx from 'eslint-plugin-mdx' @@ -68,11 +69,9 @@ export default [ }, // typescript + { ...eslint.configs.recommended, files: ['**/*.ts', '**/*.tsx'] }, + ...tseslint.configs.recommended.map(conf => ({ ...conf, files: ['**/*.ts', '**/*.tsx'] })), /** @type {import('@typescript-eslint/utils').TSESLint.FlatConfig.ConfigFile} */ - ...tseslint.configs.recommended.map(conf => ({ - ...conf, - files: ['**/*.ts', '**/*.tsx'], - })), { files: ['**/*.ts', '**/*.tsx'], // ...eslintPluginImport.configs.recommended, // To uncomment when it will support flat config diff --git a/package-lock.json b/package-lock.json index d0fd49c71..be7ad7abe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@emotion/react": "^11.11.4", "@emotion/styled": "^11.11.0", + "@eslint/js": "^9.0.0", "@fortawesome/fontawesome-svg-core": "^6.5.1", "@fortawesome/free-brands-svg-icons": "^6.5.1", "@fortawesome/free-solid-svg-icons": "^6.5.1", @@ -2543,7 +2544,6 @@ "version": "9.0.0", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.0.0.tgz", "integrity": "sha512-RThY/MnKrhubF6+s1JflwUjPEsnCEmYCWwqa/aRISKWNXGZ9epUwft4bUMM35SdKF9xvBrLydAM1RDHd1Z//ZQ==", - "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } diff --git a/package.json b/package.json index 9ac9e9efc..9c20af9f2 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "vanilla-cookieconsent": "^2.9.2" }, "devDependencies": { + "@eslint/js": "^9.0.0", "@types/chroma-js": "^2.4.4", "@types/react": "^18.2.74", "babel-plugin-styled-components": "^2.1.4",