eslint-config-airbnb-extended 0.9.3 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
1
  /**
2
- * Direct export not allowed, it will increase the size of d.ts
2
+ * Direct export isn't allowed, it will increase the size of d.ts
3
3
  */
4
4
  export declare const rules: {
5
- readonly base: Record<"strict" | "imports" | "variables" | "bestPractices" | "errors" | "es6" | "style" | "stylistic" | "importsStrict" | "reactStrict", import("eslint").Linter.Config>;
5
+ readonly base: Record<"strict" | "imports" | "variables" | "bestPractices" | "errors" | "es6" | "style" | "stylistic" | "stylisticPlus" | "importsStrict", import("eslint").Linter.Config>;
6
6
  readonly node: Record<"globals" | "base" | "promises" | "noUnsupportedFeatures", import("eslint").Linter.Config>;
7
- readonly react: Record<"react" | "reactJsxA11y" | "reactHooks", import("eslint").Linter.Config>;
7
+ readonly react: Record<"strict" | "stylistic" | "base" | "jsxA11y" | "hooks", import("eslint").Linter.Config>;
8
8
  readonly next: Record<"base" | "coreWebVitals", import("eslint").Linter.Config>;
9
- readonly typescript: Record<"imports" | "base" | "typescriptEslint", import("eslint").Linter.Config>;
9
+ readonly typescript: Record<"imports" | "stylistic" | "stylisticPlus" | "base" | "typescriptEslint", import("eslint").Linter.Config>;
10
10
  };
11
11
  export declare const configs: {
12
- readonly base: Record<"all" | "recommended" | "typescript", import("eslint").Linter.Config[]>;
13
- readonly react: Record<"all" | "recommended" | "typescript", import("eslint").Linter.Config[]>;
14
- readonly next: Record<"all" | "recommended" | "typescript", import("eslint").Linter.Config[]>;
12
+ readonly base: Record<"all" | "typescript" | "recommended", import("eslint").Linter.Config[]>;
13
+ readonly react: Record<"all" | "typescript" | "recommended", import("eslint").Linter.Config[]>;
14
+ readonly next: Record<"all" | "typescript" | "recommended", import("eslint").Linter.Config[]>;
15
15
  readonly node: Record<"recommended", import("eslint").Linter.Config[]>;
16
16
  };
17
17
  export declare const plugins: {
@@ -22,4 +22,5 @@ export declare const plugins: {
22
22
  readonly reactHooks: import("eslint").Linter.Config;
23
23
  readonly next: import("eslint").Linter.Config;
24
24
  readonly typescriptEslint: import("eslint").Linter.Config;
25
+ readonly stylistic: import("eslint").Linter.Config;
25
26
  };
@@ -10,6 +10,7 @@ const imports_1 = __importDefault(require("../../rules/imports"));
10
10
  const strict_1 = __importDefault(require("../../rules/strict"));
11
11
  const style_1 = __importDefault(require("../../rules/style"));
12
12
  const stylistic_1 = __importDefault(require("../../rules/stylistic"));
13
+ const stylisticPlus_1 = __importDefault(require("../../rules/stylisticPlus"));
13
14
  const variables_1 = __importDefault(require("../../rules/variables"));
14
15
  const baseConfig = {
15
16
  bestPractices: best_practices_1.default,
@@ -19,6 +20,7 @@ const baseConfig = {
19
20
  strict: strict_1.default,
20
21
  style: style_1.default,
21
22
  stylistic: stylistic_1.default,
23
+ stylisticPlus: stylisticPlus_1.default,
22
24
  variables: variables_1.default,
23
25
  };
24
26
  exports.default = baseConfig;
@@ -5,6 +5,5 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const config_1 = __importDefault(require("../../configs/base/config"));
7
7
  const importsStrict_1 = __importDefault(require("../../rules/importsStrict"));
8
- const reactStrict_1 = __importDefault(require("../../rules/reactStrict"));
9
- const baseConfigExtended = Object.assign(Object.assign({}, config_1.default), { importsStrict: importsStrict_1.default, reactStrict: reactStrict_1.default });
8
+ const baseConfigExtended = Object.assign(Object.assign({}, config_1.default), { importsStrict: importsStrict_1.default });
10
9
  exports.default = baseConfigExtended;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const config_1 = __importDefault(require("../../configs/base/config"));
7
+ const getStylisticLegacyConfig_1 = __importDefault(require("../../helpers/getStylisticLegacyConfig"));
7
8
  const baseRecommendedConfig = [
8
9
  ...Object.values(config_1.default),
9
10
  {
@@ -15,5 +16,6 @@ const baseRecommendedConfig = [
15
16
  },
16
17
  },
17
18
  },
19
+ Object.assign({ name: 'airbnb/config/base-disable-legacy-stylistic-js-config' }, (0, getStylisticLegacyConfig_1.default)('javascript')),
18
20
  ];
19
21
  exports.default = baseRecommendedConfig;
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const eslint_import_resolver_typescript_1 = require("eslint-import-resolver-typescript");
7
7
  const config_1 = __importDefault(require("../../configs/typescript/config"));
8
+ const getStylisticLegacyConfig_1 = __importDefault(require("../../helpers/getStylisticLegacyConfig"));
8
9
  const baseTypescriptConfig = [
9
10
  ...Object.values(config_1.default),
10
11
  {
@@ -18,5 +19,6 @@ const baseTypescriptConfig = [
18
19
  ],
19
20
  },
20
21
  },
22
+ Object.assign({ name: 'airbnb/config/base-typescript-disable-legacy-stylistic-ts-config' }, (0, getStylisticLegacyConfig_1.default)('typescript')),
21
23
  ];
