diff --git a/packages/eslint-config/rules/base.js b/packages/eslint-config/rules/base.js index 815e90f..89e770e 100644 --- a/packages/eslint-config/rules/base.js +++ b/packages/eslint-config/rules/base.js @@ -277,8 +277,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/eslint-base/control-flow#no-duplicate-case "no-duplicate-case": "error", - // Shadowed by plugin-imports rule - // TODO + // Shadowed by import/no-duplicates "no-duplicate-imports": "off", // `else-if` is able to save one line, and also makes the flow more natural. diff --git a/packages/eslint-config/rules/import.js b/packages/eslint-config/rules/import.js index 9c5dbb9..7e944c8 100644 --- a/packages/eslint-config/rules/import.js +++ b/packages/eslint-config/rules/import.js @@ -1,34 +1,128 @@ -// This section is not completed. -// TODO turn on more rules - module.exports = { plugins: ["import"], rules: { + // We use @typescript-eslint/no-import-type-side-effects + "import/consistent-type-specifier-style": "off", + // This rule reports when using esModuleInterop "import/default": "off", - "import/first": "error", + // Enable if you use Webpack + "import/dynamic-import-chunkname": 0, + + "import/export": "error", + + "import/exports-last": "off", + + "import/extensions": "off", - "import/named": "error", + "import/first": ["error", "absolute-first"], - // Not as useful + // We want the opposite style + "import/group-exports": "off", + + "import/max-dependencies": "off", + + // Performance + "import/named": "off", + + // Performance "import/namespace": "off", - "import/newline-after-import": "error", + "import/newline-after-import": [ + "error", + { considerComments: true, count: 1, exactCount: true }, + ], + + // Don't do absolute, even when authoring modules directly sent to browsers! + "import/no-absolute-path": [ + "error", + { amd: true, commonjs: true, esmodule: true }, + ], + + // We don't use AMD + "import/no-amd": "error", + + // Anonymous functions/classes are already covered by func-names + "import/no-anonymous-default-export": "off", + + "import/no-commonjs": "off", + + // Performance, and cycles are generally not an issue until they are + "import/no-cycle": "off", + + // Please use default export for React components + "import/no-default-export": "off", + + "import/no-deprecated": "off", + + "import/no-duplicates": [ + "error", + { considerQueryString: true, "prefer-inline": true }, + ], + + "import/no-dynamic-require": "off", + + "import/no-empty-named-blocks": "error", - "import/no-absolute-path": "error", + "import/no-extraneous-dependencies": [ + "error", + { + bundledDependencies: false, + devDependencies: ["**/*.test.{js,ts,jsx,tsx}"], + optionalDependencies: false, + peerDependencies: true, + }, + ], + + // If you have to do this, it must be for some weird reason + "import/no-import-module-exports": "warn", + + "import/no-internal-modules": "off", + + // The only reason to use this is when the environment doesn't handle this + // compliantly + "import/no-mutable-exports": "off", + + // Performance + "import/no-named-as-default": "off", + + // Performance + "import/no-named-as-default-member": "off", + + "import/no-named-default": "error", + + "import/no-named-export": "off", + + "import/no-namespace": "off", - "import/no-duplicates": "error", + "import/no-nodejs-modules": "off", - // This rule doesn't play well with TypeScript + ESM. TS is able to catch - // missing import anyways. - "import/no-unresolved": ["off", { caseSensitive: true, commonjs: true }], + "import/no-relative-packages": "warn", + + "import/no-relative-parent-imports": "off", + + "import/no-restricted-paths": 0, + + "import/no-self-import": "error", + + "import/no-unassigned-import": "off", + + "import/no-unresolved": "off", + + "import/no-unused-modules": 0, // Going one directory above ensures transpilation doesn't mess with paths "import/no-useless-path-segments": "off", // When we use it, it's useful. "import/no-webpack-loader-syntax": "off", + + "import/order": 0, + + "import/prefer-default-export": "off", + + "import/unambiguous": "off", }, settings: { "import/resolver": { diff --git a/packages/eslint-config/rules/typescript.js b/packages/eslint-config/rules/typescript.js index cffff4b..51d4e1d 100644 --- a/packages/eslint-config/rules/typescript.js +++ b/packages/eslint-config/rules/typescript.js @@ -84,10 +84,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/typescript/base#consistent-type-assertions "@typescript-eslint/consistent-type-assertions": [ "error", - { - assertionStyle: "as", - objectLiteralTypeAssertions: "allow", - }, + { assertionStyle: "as", objectLiteralTypeAssertions: "allow" }, ], // We sometimes allow declaration merging @@ -156,9 +153,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/typescript/base#no-empty-interface "@typescript-eslint/no-empty-interface": [ "error", - { - allowSingleExtends: true, - }, + { allowSingleExtends: true }, ], // https://jc-verse.github.io/js-style-guide/typescript/base#no-explicit-any @@ -193,10 +188,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/typescript/base#no-invalid-void-type "@typescript-eslint/no-invalid-void-type": [ "warn", - { - allowAsThisParameter: false, - allowInGenericTypeArguments: true, - }, + { allowAsThisParameter: false, allowInGenericTypeArguments: true }, ], // We turn off the base rule too @@ -259,10 +251,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/typescript/base#no-this-alias "@typescript-eslint/no-this-alias": [ "warn", - { - allowDestructuring: true, - allowedNames: [], - }, + { allowDestructuring: true, allowedNames: [] }, ], // Deprecated @@ -325,10 +314,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/typescript/base#parameter-properties "@typescript-eslint/parameter-properties": [ "warn", - { - allow: [], - prefer: "class-property", - }, + { allow: [], prefer: "class-property" }, ], // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-as-const @@ -346,9 +332,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-literal-enum-member "@typescript-eslint/prefer-literal-enum-member": [ "warn", - { - allowBitwiseExpressions: true, - }, + { allowBitwiseExpressions: true }, ], // https://jc-verse.github.io/js-style-guide/typescript/base#prefer-namespace-keyword @@ -362,11 +346,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/typescript/base#triple-slash-reference "@typescript-eslint/triple-slash-reference": [ "error", - { - lib: "never", - path: "never", - types: "prefer-import", - }, + { lib: "never", path: "never", types: "prefer-import" }, ], // We use strict TS options instead. @@ -376,9 +356,7 @@ module.exports = { // https://jc-verse.github.io/js-style-guide/typescript/base#unified-signatures "@typescript-eslint/unified-signatures": [ "warn", - { - ignoreDifferentlyNamedParameters: false, - }, + { ignoreDifferentlyNamedParameters: false }, ], }, };