Skip to content

Commit

Permalink
fix(linter): move eslint-config-prettier to the end for proper overri…
Browse files Browse the repository at this point in the history
…de (#28503)

There is a conflict between ESLint and Prettier rules, which causes
incorrect formatting behavior.

Reordering the config so that `eslint-config-prettier` is applied last
ensures proper rule overrides and resolves conflicts with Prettier.

---------

Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
  • Loading branch information
demonicattack and leosvelperez authored Nov 19, 2024
1 parent e4ce2b1 commit 25909b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions packages/eslint-plugin/src/flat-configs/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export default tseslint.config(
files: ['**/*.js', '**/*.jsx'],
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
},
...(isPrettierAvailable ? [require('eslint-config-prettier')] : []),
{
languageOptions: {
parser: tseslint.parser,
Expand Down Expand Up @@ -80,5 +79,9 @@ export default tseslint.config(
*/
'@typescript-eslint/no-require-imports': 'off',
},
}
},
/**
* We include it last so it overrides the conflicting rules from the configuration blocks above.
*/
...(isPrettierAvailable ? [require('eslint-config-prettier')] : [])
);
7 changes: 5 additions & 2 deletions packages/eslint-plugin/src/flat-configs/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default tseslint.config(
files: ['**/*.ts', '**/*.tsx'],
extends: [eslint.configs.recommended, ...tseslint.configs.recommended],
},
...(isPrettierAvailable ? [require('eslint-config-prettier')] : []),
{
plugins: { '@typescript-eslint': tseslint.plugin },
languageOptions: {
Expand Down Expand Up @@ -64,5 +63,9 @@ export default tseslint.config(
*/
'@typescript-eslint/no-require-imports': 'off',
},
}
},
/**
* We include it last so it overrides the conflicting rules from the configuration blocks above.
*/
...(isPrettierAvailable ? [require('eslint-config-prettier')] : [])
);

0 comments on commit 25909b0

Please sign in to comment.