diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index ee98c5bdb0..0000000000 --- a/.eslintignore +++ /dev/null @@ -1,8 +0,0 @@ -# Contains the PDF file of the Tag as JSON string, thus does not need to be linted -src/components/CheckIn/tagTemplate.ts -package.json -package-lock.json -tsconfig.json - -# Ignore the Docusaurus website subdirectory -docs/** \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index de93fb465f..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,157 +0,0 @@ -{ - "env": { - "browser": true, - "node": true, - "es6": true - }, - - "extends": [ - "plugin:react/recommended", - "eslint:recommended", - "plugin:jest/recommended", - "plugin:prettier/recommended", - "plugin:@typescript-eslint/recommended", - "eslint-config-prettier", - "prettier" - ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 2018, - "sourceType": "module" - }, - - "plugins": [ - "react", - "@typescript-eslint", - "jest", - "import", - "eslint-plugin-tsdoc", - "prettier" - ], - "rules": { - "react/destructuring-assignment": "error", - "@typescript-eslint/explicit-module-boundary-types": "error", - "react/no-multi-comp": [ - "error", - { - "ignoreStateless": false - } - ], - "react/jsx-filename-extension": [ - "error", - { - "extensions": [".tsx"] - } - ], - "import/no-duplicates": "error", - "tsdoc/syntax": "error", - "@typescript-eslint/ban-ts-comment": "error", - "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/no-explicit-any": "error", - "@typescript-eslint/no-inferrable-types": "error", - "@typescript-eslint/no-non-null-asserted-optional-chain": "error", - "@typescript-eslint/no-non-null-assertion": "error", - "@typescript-eslint/no-var-requires": "error", - "@typescript-eslint/no-unsafe-function-type": "error", - "@typescript-eslint/no-wrapper-object-types": "error", - "@typescript-eslint/no-empty-object-type": "error", - "@typescript-eslint/no-duplicate-enum-values": "error", - "@typescript-eslint/array-type": "error", - "@typescript-eslint/consistent-type-assertions": "error", - "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/explicit-function-return-type": [ - 2, - { - "allowExpressions": true, - "allowTypedFunctionExpressions": true - } - ], - "camelcase": "off", - "@typescript-eslint/naming-convention": [ - "error", - - { - "selector": "interface", - "format": ["PascalCase"], - "prefix": ["Interface", "TestInterface"] - }, - - { - "selector": ["typeAlias", "typeLike", "enum"], - "format": ["PascalCase"] - }, - { - "selector": "typeParameter", - "format": ["PascalCase"], - "prefix": ["T"] - }, - { - "selector": "variable", - "format": ["camelCase", "UPPER_CASE", "PascalCase"], - "leadingUnderscore": "allow" - }, - { - "selector": "parameter", - "format": ["camelCase"], - "leadingUnderscore": "allow" - }, - { - "selector": "function", - "format": ["camelCase", "PascalCase"] - }, - { - "selector": "memberLike", - "modifiers": ["private"], - "format": ["camelCase"], - "leadingUnderscore": "require" - }, - - { - "selector": "variable", - "modifiers": ["exported"], - "format": null - } - ], - - "react/jsx-pascal-case": [ - "error", - { "allowAllCaps": false, "allowNamespace": false } - ], - - "react/jsx-equals-spacing": ["warn", "never"], - "react/no-this-in-sfc": "error", - - "jest/expect-expect": 0, - - "react/no-unstable-nested-components": ["error", { "allowAsProps": true }], - "react/function-component-definition": [ - 0, - { "namedComponents": "function-declaration" } - ], - "prettier/prettier": "error" - }, - - "settings": { - "react": { - "version": "detect" - } - }, - "ignorePatterns": [ - "**/*.css", - "**/*.scss", - "**/*.less", - "**/*.json", - "**/*.svg", - "docs/docusaurus.config.ts", - "docs/sidebars.ts", - "docs/src/**", - "docs/blog/**" - ] -} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 4708e39869..02e10698d3 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -112,7 +112,7 @@ jobs: .prettierrc .prettierignore .nojekyll - vite.config.ts + vitest.config.ts docker-compose.yaml Dockerfile CODEOWNERS diff --git a/eslint.config.mjs b/eslint.config.mjs index e49414f4ba..5796bbfd51 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -12,13 +12,18 @@ import { fileURLToPath } from 'node:url'; import js from '@eslint/js'; import { FlatCompat } from '@eslint/eslintrc'; -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 function createESLintCompat() { + const _filename = fileURLToPath(import.meta.url); + const _dirname = path.dirname(_filename); + + return new FlatCompat({ + baseDirectory: _dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, + }); +} + +const compat = createESLintCompat(); export default [ { diff --git a/package-lock.json b/package-lock.json index c5d46b55ec..42b6fae7e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,6 +85,7 @@ "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^12.1.10", + "@types/eslint__eslintrc": "^2.1.2", "@types/inquirer": "^9.0.7", "@types/jest": "^26.0.24", "@types/js-cookie": "^3.0.6", @@ -5858,6 +5859,25 @@ "resolved": "https://registry.npmjs.org/@types/d3-time/-/d3-time-3.0.3.tgz", "integrity": "sha512-2p6olUZ4w3s+07q3Tm2dbiMZy5pCDfYwtLXXHUnVzXgQlZ/OyPtUz6OL382BkOuGlLXqfT+wqv8Fw2v8/0geBw==" }, + "node_modules/@types/eslint": { + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz", + "integrity": "sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/eslint__eslintrc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@types/eslint__eslintrc/-/eslint__eslintrc-2.1.2.tgz", + "integrity": "sha512-qXvzPFY7Rz05xD8ZApXJ3S8xStQD2Ibzu3EFIF0UMNOAfLY5xUu3H61q0JrHo2OXD6rcFG75yUxNQbkKtFKBSw==", + "dev": true, + "dependencies": { + "@types/eslint": "*" + } + }, "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", diff --git a/package.json b/package.json index 756996b51c..c9b22c9613 100644 --- a/package.json +++ b/package.json @@ -122,6 +122,7 @@ "@testing-library/jest-dom": "^6.6.3", "@testing-library/react": "^16.0.1", "@testing-library/user-event": "^12.1.10", + "@types/eslint__eslintrc": "^2.1.2", "@types/inquirer": "^9.0.7", "@types/jest": "^26.0.24", "@types/js-cookie": "^3.0.6", diff --git a/src/createESLint.test.ts b/src/createESLint.test.ts new file mode 100644 index 0000000000..9095e1b16e --- /dev/null +++ b/src/createESLint.test.ts @@ -0,0 +1,19 @@ +import { createESLintCompat } from '../eslint.config.mjs'; +import { FlatCompat } from '@eslint/eslintrc'; + +describe('createESLintCompat', () => { + it('should initialize FlatCompat with the correct configuration', () => { + const compat = createESLintCompat(); + + expect(compat).toBeDefined(); + expect(compat).toHaveProperty('baseDirectory'); + expect(compat).toHaveProperty('recommendedConfig'); + expect(compat).toHaveProperty('allConfig'); + }); + + it('should return a valid FlatCompat instance', () => { + const compat = createESLintCompat(); + + expect(compat instanceof FlatCompat).toBe(true); + }); +}); diff --git a/src/eslint.config.spec.mjs b/src/eslint.config.spec.mjs deleted file mode 100644 index b94c8f1782..0000000000 --- a/src/eslint.config.spec.mjs +++ /dev/null @@ -1,40 +0,0 @@ -import { ESLint } from 'eslint'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; - -const _filename = fileURLToPath(import.meta.url); -const _dirname = path.dirname(_filename); - -describe('ESLint Config Tests', () => { - let eslint; - - beforeAll(() => { - eslint = new ESLint({ - overrideConfigFile: path.resolve(_dirname, '../eslint.config.mjs'), - }); - }); - - test('should ignore specified file patterns', async () => { - const results = await eslint.lintFiles([ - '**/*.css', - '**/*.scss', - '**/*.less', - '**/*.json', - '**/*.svg', - 'docs/docusaurus.config.ts', - 'docs/sidebars.ts', - 'docs/src/**/*', - 'docs/blog/**/*', - 'src/components/CheckIn/tagTemplate.ts', - '**/package.json', - '**/package-lock.json', - '**/tsconfig.json', - 'docs/**/*', - ]); - - results.forEach((result) => { - expect(result.errorCount).toBe(0); - expect(result.warningCount).toBe(0); - }); - }); -});