diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index fce0e86e000498d25af7aeb2fcc9cf22c0bfac48..0000000000000000000000000000000000000000 --- a/.eslintrc.js +++ /dev/null @@ -1,115 +0,0 @@ -const path = require('node:path'); - -module.exports = { - root: true, - extends: ['plugin:@gitlab/default', 'plugin:storybook/csf'], - rules: { - 'import/no-extraneous-dependencies': 'off', - 'import/no-relative-packages': 'off', - '@gitlab/tailwind-no-interpolation': 'error', - 'no-restricted-imports': [ - 'error', - { - patterns: [ - { - group: ['**/index'], - message: - 'Import components and directives directly rather than via the top-level barrel file.', - }, - ], - paths: [ - { - name: 'lodash', - message: 'Import from lodash/ instead for better tree-shaking.', - }, - { - name: 'lodash/isArray', - message: 'Prefer native Array.isArray method.', - }, - { - name: 'lodash/isFinite', - message: 'Prefer native Number.isFinite method.', - }, - ], - }, - ], - 'vue/no-v-html': 'error', - 'max-params': ['error', { max: 3 }], - }, - overrides: [ - { - files: ['**/*.spec.js', 'tests/jest_setup.js', 'tests/__helpers__/*.js'], - extends: ['plugin:@gitlab/jest'], - settings: { - 'import/resolver': { - jest: { - jestConfigFile: path.join(__dirname, 'jest.config.js'), - }, - }, - }, - rules: { - 'promise/always-return': 'off', - 'jest/expect-expect': [ - 'warn', - { - assertFunctionNames: ['expect*'], - }, - ], - 'no-restricted-syntax': [ - 'error', - { - selector: - "CallExpression[callee.name='afterEach'] CallExpression MemberExpression[object.name='wrapper'][property.name='destroy']", - message: - 'No need to call wrapper.destroy() in afterEach due to enableAutoDestroy being enabled suite-wide.', - }, - ], - 'no-restricted-imports': [ - 'error', - { - paths: [ - { - name: '@vue/test-utils', - importNames: ['createLocalVue'], - message: - 'createLocalVue should be avoided. Perform operations on global Vue instance instead', - }, - ], - patterns: [ - { - group: ['**/index'], - message: - 'Import components and directives directly rather than via the top-level barrel file.', - }, - ], - }, - ], - '@gitlab/tailwind-no-interpolation': 'off', - }, - }, - { - files: ['**/*.stories.js'], - rules: { - 'no-restricted-globals': [ - 'error', - { - name: 'setTimeout', - message: 'use setStoryTimeout from the utils/test_utils instead.', - }, - ], - }, - }, - { - files: ['config.js', 'rollup.config.js', '**/index.js', '**/*.stories.js'], - rules: { - 'import/no-default-export': 'off', - }, - }, - { - files: ['**/*.vue'], - rules: { - 'vue/require-name-property': 'error', - }, - }, - ], -}; diff --git a/cypress/.eslintrc.json b/cypress/.eslintrc.json deleted file mode 100644 index b677df5693ba7b08e8034c22a6744cbe759a2801..0000000000000000000000000000000000000000 --- a/cypress/.eslintrc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "plugin:cypress/recommended" - ] -} \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000000000000000000000000000000000000..b151faac92826b3b0230691ebab595c7b92cf408 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,175 @@ +import path from 'node:path'; + +import { fileURLToPath } from 'node:url'; +import js from '@eslint/js'; +import { FlatCompat } from '@eslint/eslintrc'; +import pluginCypress from 'eslint-plugin-cypress/flat'; + +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, +}); + +export default [ + pluginCypress.configs.recommended, + { + ignores: [ + 'node_modules/', + 'storybook/', + 'dist/', + 'public/', + '**/.cypress_cache', + 'src/vendor/', + ], + }, + ...compat.extends('plugin:@gitlab/default', 'plugin:storybook/csf', 'plugin:@gitlab/jest'), + { + rules: { + 'import/no-extraneous-dependencies': 'off', + 'import/no-relative-packages': 'off', + 'import/no-deprecated': 'off', + '@gitlab/tailwind-no-interpolation': 'error', + + 'no-restricted-imports': [ + 'error', + { + patterns: [ + { + group: ['**/index'], + message: + 'Import components and directives directly rather than via the top-level barrel file.', + }, + ], + + paths: [ + { + name: 'lodash', + message: 'Import from lodash/ instead for better tree-shaking.', + }, + { + name: 'lodash/isArray', + message: 'Prefer native Array.isArray method.', + }, + { + name: 'lodash/isFinite', + message: 'Prefer native Number.isFinite method.', + }, + ], + }, + ], + + 'vue/no-v-html': 'error', + + 'max-params': [ + 'error', + { + max: 3, + }, + ], + }, + }, + { + files: ['**/*.spec.js', 'tests/jest_setup.js', 'tests/__helpers__/*.js'], + + settings: { + 'import/resolver': { + jest: { + jestConfigFile: path.join(dirname, 'jest.config.js'), + }, + }, + }, + + rules: { + 'promise/always-return': 'off', + + 'jest/expect-expect': [ + 'warn', + { + assertFunctionNames: ['expect*'], + }, + ], + + 'no-restricted-syntax': [ + 'error', + { + selector: + "CallExpression[callee.name='afterEach'] CallExpression MemberExpression[object.name='wrapper'][property.name='destroy']", + message: + 'No need to call wrapper.destroy() in afterEach due to enableAutoDestroy being enabled suite-wide.', + }, + ], + + 'no-restricted-imports': [ + 'error', + { + paths: [ + { + name: '@vue/test-utils', + importNames: ['createLocalVue'], + message: + 'createLocalVue should be avoided. Perform operations on global Vue instance instead', + }, + ], + + patterns: [ + { + group: ['**/index'], + message: + 'Import components and directives directly rather than via the top-level barrel file.', + }, + ], + }, + ], + + '@gitlab/tailwind-no-interpolation': 'off', + }, + }, + { + files: ['**/*.stories.js'], + + rules: { + 'no-restricted-globals': [ + 'error', + { + name: 'setTimeout', + message: 'use setStoryTimeout from the utils/test_utils instead.', + }, + ], + }, + }, + { + files: ['**/config.js', '**/rollup.config.js', '**/index.js', '**/*.stories.js'], + + rules: { + 'import/no-default-export': 'off', + }, + }, + { + files: ['**/*.vue'], + + rules: { + 'vue/require-name-property': 'error', + }, + }, + { + files: ['cypress/**/*.js'], + plugins: { + cypress: pluginCypress, + }, + rules: { + 'jest/expect-expect': 'off', + 'jest/no-identical-title': 'off', + 'jest/valid-describe-callback': 'off', + 'jest/valid-expect': 'off', + }, + }, + { + files: ['bin/**/*.{js,mjs}'], + rules: { + 'no-console': 'off', + }, + }, +]; diff --git a/package.json b/package.json index 2671da53b842dbb026faa3f2b694ca890efe71e4..41717a9fe676e2c5a0976a035c5816412210b40a 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "test:visual:internal": "NODE_ENV=test IS_VISUAL_TEST=true start-test storybook:run http-get://${STORYBOOK_HOST:-localhost}:${STORYBOOK_PORT:-9001}/iframe.html", "prettier": "prettier --check '**/*.{js,mjs,ts,vue}'", "prettier:fix": "prettier --write '**/*.{js,mjs,ts,vue}'", - "eslint": "eslint --max-warnings 0 --ext .js,.vue .", + "eslint": "eslint --max-warnings 0 .", "eslint:fix": "yarn eslint --fix", "stylelint": "stylelint 'src/**/*.scss'", "stylelint:fix": "yarn stylelint --fix", @@ -108,6 +108,8 @@ "@babel/preset-env": "^7.27.2", "@babel/preset-react": "^7.27.1", "@cypress/grep": "^4.0.1", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "^9.27.0", "@gitlab/eslint-plugin": "20.7.1", "@gitlab/fonts": "^1.3.0", "@gitlab/stylelint-config": "6.2.2", diff --git a/yarn.lock b/yarn.lock index 5c7b91c1236598c5b826115e17891eeaa3ed7b57..df1f9c93e70130e2613d2cd9aefb4b53c1bc0dbc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1290,11 +1290,31 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" +"@eslint/eslintrc@^3.3.1": + version "3.3.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-3.3.1.tgz#e55f7f1dd400600dd066dbba349c4c0bac916964" + integrity sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ== + dependencies: + ajv "^6.12.4" + debug "^4.3.2" + espree "^10.0.1" + globals "^14.0.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" + "@eslint/js@8.57.1": version "8.57.1" resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.57.1.tgz#de633db3ec2ef6a3c89e2f19038063e8a122e2c2" integrity sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q== +"@eslint/js@^9.27.0": + version "9.27.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.27.0.tgz#181a23460877c484f6dd03890f4e3fa2fdeb8ff0" + integrity sha512-G5JD9Tu5HJEu4z2Uo4aHY2sLV64B7CDMXxFzqzjl3NKd6RVzSXNoE80jk7Y0lJkTTkjiIhBAqmlYwjuBY3tvpA== + "@fal-works/esbuild-plugin-global-externals@^2.1.2": version "2.1.2" resolved "https://registry.yarnpkg.com/@fal-works/esbuild-plugin-global-externals/-/esbuild-plugin-global-externals-2.1.2.tgz#c05ed35ad82df8e6ac616c68b92c2282bd083ba4" @@ -7099,6 +7119,11 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4 resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== +eslint-visitor-keys@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz#687bacb2af884fcdda8a6e7d65c606f46a14cd45" + integrity sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw== + eslint@8.57.1: version "8.57.1" resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.57.1.tgz#7df109654aba7e3bbe5c8eae533c5e461d3c6ca9" @@ -7143,6 +7168,15 @@ eslint@8.57.1: strip-ansi "^6.0.1" text-table "^0.2.0" +espree@^10.0.1: + version "10.3.0" + resolved "https://registry.yarnpkg.com/espree/-/espree-10.3.0.tgz#29267cf5b0cb98735b65e64ba07e0ed49d1eed8a" + integrity sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg== + dependencies: + acorn "^8.14.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^4.2.0" + espree@^9.3.1, espree@^9.6.0, espree@^9.6.1: version "9.6.1" resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" @@ -8109,6 +8143,11 @@ globals@^13.19.0, globals@^13.20.0, globals@^13.24.0: dependencies: type-fest "^0.20.2" +globals@^14.0.0: + version "14.0.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-14.0.0.tgz#898d7413c29babcf6bafe56fcadded858ada724e" + integrity sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ== + globals@^15.7.0: version "15.9.0" resolved "https://registry.yarnpkg.com/globals/-/globals-15.9.0.tgz#e9de01771091ffbc37db5714dab484f9f69ff399"