|
1 | 1 | module.exports = {
|
2 |
| - extends: ['./node_modules/@sclable/eslint-config/index.js'], |
3 | 2 | root: true,
|
| 3 | + env: { |
| 4 | + browser: true, |
| 5 | + node: true, |
| 6 | + mocha: true, |
| 7 | + }, |
| 8 | + extends: [ |
| 9 | + 'eslint:recommended', |
| 10 | + 'plugin:@typescript-eslint/recommended', |
| 11 | + 'plugin:prettier/recommended', |
| 12 | + 'prettier', |
| 13 | + ], |
| 14 | + plugins: ['no-only-tests', 'eslint-plugin-import', '@typescript-eslint', 'prettier'], |
4 | 15 | ignorePatterns: ['!.eslintrc.js', 'node_modules', 'dist'],
|
5 | 16 | rules: {
|
6 |
| - // override or extend rules coming from `@sclable/lint` as needed |
| 17 | + /* |
| 18 | + * Disable native ESLint rules that don't work well with TypeScript |
| 19 | + * ======================================================================================= |
| 20 | + */ |
| 21 | + |
| 22 | + // no-undef does not know about types that are available in TypeScript |
| 23 | + 'no-undef': 'off', |
| 24 | + |
| 25 | + // no-dupe-class-members cannot handle function overloading |
| 26 | + 'no-dupe-class-members': 'off', |
| 27 | + |
| 28 | + /* |
| 29 | + * Rules native to ESLint follow |
| 30 | + * ======================================================================================= |
| 31 | + */ |
| 32 | + 'no-console': 'warn', |
| 33 | + 'no-debugger': 'warn', |
| 34 | + 'arrow-parens': ['warn', 'as-needed', { requireForBlockBody: false }], |
| 35 | + 'space-before-function-paren': [ |
| 36 | + 'warn', |
| 37 | + { |
| 38 | + anonymous: 'always', |
| 39 | + named: 'never', |
| 40 | + asyncArrow: 'always', |
| 41 | + }, |
| 42 | + ], |
| 43 | + 'consistent-return': 'error', |
| 44 | + 'no-confusing-arrow': 'error', |
| 45 | + 'no-unused-expressions': 'off', |
| 46 | + 'no-var': 'error', |
| 47 | + 'prefer-const': 'error', |
| 48 | + 'spaced-comment': 'warn', |
| 49 | + 'no-extra-boolean-cast': 'error', |
| 50 | + 'padding-line-between-statements': [ |
| 51 | + 'warn', |
| 52 | + { blankLine: 'always', prev: '*', next: 'return' }, |
| 53 | + ], |
| 54 | + 'sort-imports': ['warn', { ignoreDeclarationSort: true }], |
| 55 | + 'id-length': [ |
| 56 | + 'warn', |
| 57 | + { |
| 58 | + min: 2, |
| 59 | + max: 50, |
| 60 | + exceptions: ['i', 'j', 'x', 'y', 'z', '_'], |
| 61 | + }, |
| 62 | + ], |
| 63 | + |
| 64 | + /* |
| 65 | + * Rules implemented by `no-only-tests` follow |
| 66 | + * ======================================================================================= |
| 67 | + */ |
| 68 | + 'no-only-tests/no-only-tests': 'warn', |
| 69 | + |
| 70 | + /* |
| 71 | + * Rules implemented by `eslint-plugin-import` follow |
| 72 | + * ======================================================================================= |
| 73 | + */ |
| 74 | + 'import/order': [ |
| 75 | + 'warn', |
| 76 | + { |
| 77 | + 'groups': [ |
| 78 | + 'builtin', |
| 79 | + 'external', |
| 80 | + 'internal', |
| 81 | + ['parent', 'sibling', 'index'], |
| 82 | + 'unknown', |
| 83 | + ], |
| 84 | + 'pathGroups': [ |
| 85 | + { |
| 86 | + pattern: '@/**', |
| 87 | + group: 'internal', |
| 88 | + }, |
| 89 | + ], |
| 90 | + 'newlines-between': 'always', |
| 91 | + 'alphabetize': { |
| 92 | + order: 'asc', |
| 93 | + caseInsensitive: false, |
| 94 | + }, |
| 95 | + }, |
| 96 | + ], |
| 97 | + 'import/default': 'error', |
| 98 | + 'import/export': 'error', |
| 99 | + 'import/no-commonjs': 'error', |
| 100 | + 'import/no-amd': 'error', |
| 101 | + 'import/no-named-as-default': 'error', |
| 102 | + 'import/no-named-as-default-member': 'error', |
| 103 | + 'import/no-mutable-exports': 'error', |
| 104 | + 'import/no-duplicates': 'error', |
| 105 | + 'import/no-default-export': 'error', |
| 106 | + 'import/no-useless-path-segments': 'warn', |
| 107 | + 'import/dynamic-import-chunkname': 'warn', |
| 108 | + |
| 109 | + /* |
| 110 | + * Rules implemented by `eslint-plugin-prettier` follow |
| 111 | + * ======================================================================================= |
| 112 | + */ |
| 113 | + 'prettier/prettier': [ |
| 114 | + 'warn', |
| 115 | + { |
| 116 | + $schema: 'http://json.schemastore.org/prettierrc', |
| 117 | + arrowParens: 'avoid', |
| 118 | + printWidth: 95, |
| 119 | + semi: false, |
| 120 | + singleQuote: true, |
| 121 | + trailingComma: 'all', |
| 122 | + quoteProps: 'consistent', |
| 123 | + }, |
| 124 | + ], |
| 125 | + |
| 126 | + /* |
| 127 | + * Rules implemented by `@typescript-eslint` follow |
| 128 | + * ======================================================================================= |
| 129 | + */ |
| 130 | + '@typescript-eslint/array-type': ['error', { default: 'array' }], |
| 131 | + '@typescript-eslint/ban-ts-comment': 'off', |
| 132 | + '@typescript-eslint/consistent-type-definitions': ['warn', 'interface'], |
| 133 | + '@typescript-eslint/explicit-function-return-type': [ |
| 134 | + 'warn', |
| 135 | + { |
| 136 | + allowExpressions: true, |
| 137 | + allowTypedFunctionExpressions: true, |
| 138 | + allowHigherOrderFunctions: true, |
| 139 | + }, |
| 140 | + ], |
| 141 | + '@typescript-eslint/explicit-member-accessibility': 'warn', |
| 142 | + '@typescript-eslint/prefer-function-type': 'warn', |
| 143 | + '@typescript-eslint/indent': 'off', |
| 144 | + '@typescript-eslint/prefer-for-of': 'error', |
| 145 | + '@typescript-eslint/member-delimiter-style': [ |
| 146 | + 'warn', |
| 147 | + { |
| 148 | + multiline: { delimiter: 'none', requireLast: true }, |
| 149 | + singleline: { delimiter: 'semi', requireLast: false }, |
| 150 | + }, |
| 151 | + ], |
| 152 | + '@typescript-eslint/member-ordering': 'warn', |
| 153 | + '@typescript-eslint/no-explicit-any': 'warn', |
| 154 | + '@typescript-eslint/no-inferrable-types': 'off', |
| 155 | + '@typescript-eslint/no-parameter-properties': 'off', |
| 156 | + '@typescript-eslint/no-this-alias': 'off', |
| 157 | + '@typescript-eslint/no-unused-expressions': [ |
| 158 | + 'error', |
| 159 | + { allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true }, |
| 160 | + ], |
| 161 | + '@typescript-eslint/no-unused-vars': [ |
| 162 | + 'warn', |
| 163 | + { argsIgnorePattern: '^_', varsIgnorePattern: '_' }, |
| 164 | + ], |
| 165 | + '@typescript-eslint/no-use-before-define': ['error', { functions: false }], |
| 166 | + '@typescript-eslint/consistent-type-assertions': ['warn'], |
| 167 | + '@typescript-eslint/no-for-in-array': 'error', |
| 168 | + '@typescript-eslint/unified-signatures': 'error', |
| 169 | + '@typescript-eslint/no-extraneous-class': 'error', |
| 170 | + }, |
| 171 | + overrides: [ |
| 172 | + { |
| 173 | + files: ['*.d.ts'], |
| 174 | + rules: { |
| 175 | + /* |
| 176 | + * Disable rules that don't work well with d.ts files |
| 177 | + * =================================================================================== |
| 178 | + */ |
| 179 | + 'import/no-default-export': 'off', |
| 180 | + '@typescript-eslint/no-explicit-any': 'off', |
| 181 | + '@typescript-eslint/no-unused-vars': 'off', |
| 182 | + }, |
| 183 | + }, |
| 184 | + { |
| 185 | + files: ['.*.js', '*.config.js'], |
| 186 | + rules: { |
| 187 | + /* |
| 188 | + * Disable rules that don't work well with common js config files |
| 189 | + * =================================================================================== |
| 190 | + */ |
| 191 | + 'import/no-commonjs': 'off', |
| 192 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 193 | + '@typescript-eslint/no-var-requires': 'off', |
| 194 | + }, |
| 195 | + }, |
| 196 | + { |
| 197 | + files: ['*.js'], |
| 198 | + rules: { |
| 199 | + /* |
| 200 | + * Disable rules that don't work with standard js files |
| 201 | + * =================================================================================== |
| 202 | + */ |
| 203 | + 'import/no-commonjs': 'off', |
| 204 | + '@typescript-eslint/explicit-function-return-type': 'off', |
| 205 | + '@typescript-eslint/no-var-requires': 'off', |
| 206 | + }, |
| 207 | + }, |
| 208 | + ], |
| 209 | + parserOptions: { |
| 210 | + parser: '@typescript-eslint/parser', |
| 211 | + sourceType: 'module', |
| 212 | + ecmaVersion: 2020, |
| 213 | + ecmaFeatures: { |
| 214 | + jsx: true, |
| 215 | + }, |
7 | 216 | },
|
8 | 217 | }
|
0 commit comments