docz icon indicating copy to clipboard operation
docz copied to clipboard

DX with eslint + prettier + typescript + vscode

Open kilianc opened this issue 6 years ago • 1 comments

Question

I have been trying to set this up for my team, so far unsuccessfully and that's why I am here! How do I add mdx linting into the mix?

This is my .eslintrc.js file and it works wonderfully.

module.exports = {
  parser: '@typescript-eslint/parser',
  plugins: ['react-hooks'],
  extends: [
    'plugin:react/recommended',
    'plugin:@typescript-eslint/recommended',
    'prettier/@typescript-eslint',
    'plugin:prettier/recommended'
  ],
  parserOptions: {
    ecmaVersion: 2018,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true
    }
  },
  rules: {
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/no-use-before-define': 'off',
    'react/prop-types': 'off',
    'react-hooks/rules-of-hooks': 'error',
    'react-hooks/exhaustive-deps': 'error'
  },
  settings: {
    react: {
      version: 'detect'
    }
  }
}

Adding plugin:mdx/recommended to the list of plugins gives me a bunch of these:

error  Expected an assignment or function call and instead saw an expression  mdx/no-unused-expressions

It also does not parse the mdx files correctly when I run

tsc --noEmit --skipLibCheck && eslint 'src/**/*.{js,ts,tsx,mdx}' --max-warnings=0

Where do I go from here?

kilianc avatar Mar 26 '20 16:03 kilianc

@kilianc have you solved it? I think I have something similar.. I think it complains about "---" in the MDX files

magdalko avatar Apr 07 '20 07:04 magdalko