| 1 | import ljharbConfig from '@ljharb/eslint-config/flat';
|
|---|
| 2 | import importPlugin from 'eslint-plugin-import';
|
|---|
| 3 |
|
|---|
| 4 | export default [
|
|---|
| 5 | ...ljharbConfig,
|
|---|
| 6 | {
|
|---|
| 7 | plugins: {
|
|---|
| 8 | import: importPlugin,
|
|---|
| 9 | },
|
|---|
| 10 | settings: {
|
|---|
| 11 | 'import/resolver': {
|
|---|
| 12 | node: {
|
|---|
| 13 | extensions: ['.mjs', '.js', '.json'],
|
|---|
| 14 | },
|
|---|
| 15 | },
|
|---|
| 16 | 'import/extensions': [
|
|---|
| 17 | '.js',
|
|---|
| 18 | '.mjs',
|
|---|
| 19 | '.jsx',
|
|---|
| 20 | ],
|
|---|
| 21 | 'import/core-modules': [
|
|---|
| 22 | ],
|
|---|
| 23 | 'import/ignore': [
|
|---|
| 24 | 'node_modules',
|
|---|
| 25 | ],
|
|---|
| 26 | },
|
|---|
| 27 |
|
|---|
| 28 | rules: {
|
|---|
| 29 | 'import/no-unresolved': ['error', { commonjs: true, caseSensitive: true }],
|
|---|
| 30 |
|
|---|
| 31 | 'import/named': 'error',
|
|---|
| 32 | 'import/export': 'error',
|
|---|
| 33 | 'import/no-named-as-default': 'error',
|
|---|
| 34 | 'import/no-named-as-default-member': 'error',
|
|---|
| 35 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-deprecated.md
|
|---|
| 36 | 'import/no-deprecated': 'error',
|
|---|
| 37 |
|
|---|
| 38 | 'import/no-extraneous-dependencies': ['error', {
|
|---|
| 39 | devDependencies: [
|
|---|
| 40 | 'eslint.config.mjs',
|
|---|
| 41 | 'test/**',
|
|---|
| 42 | ],
|
|---|
| 43 | optionalDependencies: false,
|
|---|
| 44 | }],
|
|---|
| 45 | 'import/no-mutable-exports': 'error',
|
|---|
| 46 | 'import/no-commonjs': 'off',
|
|---|
| 47 | 'import/no-amd': 'error',
|
|---|
| 48 | 'import/first': 'error',
|
|---|
| 49 | 'import/no-duplicates': 'error',
|
|---|
| 50 | 'import/no-namespace': 'error',
|
|---|
| 51 |
|
|---|
| 52 | // Ensure consistent use of file extension within the import path
|
|---|
| 53 | // https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/extensions.md
|
|---|
| 54 | 'import/extensions': ['error', 'ignorePackages', {
|
|---|
| 55 | json: 'never',
|
|---|
| 56 | js: 'never',
|
|---|
| 57 | mjs: 'never',
|
|---|
| 58 | jsx: 'never',
|
|---|
| 59 | }],
|
|---|
| 60 | 'import/order': ['warn', { groups: [['builtin', 'external', 'internal']] }],
|
|---|
| 61 | 'import/newline-after-import': 'error',
|
|---|
| 62 | 'import/prefer-default-export': 'error',
|
|---|
| 63 | 'import/no-restricted-paths': 'off',
|
|---|
| 64 | 'import/max-dependencies': ['off', { max: 10 }],
|
|---|
| 65 | 'import/no-absolute-path': 'error',
|
|---|
| 66 | 'import/no-dynamic-require': 'error',
|
|---|
| 67 | 'import/no-internal-modules': ['off', {
|
|---|
| 68 | allow: [],
|
|---|
| 69 | }],
|
|---|
| 70 | 'import/no-webpack-loader-syntax': 'error',
|
|---|
| 71 | 'import/no-unassigned-import': 'off',
|
|---|
| 72 | 'import/no-named-default': 'error',
|
|---|
| 73 | 'import/no-anonymous-default-export': ['off', {
|
|---|
| 74 | allowArray: false,
|
|---|
| 75 | allowArrowFunction: false,
|
|---|
| 76 | allowAnonymousClass: false,
|
|---|
| 77 | allowAnonymousFunction: false,
|
|---|
| 78 | allowLiteral: false,
|
|---|
| 79 | allowObject: false,
|
|---|
| 80 | }],
|
|---|
| 81 | 'import/exports-last': 'error',
|
|---|
| 82 | 'import/group-exports': 'off',
|
|---|
| 83 | 'import/no-default-export': 'off',
|
|---|
| 84 | 'import/no-named-export': 'off',
|
|---|
| 85 | 'import/no-self-import': 'error',
|
|---|
| 86 | 'import/no-cycle': ['error', { commonjs: true, maxDepth: '∞' }],
|
|---|
| 87 | 'import/no-useless-path-segments': ['error', { commonjs: true }],
|
|---|
| 88 | 'import/no-relative-parent-imports': 'off',
|
|---|
| 89 | // TODO: enable once it works for flat config
|
|---|
| 90 | 'import/no-unused-modules': ['off', {
|
|---|
| 91 | commonjs: true,
|
|---|
| 92 | ignoreExports: [],
|
|---|
| 93 | missingExports: true,
|
|---|
| 94 | unusedExports: true,
|
|---|
| 95 | }],
|
|---|
| 96 | 'import/no-import-module-exports': ['error', {
|
|---|
| 97 | exceptions: [],
|
|---|
| 98 | }],
|
|---|
| 99 | 'import/no-relative-packages': 'error',
|
|---|
| 100 | },
|
|---|
| 101 | },
|
|---|
| 102 | {
|
|---|
| 103 | languageOptions: {
|
|---|
| 104 | globals: {
|
|---|
| 105 | Iterator: false,
|
|---|
| 106 | },
|
|---|
| 107 | },
|
|---|
| 108 | rules: {
|
|---|
| 109 | 'array-bracket-newline': 'off',
|
|---|
| 110 | 'func-name-matching': 'off',
|
|---|
| 111 | 'id-length': 'off',
|
|---|
| 112 | 'max-lines-per-function': 'off',
|
|---|
| 113 | 'max-statements': 'off',
|
|---|
| 114 | 'multiline-comment-style': 'off',
|
|---|
| 115 | 'new-cap': ['error', {
|
|---|
| 116 | capIsNewExceptions: [
|
|---|
| 117 | 'Call',
|
|---|
| 118 | 'CreateDataPropertyOrThrow',
|
|---|
| 119 | 'CreateIteratorFromClosure',
|
|---|
| 120 | 'CreateIteratorResultObject',
|
|---|
| 121 | 'GeneratorResume',
|
|---|
| 122 | 'GeneratorResumeAbrupt',
|
|---|
| 123 | 'GeneratorValidate',
|
|---|
| 124 | 'Get',
|
|---|
| 125 | 'GetIntrinsic',
|
|---|
| 126 | 'GetIterator',
|
|---|
| 127 | 'GetIteratorDirect',
|
|---|
| 128 | 'GetIteratorFlattenable',
|
|---|
| 129 | 'GetMethod',
|
|---|
| 130 | 'GetOptionsObject',
|
|---|
| 131 | 'IfAbruptCloseIterator',
|
|---|
| 132 | 'IfAbruptCloseIterators',
|
|---|
| 133 | 'IsAccessorDescriptor',
|
|---|
| 134 | 'IsArray',
|
|---|
| 135 | 'IsCallable',
|
|---|
| 136 | 'IsDataDescriptor',
|
|---|
| 137 | 'IteratorClose',
|
|---|
| 138 | 'IteratorCloseAll',
|
|---|
| 139 | 'IteratorStep',
|
|---|
| 140 | 'IteratorStepValue',
|
|---|
| 141 | 'IteratorZip',
|
|---|
| 142 | 'NormalCompletion',
|
|---|
| 143 | 'OrdinaryHasInstance',
|
|---|
| 144 | 'OrdinaryObjectCreate',
|
|---|
| 145 | 'ReturnCompletion',
|
|---|
| 146 | 'SameValueZero',
|
|---|
| 147 | 'StringToCodePoints',
|
|---|
| 148 | 'ThrowCompletion',
|
|---|
| 149 | 'ToBoolean',
|
|---|
| 150 | 'ToIntegerOrInfinity',
|
|---|
| 151 | 'ToNumber',
|
|---|
| 152 | 'ToPropertyDescriptor',
|
|---|
| 153 | 'ToString',
|
|---|
| 154 | ],
|
|---|
| 155 | }],
|
|---|
| 156 | 'no-negated-condition': 'warn',
|
|---|
| 157 | 'object-curly-newline': 'off',
|
|---|
| 158 | 'sort-keys': 'off',
|
|---|
| 159 | },
|
|---|
| 160 | },
|
|---|
| 161 | {
|
|---|
| 162 | files: ['test/**'],
|
|---|
| 163 | rules: {
|
|---|
| 164 | eqeqeq: ['error', 'allow-null'],
|
|---|
| 165 | 'func-style': 'off',
|
|---|
| 166 | },
|
|---|
| 167 | },
|
|---|
| 168 | {
|
|---|
| 169 | files: ['Iterator.zip*/implementation.js'],
|
|---|
| 170 | rules: {
|
|---|
| 171 | complexity: 'off',
|
|---|
| 172 | 'max-depth': 'off',
|
|---|
| 173 | },
|
|---|
| 174 | },
|
|---|
| 175 | {
|
|---|
| 176 | files: ['aos/IteratorZip.js'],
|
|---|
| 177 | rules: {
|
|---|
| 178 | 'max-depth': 'off',
|
|---|
| 179 | 'max-params': 'off',
|
|---|
| 180 | },
|
|---|
| 181 | },
|
|---|
| 182 | ];
|
|---|