Skip to content

Commit

Permalink
Require eslint-config-prettier if eslint-plugin-prettier is in `e…
Browse files Browse the repository at this point in the history
…xtends` (fixes #128)
  • Loading branch information
webpro committed May 17, 2023
1 parent ce29c84 commit 3655301
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/plugins/eslint/helpers.ts
Expand Up @@ -12,6 +12,8 @@ type Manifest = PackageJson & { eslintConfig?: ESLintConfig };
const getDependencies = (config: ESLintConfig | OverrideConfig) => {
const extendsSpecifiers = config.extends ? [config.extends].flat().map(resolveExtendsSpecifier) : [];
const plugins = config.plugins ? config.plugins.map(resolvePluginPackageName) : [];
// https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
if (extendsSpecifiers.includes('eslint-plugin-prettier')) extendsSpecifiers.push('eslint-config-prettier');
const parser = config.parser;
const extraParsers = config.parserOptions?.babelOptions?.presets ?? [];
const settings = config.settings ? getDependenciesFromSettings(config.settings) : [];
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/plugins/eslint/.eslintrc.js
Expand Up @@ -3,7 +3,6 @@ module.exports = {
extends: [
require.resolve('./base.eslint.json'),
'airbnb',
'plugin:prettier/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
Expand All @@ -13,8 +12,9 @@ module.exports = {
'plugin:eslint-comments/recommended',
'plugin:eslint-plugin/all',
'@scope/eslint-config/file',
'plugin:prettier/recommended',
],
plugins: ['@typescript-eslint', '@nrwl/nx', 'prettier', 'eslint-plugin-cypress', '@scope/eslint-plugin'],
plugins: ['@typescript-eslint', '@nrwl/nx', 'eslint-plugin-cypress', '@scope/eslint-plugin'],
settings: {
'import/resolver': {
typescript: true,
Expand Down
3 changes: 2 additions & 1 deletion tests/plugins/eslint.test.ts
Expand Up @@ -29,13 +29,14 @@ test('Find dependencies in ESLint configuration (legacy js)', async () => {
'eslint-plugin-import',
'@typescript-eslint/parser',
'eslint-config-airbnb',
'eslint-plugin-prettier',
'@typescript-eslint/eslint-plugin',
'eslint-config-next',
'@next/eslint-plugin-next',
'eslint-plugin-eslint-comments',
'eslint-plugin-eslint-plugin',
'@scope/eslint-config/file',
'eslint-plugin-prettier',
'eslint-config-prettier',
'@nrwl/eslint-plugin-nx',
'eslint-plugin-cypress',
'@scope/eslint-plugin',
Expand Down

0 comments on commit 3655301

Please sign in to comment.