iamturns / eslint-config-airbnb-typescript

Airbnb's ESLint config with TypeScript support
MIT License
1.05k stars 101 forks source link

No Definition found for "comma_dangle", "no-loop-func", "no-redeclare" and "no-shadow" #185

Open dtwardy opened 3 years ago

dtwardy commented 3 years ago

So I recently encountered some issue with a boilerplate repo of mine when I moved to higher versions of several tools. It is probably my mistake but since I could not for the love of the code gods find the issue.

ESLint is complaining about 4 missing rules:

Definition for rule '@typescript-eslint/comma-dangle' was not found. Definition for rule '@typescript-eslint/no-loop-func' was not found. Definition for rule '@typescript-eslint/no-redeclare' was not found. Definition for rule '@typescript-eslint/no-shadow' was not found.

The following dependencies are in my package.json:

"devDependencies": {
    "@types/chai": "4.2.11",
    "@types/mocha": "7.0.2",
    "@types/node": "14.0.13",
    "@typescript-eslint/eslint-plugin": "^4.4.1",
    "@typescript-eslint/parser": "4.13.0",
    "chai": "4.2.0",
    "eslint": "^7.15.0",
    "eslint-config-airbnb-typescript": "^12.0.0",
    "eslint-config-prettier": "7.1.0",
    "eslint-plugin-chai-expect": "2.2.0",
    "eslint-plugin-eslint-comments": "3.2.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-mocha": "8.0.0",
    "eslint-plugin-prettier": "3.3.1",
    "eslint-plugin-react": "^7.20.3",
    "eslint-plugin-react-hooks": "^4.0.8",
    "grunt": "1.3.0",
    "grunt-cli": "1.3.2",
    "grunt-contrib-clean": "2.0.0",
    "grunt-contrib-watch": "1.1.0",
    "grunt-eslint": "23.0.0",
    "grunt-git": "1.0.14",
    "grunt-shell": "3.0.1",
    "grunt-string-replace": "1.3.1",
    "grunt-ts": "6.0.0-beta.22",
    "mocha": "8.2.1",
    "nyc": "15.1.0",
    "prettier": "2.2.1",
    "ts-mocha": "8.0.0",
    "ts-node": "9.1.1",
    "tsconfig-paths": "3.9.0",
    "typedoc": "0.17.7",
    "typescript": "4.1.3"
},

And my .eslintrc.js file looks as follows:

module.exports = {
  plugins: ['@typescript-eslint', 'eslint-comments', 'mocha', 'chai-expect'],
  extends: [
    'airbnb-typescript',
    'airbnb/hooks',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
    'plugin:eslint-comments/recommended',
    'plugin:mocha/recommended',
    'plugin:chai-expect/recommended',
  ],
  env: {
    es2020: true,
    mocha: true,
    node: true,
  },
  parser: '@typescript-eslint/parser',
  parserOptions: {
    project: './tsconfig.json',
    ecmaVersion: 11,
    sourceType: 'module',
  },
  settings: {
    'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
    'import/parsers': {
      '@typescript-eslint/parser': ['.ts', '.tsx'],
    },
    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
    },
  },
  rules: {
    'no-unused-vars': 'off',
    '@typescript-eslint/no-unused-vars': 'error',
    'no-useless-constructor': 'off',
    '@typescript-eslint/no-useless-constructor': 'error',
    'linebreak-style': ['error', 'windows'],
    'import/prefer-default-export': 'off',
    'importDeclaration': 'off',
    'no-console': 'off',
    'prefer-arrow-callback': 'off',
  },
};
iamturns commented 3 years ago

See if uninstalling @typescript-eslint/parser helps. This config installs that for you, there's no need to install it yourself. I'm not sure if it's the problem, but worth a try, perhaps the versions are out of sync with @typescript-eslint/eslint-plugin

anirudh1713 commented 3 years ago

I am facing the same issue but with different rules.

image

"devDependencies": {
    "@typescript-eslint/eslint-plugin": "4.4.1",
    "eslint": "^7.25.0",
    "eslint-config-airbnb-typescript": "^12.3.1",
    "eslint-plugin-import": "2.22.0",
    "eslint-plugin-jsx-a11y": "6.3.1",
    "eslint-plugin-react": "7.20.3",
    "eslint-plugin-react-hooks": "4.0.8"
  }

.eslintrc.js

module.exports = {
  extends: [
    'airbnb-typescript',
    'airbnb/hooks',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
  ],
  parserOptions: {
    project: './tsconfig.eslint.json',
    sourceType: 'module',
    createDefaultProgram: true,
  },
};

tsconfig.eslint.json

{
  "extends": "./tsconfig.json",
  "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx",]
}

UPDATE

So i tried with new project again and its working fine

.eslintrc.js

module.exports = {
  extends: ['airbnb-typescript'],
  overrides: [
    {
      files: ['*.ts', '*.tsx'],
      parserOptions: {
        project: ['./tsconfig.json'],
      },
    }
  ],
  parser: '@typescript-eslint/parser',
};
"devDependencies": {
    "@typescript-eslint/eslint-plugin": "^4.22.0",
    "eslint": "^7.25.0",
    "eslint-config-airbnb-typescript": "^12.3.1",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.23.2",
    "eslint-plugin-react-hooks": "^4.2.0"
  }