-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor ESLint configuration and update dependencies #900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
11f50ad
Refactor ESLint configuration and update dependencies
achour94 23166ac
Merge branch 'main' into upgrade-eslint-typescript-prettier
achour94 56e104f
Resolve comments
achour94 f977e5c
Merge remote-tracking branch 'origin/main' into upgrade-eslint-typesc…
achour94 2ca54a6
Merge branch 'main' into upgrade-eslint-typescript-prettier
achour94 6cbb489
Resolve comments
achour94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| /** | ||
| * Copyright (c) 2025, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
|
|
||
| /** | ||
| * Base ESLint config initially generated by `eslint-config-airbnb-extended` (v2.3.2) | ||
| * using the React + Prettier + TypeScript template, then manually adapted for Commons-ui. | ||
| * Source template: | ||
| * https://eslint-airbnb-extended.nishargshah.dev/cli/guide | ||
| * https://github.com/NishargShah/eslint-config-airbnb-extended/blob/v2.3.2/packages/create-airbnb-x-config/templates/react/prettier/ts/default/eslint.config.mjs | ||
| */ | ||
|
|
||
| import { configs, plugins } from 'eslint-config-airbnb-extended'; | ||
| import { rules as prettierConfigRules } from 'eslint-config-prettier'; | ||
| import prettierPlugin from 'eslint-plugin-prettier'; | ||
| import js from '@eslint/js'; | ||
|
|
||
| const jsConfig = [ | ||
| // ESLint Recommended Rules | ||
| { | ||
| name: 'js/config', | ||
| ...js.configs.recommended, | ||
| }, | ||
| // Stylistic Plugin | ||
| plugins.stylistic, | ||
| // Import X Plugin | ||
| plugins.importX, | ||
| // Airbnb Base Recommended Config | ||
| ...configs.base.recommended, | ||
| ]; | ||
|
|
||
| const reactConfig = [ | ||
| // React Plugin | ||
| plugins.react, | ||
| // React Hooks Plugin | ||
| plugins.reactHooks, | ||
| // React JSX A11y Plugin | ||
| plugins.reactA11y, | ||
| // Airbnb React Recommended Config | ||
| ...configs.react.recommended, | ||
| ]; | ||
|
|
||
| const typescriptConfig = [ | ||
| // TypeScript ESLint Plugin | ||
| plugins.typescriptEslint, | ||
| // Airbnb Base TypeScript Config | ||
| ...configs.base.typescript, | ||
| // Airbnb React TypeScript Config | ||
| ...configs.react.typescript, | ||
| ]; | ||
|
|
||
| const prettierConfig = [ | ||
| // Prettier Plugin | ||
| { | ||
| name: 'prettier/plugin/config', | ||
| plugins: { | ||
| prettier: prettierPlugin, | ||
| }, | ||
| }, | ||
| // Prettier Config (disable conflicting rules) | ||
| { | ||
| name: 'prettier/config', | ||
| rules: { | ||
| ...prettierConfigRules, | ||
| 'prettier/prettier': 'warn', | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| const projectConfig = [ | ||
| { | ||
| name: 'project/ignores', | ||
| ignores: ['dist', 'coverage'], | ||
| }, | ||
| // Settings | ||
| { | ||
| name: 'project/settings', | ||
| settings: { | ||
| react: { | ||
| version: 'detect', | ||
| }, | ||
| }, | ||
| }, | ||
| // React JSX Runtime (prevents "React must be in scope" errors) | ||
| { | ||
| name: 'project/react-jsx-runtime', | ||
| files: ['**/*.{jsx,tsx}'], | ||
| rules: { | ||
| 'react/react-in-jsx-scope': 'off', | ||
| 'react/jsx-uses-react': 'off', | ||
| }, | ||
| }, | ||
| // Custom rules | ||
| { | ||
| name: 'project/rules', | ||
| rules: { | ||
| // Code style | ||
| curly: 'error', | ||
| 'no-console': 'off', | ||
| 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }], | ||
|
|
||
| // React rules | ||
| 'react/jsx-props-no-spreading': 'off', | ||
| 'react/require-default-props': 'off', | ||
|
|
||
| // Import rules | ||
| 'import-x/prefer-default-export': 'off', | ||
| 'import-x/extensions': 'off', | ||
| 'import-x/no-unresolved': 'off', | ||
| 'import-x/no-useless-path-segments': 'off', | ||
| 'import-x/no-extraneous-dependencies': [ | ||
| 'error', | ||
| { | ||
| devDependencies: [ | ||
| 'test/**', | ||
| 'tests/**', | ||
| 'spec/**', | ||
| '**/__tests__/**', | ||
| '**/__mocks__/**', | ||
| 'test.{js,jsx,ts,tsx}', | ||
| 'test-*.{js,jsx,ts,tsx}', | ||
| '**/*{.,_}{test,spec}.{js,jsx,ts,tsx}', | ||
| '**/jest.config.ts', | ||
| '**/jest.setup.ts', | ||
| '**/prettier.config.js', | ||
| '**/vite.config.ts', | ||
| '**/eslint.config.js', | ||
| ], | ||
| optionalDependencies: false, | ||
| }, | ||
| ], | ||
|
|
||
| // MUI deep imports restriction | ||
| 'no-restricted-imports': [ | ||
| 'warn', | ||
| { | ||
| patterns: [ | ||
| { | ||
| group: [ | ||
| '@mui/*/*', | ||
| '!@mui/material/colors', | ||
| '!@mui/material/locale', | ||
| '!@mui/icons-material/*', | ||
| ], | ||
| message: | ||
| 'Deep imports from MUI libraries are forbidden. Import only from the library root.', | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
|
|
||
| // Disable strict type-aware rules that weren't in old config | ||
| '@typescript-eslint/no-unsafe-enum-comparison': 'off', | ||
| '@typescript-eslint/consistent-type-definitions': 'off', | ||
| '@typescript-eslint/no-inferrable-types': 'off', | ||
| '@typescript-eslint/consistent-indexed-object-style': 'off', | ||
| '@typescript-eslint/no-empty-object-type': 'off', | ||
| '@typescript-eslint/no-unnecessary-template-expression': 'off', | ||
| '@typescript-eslint/no-duplicate-enum-values': 'off', | ||
| '@typescript-eslint/no-wrapper-object-types': 'off', | ||
| '@typescript-eslint/array-type': 'off', | ||
| '@typescript-eslint/no-unnecessary-type-arguments': 'off', | ||
| 'arrow-body-style': 'off', | ||
| 'no-shadow': 'off', | ||
| 'no-unused-expressions': ['error', { allowShortCircuit: true }], | ||
| 'prefer-arrow-callback': 'off', | ||
| 'no-unused-vars': ['off', { argsIgnorePattern: '^_' }], | ||
| '@typescript-eslint/no-unnecessary-type-assertion': 'off', | ||
| 'prefer-object-has-own': 'off', | ||
| }, | ||
| }, | ||
| ]; | ||
|
|
||
| export default [...jsConfig, ...reactConfig, ...typescriptConfig, ...prettierConfig, ...projectConfig]; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.