22
24
  exports.default = baseTypescriptConfig;
@@ -3,12 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("../../rules/react"));
7
- const react_hooks_1 = __importDefault(require("../../rules/react-hooks"));
8
- const react_jsx_a11y_1 = __importDefault(require("../../rules/react-jsx-a11y"));
6
+ const react_1 = __importDefault(require("../../rules/react/react"));
7
+ const reactHooks_1 = __importDefault(require("../../rules/react/reactHooks"));
8
+ const reactJsxA11y_1 = __importDefault(require("../../rules/react/reactJsxA11y"));
9
+ const reactStylistic_1 = __importDefault(require("../../rules/react/reactStylistic"));
9
10
  const reactConfig = {
10
- react: react_1.default,
11
- reactJsxA11y: react_jsx_a11y_1.default,
12
- reactHooks: react_hooks_1.default,
11
+ base: react_1.default,
12
+ jsxA11y: reactJsxA11y_1.default,
13
+ hooks: reactHooks_1.default,
14
+ stylistic: reactStylistic_1.default,
13
15
  };
14
16
  exports.default = reactConfig;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const config_1 = __importDefault(require("../../configs/react/config"));
7
+ const reactStrict_1 = __importDefault(require("../../rules/react/reactStrict"));
8
+ const reactConfigExtended = Object.assign(Object.assign({}, config_1.default), { strict: reactStrict_1.default });
9
+ exports.default = reactConfigExtended;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const config_1 = __importDefault(require("../../configs/react/config"));
7
+ const getStylisticLegacyConfig_1 = __importDefault(require("../../helpers/getStylisticLegacyConfig"));
7
8
  const style_1 = __importDefault(require("../../rules/style"));
8
9
  const utils_1 = require("../../utils");
9
10
  const dangleRules = style_1.default.rules['no-underscore-dangle'];
