Skip to content

Commit

Permalink
fix(eslint-plugin): make import/no-extraneous-dependencies work for r…
Browse files Browse the repository at this point in the history
…eact config
  • Loading branch information
Hotell committed Mar 2, 2022
1 parent 70ee9eb commit da09e63
Showing 1 changed file with 29 additions and 36 deletions.
65 changes: 29 additions & 36 deletions packages/eslint-plugin/src/configs/react.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-check
const path = require('path');
const configHelpers = require('../utils/configHelpers');

const gitRoot = configHelpers.findGitRoot();
Expand All @@ -9,35 +8,25 @@ const config = {
extends: [
// Provides both rules and some parser options and other settings
'airbnb',
// add typescript support for import plugin
'plugin:import/typescript',
// Extended configs are applied in order, so these configs that turn other rules off should come last
'prettier',
],
parser: '@typescript-eslint/parser',
// parserOptions: {},
plugins: [
'@fluentui',
'@rnx-kit',
'@typescript-eslint',
'deprecation',
'import',
'jest',
'jsdoc',
'jsx-a11y',
'react',
'react-hooks',
],
settings: {
// Some config suggestions copied from https://github.com/alexgorbatchev/eslint-import-resolver-typescript#configuration
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
},
'import/resolver': {
typescript: {
// always try to resolve types under `<root>@types` directory
alwaysTryTypes: true,
// NOTE: For packages without a tsconfig.json, override with "project": "../../tsconfig.json"
project: ['./tsconfig.json', path.join(gitRoot, 'tsconfig.json')],
},
},
jsdoc: {
ignoreInternal: true,
tagNamePreference: {
Expand Down Expand Up @@ -102,7 +91,6 @@ const config = {
'dot-notation': 'error',
eqeqeq: ['error', 'always'],
'guard-for-in': 'error',
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
'jsx-a11y/tabindex-no-positive': 'error',
'no-alert': 'error',
'no-bitwise': 'error',
Expand Down Expand Up @@ -173,15 +161,7 @@ const config = {
'default-case': 'off',
'func-names': 'off',
'global-require': 'off',
'import/extensions': 'off',
'import/first': 'off',
'import/newline-after-import': 'off',
'import/no-duplicates': 'off', // mostly redundant with no-duplicate-imports
'import/no-dynamic-require': 'off',
'import/no-mutable-exports': 'off',
'import/no-unresolved': 'off',
'import/no-useless-path-segments': 'off',
'import/order': 'off',

'jsx-a11y/alt-text': 'off',
'jsx-a11y/anchor-is-valid': 'off',
'jsx-a11y/aria-activedescendant-has-tabindex': 'off',
Expand Down Expand Up @@ -256,17 +236,13 @@ const config = {
'no-restricted-syntax': 'off',

// permanently disable because we disagree with these rules
'import/prefer-default-export': 'off',
'no-await-in-loop': 'off', // contrary to rule docs, awaited things often are NOT parallelizable
'react/jsx-props-no-spreading': 'off',
'react/prop-types': 'off',

// permanently disable due to performance issues (using custom rule `@fluentui/max-len` instead)
'max-len': 'off',

// permanently disable due to being unnecessary or having limited benefit for TS
'import/export': 'off',

// permanently disable due to perf problems and limited benefit
// see here for perf testing (note that you must run eslint directly)
// https://eslint.org/docs/developer-guide/working-with-rules#per-rule-performance
Expand All @@ -277,6 +253,30 @@ const config = {
'react/no-unused-prop-types': 'off',
'react/prefer-es6-class': 'off',

'jsdoc/check-tag-names': [
'error',
{
// Allow TSDoc tags @remarks and @defaultValue
definedTags: ['remarks', 'defaultValue'],
},
],

/**
*
* import plugin rules
* @see https://github.com/import-js/eslint-plugin-import
*/
'import/no-extraneous-dependencies': ['error', { devDependencies: false }],
'import/extensions': 'off',
'import/first': 'off',
'import/newline-after-import': 'off',
'import/no-duplicates': 'off', // mostly redundant with no-duplicate-imports
'import/no-dynamic-require': 'off',
'import/no-mutable-exports': 'off',
'import/no-unresolved': 'off',
'import/no-useless-path-segments': 'off',
'import/order': 'off',
'import/prefer-default-export': 'off',
// may cause perf problems per https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#eslint-plugin-import
'import/no-cycle': 'off',
'import/no-deprecated': 'off',
Expand All @@ -287,14 +287,7 @@ const config = {
'import/named': 'off',
'import/namespace': 'off',
'import/no-named-as-default-member': 'off',

'jsdoc/check-tag-names': [
'error',
{
// Allow TSDoc tags @remarks and @defaultValue
definedTags: ['remarks', 'defaultValue'],
},
],
'import/export': 'off',
},
};

Expand Down

0 comments on commit da09e63

Please sign in to comment.