mdx-js / eslint-mdx

ESLint Parser/Plugin for MDX
https://npmjs.org/eslint-plugin-mdx
MIT License
264 stars 32 forks source link

Doesn't work with a complex system of layered ESLint configs #332

Closed KevinGhadyani-minted closed 3 years ago

KevinGhadyani-minted commented 3 years ago

Subject of the issue

I have a bunch of ESLint plugins and want to add this MDX one to the mix. Sadly, it seems my other plugins all interfere with each other.

The other library has these plugins:

  plugins: [
    'import',
    'modules-newline',
    'putout',
    'sort-destructure-keys',
  ],

It appears that some like putout aren't specific to .js files; therefore, they'll run on MDX files.

This is the ESLint config I settled on:

module.exports = {
  overrides: [
    {
      extends: [
        '@company/eslint-config-core',
        '@company/eslint-config-react',
        '@company/eslint-config-jest',
        'plugin:cypress/recommended',
      ],
      files: '**/*.{js,jsx,ts,tsx}',
      parser: '@babel/eslint-parser',
      plugins: [
        'cypress',
      ],
      rules: {
        'react/react-in-jsx-scope': 'off',
      },
    },
    {
      extends: [
        'plugin:json/recommended',
      ],
      files: '**/*.{json}',
    },
    {
      extends: [
        'plugin:mdx/recommended',
        'plugin:mdx/overrides',
        'plugin:mdx/code-blocks',
      ],
      files: '**/*.{md,mdx}',
      parser: 'eslint-mdx',
      settings: {
        'mdx/code-blocks': true,
      },
    },
  ],
  parserOptions: {
    babelOptions: {
      configFile: (
        require
          .resolve(
            '@company/babel-config-scripts-app'
          )
      ),
    },
    ecmaVersion: 2021,
    sourceType: 'module',
  },
  rules: {
    'react/react-in-jsx-scope': 'off',
  },
};

Your environment

Steps to reproduce

  1. Have a bunch of ESLint configurations that layer on each other.
  2. Have some other 3rd party plugins.
  3. Watch as MDX files are linted (and auto-fixed) as if they're JSX files.

Expected behaviour

Only eslint-mdx should be linting MD and MDX files.

Actual behaviour

All MD and MDX files are linted by other plugins which aren't eslint-mdx.

JounQin commented 3 years ago

Please provide a minimal reproduction, the issue content does not help much.

KevinGhadyani-minted commented 3 years ago

I don't have time to make a reproduction. Closing the issue.