@@ -22,16 +23,16 @@ const reactRecommendedConfig = [
22
23
  {
23
24
  name: 'airbnb/config/react-configurations',
24
25
  rules: {
26
+ // disallow dangling underscores in identifiers
27
+ // https://eslint.org/docs/latest/rules/no-underscore-dangle
25
28
  // Allow Redux devtools variable
26
29
  'no-underscore-dangle': [
27
30
  dangleRules[0],
28
31
  Object.assign(Object.assign({}, dangleRules[1]), { allow: [...dangleRules[1].allow, '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__'] }),
29
32
  ],
30
- // Specify whether double or single quotes should be used in JSX attributes
31
- // https://eslint.org/docs/rules/jsx-quotes
32
- // @deprecated
33
- 'jsx-quotes': ['error', 'prefer-double'],
34
- // Class Methods can be used in react
33
+ // enforce that class methods use "this"
34
+ // https://eslint.org/docs/rules/class-methods-use-this
35
+ // Class Methods can be used in React
35
36
  'class-methods-use-this': [
36
37
  'error',
37
38
  {
@@ -57,5 +58,14 @@ const reactRecommendedConfig = [
57
58
  ],
58
59
  },
59
60
  },
61
+ {
62
+ name: 'airbnb/config/react-stylistic',
63
+ rules: {
64
+ // specify whether double or single quotes should be used in JSX attributes
65
+ // https://eslint.style/rules/js/jsx-quotes
66
+ '@stylistic/jsx-quotes': ['error', 'prefer-double'],
67
+ },
68
+ },
69
+ Object.assign({ name: 'airbnb/config/react-disable-legacy-stylistic-react-config' }, (0, getStylisticLegacyConfig_1.default)('react')),
60
70
  ];
61
71
  exports.default = reactRecommendedConfig;
@@ -6,8 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const typescriptBase_1 = __importDefault(require("../../rules/typescript/typescriptBase"));
7
7
  const typescriptEslint_1 = __importDefault(require("../../rules/typescript/typescriptEslint"));
8
8
  const typescriptImports_1 = __importDefault(require("../../rules/typescript/typescriptImports"));
9
+ const typescriptStylistic_1 = __importDefault(require("../../rules/typescript/typescriptStylistic"));
10
+ const typescriptStylisticPlus_1 = __importDefault(require("../../rules/typescript/typescriptStylisticPlus"));
9
11
  const typescriptConfig = {
10
12
  base: typescriptBase_1.default,
13
+ stylistic: typescriptStylistic_1.default,
14
+ stylisticPlus: typescriptStylisticPlus_1.default,
11
15
  typescriptEslint: typescriptEslint_1.default,
12
16
  imports: typescriptImports_1.default,
13
17
  };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const eslint_plugin_1 = __importDefault(require("@stylistic/eslint-plugin"));
7
+ const getStylisticLegacyConfig = (language) => {
8
+ var _a;
9
+ const legacyConfig = eslint_plugin_1.default.configs['disable-legacy'];
10
+ const REACT = 'react/';
11
+ const TYPESCRIPT = '@typescript-eslint/';
12
+ const rules = Object.entries((_a = legacyConfig.rules) !== null && _a !== void 0 ? _a : {}).reduce((acc, [key, value]) => {
13
+ if (language === 'javascript' && !key.startsWith(REACT) && !key.startsWith(TYPESCRIPT)) {
14
+ return Object.assign(Object.assign({}, acc), { [key]: value });
15
+ }
16
+ if (language === 'typescript' && key.startsWith(TYPESCRIPT)) {
17
+ return Object.assign(Object.assign({}, acc), { [key]: value });
18
+ }
19
+ if (language === 'react' && key.startsWith(REACT)) {
20
+ return Object.assign(Object.assign({}, acc), { [key]: value });
21
+ }
22
+ return null;
23
+ }, {});
24
+ return rules ? Object.assign(Object.assign({}, legacyConfig), { rules }) : legacyConfig;
25
+ };
26
+ exports.default = getStylisticLegacyConfig;
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ const configs_1 = __importDefault(require("./configs"));
9
9
  const plugins_1 = __importDefault(require("./plugins"));
10
10
  const rules_1 = __importDefault(require("./rules"));
11
11
  /**
12
- * Direct export not allowed, it will increase the size of d.ts
12
+ * Direct export isn't allowed, it will increase the size of d.ts
13
13
  */
14
14
  exports.rules = rules_1.default;
15
15
  exports.configs = configs_1.default;
@@ -26,5 +26,8 @@ const plugins = {
26
26
  get typescriptEslint() {
27
27
  return require('../plugins/typescriptEslintPlugin').default;
28
28
  },
29
+ get stylistic() {
30
+ return require('../plugins/stylisticPlugin').default;
31
+ },
29
32
  };
30
33
  exports.default = plugins;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const eslint_plugin_1 = __importDefault(require("@stylistic/eslint-plugin"));
7
+ const stylisticPlugin = {
8
+ name: 'airbnb/config/plugin/stylistic',
9
+ plugins: {
10
+ '@stylistic': eslint_plugin_1.default,
11
+ },
12
+ };
13
+ exports.default = stylisticPlugin;
@@ -12,7 +12,7 @@ const rules = {
12
12
  return require('../configs/node/config').default;
13
13
  },
14
14
  get react() {
15
- return require('../configs/react/config').default;
15
+ return require('../configs/react/configExtended').default;
16
16
  },
17
17
  get next() {
18
18
  return require('../configs/next/config').default;
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.deprecatedReactRules = void 0;
6
+ exports.deprecatedReactBaseRules = void 0;
7
7
  const globals_1 = __importDefault(require("globals"));
8
- const reactRules = {
8
+ const reactBaseRules = {
9
9
  name: 'airbnb/config/react',
10
10
  languageOptions: {
11
11
  parserOptions: {
@@ -568,7 +568,7 @@ const reactRules = {
568
568
  'react/void-dom-elements-no-children': 'error',
569
569
  },
570
570
  };
571
- exports.deprecatedReactRules = {
571
+ exports.deprecatedReactBaseRules = {
572
572
  name: 'airbnb/config/react/deprecated',
573
573
  rules: {
574
574
  // Enforce defaultProps declarations alphabetical sorting
@@ -579,4 +579,4 @@ exports.deprecatedReactRules = {
579
579
  'react/jsx-space-before-closing': 'off',
580
580
  },
581
581
  };
582
- exports.default = reactRules;
582
+ exports.default = reactBaseRules;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deprecatedReactStylisticPlusRules = void 0;
4
+ const reactStylisticRules = {
5
+ name: 'airbnb/config/react/stylistic',
6
+ rules: {
7
+ // Enforce or disallow spaces inside of curly braces in JSX attributes and expressions
8
+ // https://eslint.style/rules/jsx/jsx-child-element-spacing
9
+ // Off due to 'react/jsx-child-element-spacing'
10
+ '@stylistic/jsx-child-element-spacing': 'off',
11
+ // Enforce the closing bracket location for JSX multiline elements.
12
+ // https://eslint.style/rules/jsx/jsx-closing-bracket-location
13
+ // Off due to 'react/jsx-closing-bracket-location'
14
+ '@stylistic/jsx-closing-bracket-location': 'off',
15
+ // Enforce the closing tag location for multiline JSX elements.
16
+ // https://eslint.style/rules/jsx/jsx-closing-tag-location
17
+ // Off due to 'react/jsx-closing-tag-location'
18
+ '@stylistic/jsx-closing-tag-location': 'off',
19
+ // Disallow unnecessary JSX expressions when literals alone are sufficient or enforce JSX expressions on literals in JSX children or attributes.
20
+ // https://eslint.style/rules/jsx/jsx-curly-brace-presence
21
+ // Off due to 'react/jsx-curly-brace-presence'
22
+ '@stylistic/jsx-curly-brace-presence': 'off',
23
+ // Enforce consistent linebreaks in curly braces in JSX attributes and expressions.
24
+ // https://eslint.style/rules/jsx/jsx-curly-newline
25
+ // Off due to 'react/jsx-curly-newline'
26
+ '@stylistic/jsx-curly-newline': 'off',
27
+ // Enforce or disallow spaces inside of curly braces in JSX attributes and expressions.
28
+ // https://eslint.style/rules/jsx/jsx-curly-spacing
29
+ // Off due to 'react/jsx-curly-spacing'
30
+ '@stylistic/jsx-curly-spacing': 'off',
31
+ // Enforce or disallow spaces around equal signs in JSX attributes.
32
+ // https://eslint.style/rules/jsx/jsx-equals-spacing
33
+ // Off due to 'react/jsx-equals-spacing'
34
+ '@stylistic/jsx-equals-spacing': 'off',
35
+ // Enforce the proper position of the first property in JSX.
36
+ // https://eslint.style/rules/jsx/jsx-first-prop-new-line
37
+ // Off due to 'react/jsx-first-prop-new-line'
38
+ '@stylistic/jsx-first-prop-new-line': 'off',
39
+ // Enforce line breaks before and after JSX elements when they are used as arguments to a function.
40
+ // https://eslint.style/rules/jsx/jsx-function-call-newline
41
+ '@stylistic/jsx-function-call-newline': 'off',
42
+ // Enforce props indentation in JSX.
43
+ // https://eslint.style/rules/jsx/jsx-indent-props
44
+ // Off due to 'react/jsx-indent-props'
45
+ '@stylistic/jsx-indent-props': 'off',
46
+ // Enforce a maximum of props on a single line in JSX.
47
+ // https://eslint.style/rules/jsx/jsx-max-props-per-line
48
+ // Off due to 'react/jsx-max-props-per-line'
49
+ '@stylistic/jsx-max-props-per-line': 'off',
50
+ // Require or prevent a new line after jsx elements and expressions
51
+ // https://eslint.style/rules/jsx/jsx-newline
52
+ // Off due to 'react/jsx-newline'
53
+ '@stylistic/jsx-newline': 'off',
54
+ // Require one JSX element per line.
55
+ // https://eslint.style/rules/jsx/jsx-one-expression-per-line
56
+ // Off due to 'react/jsx-one-expression-per-line'
57
+ '@stylistic/jsx-one-expression-per-line': 'off',
58
+ // Enforces coding style that user-defined JSX components are defined and referenced in PascalCase.
59
+ // https://eslint.style/rules/jsx/jsx-pascal-case
60
+ // Off due to 'react/jsx-pascal-case'
61
+ '@stylistic/jsx-pascal-case': 'off',
62
+ // Disallow multiple spaces between inline JSX props.
63
+ // https://eslint.style/rules/jsx/jsx-props-no-multi-spaces
64
+ // Off due to 'react/jsx-props-no-multi-spaces'
65
+ '@stylistic/jsx-props-no-multi-spaces': 'off',
66
+ // Disallow extra closing tags for components without children.
67
+ // https://eslint.style/rules/jsx/jsx-self-closing-comp
68
+ // Off due to 'react/self-closing-comp'
69
+ '@stylistic/jsx-self-closing-comp': 'off',
70
+ // Enforce props alphabetical sorting.
71
+ // https://eslint.style/rules/jsx/jsx-sort-props
72
+ // Off due to 'react/jsx-sort-props'
73
+ '@stylistic/jsx-sort-props': 'off',
74
+ // Enforce whitespace in and around the JSX opening and closing brackets.
75
+ // https://eslint.style/rules/jsx/jsx-tag-spacing
76
+ // Off due to 'react/jsx-tag-spacing'
77
+ '@stylistic/jsx-tag-spacing': 'off',
78
+ // Disallow missing parentheses around multiline JSX.
79
+ // https://eslint.style/rules/jsx/jsx-wrap-multilines
80
+ // Off due to 'react/jsx-wrap-multilines'
81
+ '@stylistic/jsx-wrap-multilines': 'off',
82
+ },
83
+ };
84
+ exports.deprecatedReactStylisticPlusRules = {
85
+ name: 'airbnb/config/react/stylistic/deprecated',
86
+ rules: {
87
+ // Enforce JSX indentation.
88
+ // https://eslint.style/rules/jsx/jsx-indent
89
+ // Off due to 'react/jsx-indent'
90
+ '@stylistic/jsx-indent': 'off',
91
+ },
92
+ };
93
+ exports.default = reactStylisticRules;
@@ -121,7 +121,7 @@ const styleRules = {
121
121
  'no-lonely-if': 'error',
122
122
  // disallow use of chained assignment expressions
123
123
  // https://eslint.org/docs/latest/rules/no-multi-assign
124
- 'no-multi-assign': ['error'],
124
+ 'no-multi-assign': 'error',
125
125
  // disallow negated conditions
126
126
  // https://eslint.org/docs/latest/rules/no-negated-condition
127
127
  'no-negated-condition': 'off',