mongkuen / gatsby-plugin-eslint

Gatsby plugin to add support for ESLint
MIT License
13 stars 14 forks source link

Gatsby Required rules rules not found #36

Open caneta opened 2 years ago

caneta commented 2 years ago

Hi everyone, despite I have followed official docs (here and here), I get the following notification by VSCode:

eslintAnonymousExport

Am I missing something?

Here my gatsby-config.js (I've reported the only interesting lines):

const path = require('path');

const gatsbyRequiredRules = path.join(
  process.cwd(),
  'node_modules',
  'gatsby',
  'dist',
  'utils',
  'eslint-rules'
);

{
  resolve: 'gatsby-plugin-eslint',
  options: {
    rulePaths: [gatsbyRequiredRules],
    stages: ['develop', 'build-javascript'],
    extensions: ['js', 'jsx', 'ts', 'tsx'],
    exclude: ['node_modules', 'bower_components', '.cache', 'public'],
  },
},

And this is my .eslintrc.js (the whole file):

module.exports = {
  globals: {
    __PATH_PREFIX__: true,
  },
  parserOptions: {
    ecmaFeatures: {
      jsx: true,
    },
    ecmaVersion: 12,
    sourceType: 'module',
  },
  settings: {
    react: {
      version: 'detect', // detect react version
    },
  },
  env: {
    node: true, // defines things like process.env when generating through node
    browser: true,
    es2021: true,
  },
  plugins: ['react', 'react-hooks', 'jsx-a11y'],
  extends: [
    'react-app',
    'eslint:recommended', // use recommended configs
    'plugin:react/recommended',
    'plugin:react-hooks/recommended',
    'plugin:jsx-a11y/recommended',
  ],
  rules: {
    'no-anonymous-exports-page-templates': 'warn', // Gatsby required rule
    'limited-exports-page-templates': 'warn', // Gatsby required rule
    'react-hooks/rules-of-hooks': 'error',
    'react-hooks/exhaustive-deps': 'warn',
    'react/prop-types': 0,
  },
};

Let me know how can I fix this, thank you!

caneta commented 2 years ago

Hi, we've solved adding the following to our .vscode/settings.json file:

"eslint.options": {
    "rulePaths": ["node_modules/gatsby/dist/utils/eslint-rules"]
}