|
| 1 | +import js from '@eslint/js'; |
| 2 | +import importPlugin from 'eslint-plugin-import'; |
| 3 | +import mochaPlugin from 'eslint-plugin-mocha'; |
| 4 | +import unicornPlugin from 'eslint-plugin-unicorn'; |
| 5 | +import globals from 'globals'; |
| 6 | + |
| 7 | +export default [ |
| 8 | + js.configs.recommended, |
| 9 | + importPlugin.flatConfigs.recommended, |
| 10 | + mochaPlugin.configs.flat.recommended, |
| 11 | + { |
| 12 | + files: ['**/*.{js,mjs,cjs}'], |
| 13 | + plugins: { |
| 14 | + unicorn: unicornPlugin, |
| 15 | + }, |
| 16 | + languageOptions: { |
| 17 | + globals: globals.node, |
| 18 | + ecmaVersion: 'latest', |
| 19 | + sourceType: 'module', |
| 20 | + }, |
| 21 | + rules: { |
| 22 | + 'array-bracket-spacing': [2, 'never'], |
| 23 | + 'array-callback-return': 2, |
| 24 | + 'array-element-newline': [2, 'consistent'], |
| 25 | + 'arrow-parens': [2, 'as-needed'], |
| 26 | + 'arrow-spacing': 2, |
| 27 | + 'brace-style': [2, 'stroustrup'], |
| 28 | + |
| 29 | + camelcase: [2, { |
| 30 | + ignoreDestructuring: true, |
| 31 | + properties: 'never', |
| 32 | + }], |
| 33 | + |
| 34 | + 'capitalized-comments': [2, 'always', { |
| 35 | + ignoreConsecutiveComments: true, |
| 36 | + ignorePattern: 'fallthrough|console', |
| 37 | + }], |
| 38 | + |
| 39 | + 'comma-dangle': [2, 'always-multiline'], |
| 40 | + |
| 41 | + 'comma-spacing': [2, { |
| 42 | + after: true, |
| 43 | + before: false, |
| 44 | + }], |
| 45 | + |
| 46 | + curly: 2, |
| 47 | + 'dot-location': [2, 'property'], |
| 48 | + 'dot-notation': 2, |
| 49 | + 'eol-last': [2, 'always'], |
| 50 | + eqeqeq: 2, |
| 51 | + 'import/first': 2, |
| 52 | + 'import/newline-after-import': 2, |
| 53 | + |
| 54 | + 'import/order': [2, { |
| 55 | + alphabetize: { |
| 56 | + order: 'asc', |
| 57 | + caseInsensitive: false, |
| 58 | + }, |
| 59 | + |
| 60 | + groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'], |
| 61 | + 'newlines-between': 'never', |
| 62 | + }], |
| 63 | + |
| 64 | + indent: [2, 4, { |
| 65 | + SwitchCase: 1, |
| 66 | + |
| 67 | + ignoredNodes: [ |
| 68 | + 'AwaitExpression > CallExpression', |
| 69 | + 'CallExpression :matches(ObjectExpression, CallExpression, BlockStatement)', |
| 70 | + ':matches(AssignmentExpression, VariableDeclarator) CallExpression ArrayExpression', |
| 71 | + 'SpreadElement MemberExpression', |
| 72 | + 'PropertyDefinition[decorators]', |
| 73 | + ], |
| 74 | + }], |
| 75 | + |
| 76 | + 'key-spacing': [2, { |
| 77 | + afterColon: true, |
| 78 | + beforeColon: false, |
| 79 | + }], |
| 80 | + |
| 81 | + 'keyword-spacing': 2, |
| 82 | + 'linebreak-style': [2, 'unix'], |
| 83 | + |
| 84 | + 'logical-assignment-operators': [2, 'always', { |
| 85 | + enforceForIfStatements: true, |
| 86 | + }], |
| 87 | + |
| 88 | + 'max-statements-per-line': 2, |
| 89 | + 'multiline-comment-style': [2, 'starred-block'], |
| 90 | + 'newline-per-chained-call': 2, |
| 91 | + 'no-console': 2, |
| 92 | + 'no-constant-binary-expression': 2, |
| 93 | + 'no-constructor-return': 2, |
| 94 | + 'no-dupe-else-if': 2, |
| 95 | + 'no-dupe-keys': 2, |
| 96 | + 'no-duplicate-imports': 2, |
| 97 | + 'no-else-return': 2, |
| 98 | + |
| 99 | + 'no-empty': [2, { |
| 100 | + allowEmptyCatch: true, |
| 101 | + }], |
| 102 | + |
| 103 | + 'no-implicit-coercion': 2, |
| 104 | + 'no-lonely-if': 2, |
| 105 | + 'no-loss-of-precision': 2, |
| 106 | + 'no-misleading-character-class': 2, |
| 107 | + 'no-mixed-operators': 2, |
| 108 | + 'no-multi-spaces': 2, |
| 109 | + |
| 110 | + 'no-multiple-empty-lines': [2, { |
| 111 | + max: 1, |
| 112 | + maxBOF: 1, |
| 113 | + maxEOF: 1, |
| 114 | + }], |
| 115 | + |
| 116 | + 'no-new-object': 2, |
| 117 | + 'no-new-wrappers': 2, |
| 118 | + 'no-return-await': 2, |
| 119 | + 'no-setter-return': 2, |
| 120 | + 'no-tabs': 2, |
| 121 | + 'no-template-curly-in-string': 2, |
| 122 | + 'no-throw-literal': 2, |
| 123 | + 'no-trailing-spaces': 2, |
| 124 | + 'no-unneeded-ternary': 2, |
| 125 | + 'no-unreachable-loop': 2, |
| 126 | + |
| 127 | + 'no-unused-expressions': [2, { |
| 128 | + allowShortCircuit: true, |
| 129 | + }], |
| 130 | + |
| 131 | + 'no-unused-private-class-members': 2, |
| 132 | + |
| 133 | + 'no-unused-vars': [2, { |
| 134 | + args: 'all', |
| 135 | + argsIgnorePattern: '^(req|res|next)$|^_', |
| 136 | + caughtErrors: 'all', |
| 137 | + varsIgnorePattern: '^_$', |
| 138 | + }], |
| 139 | + |
| 140 | + 'no-useless-call': 2, |
| 141 | + 'no-useless-concat': 2, |
| 142 | + 'no-useless-rename': 2, |
| 143 | + 'no-useless-return': 2, |
| 144 | + 'no-var': 2, |
| 145 | + |
| 146 | + 'object-curly-newline': [2, { |
| 147 | + consistent: true, |
| 148 | + }], |
| 149 | + |
| 150 | + 'object-curly-spacing': [2, 'never'], |
| 151 | + 'object-shorthand': [2, 'properties'], |
| 152 | + 'one-var': [2, 'never'], |
| 153 | + 'operator-linebreak': [2, 'before'], |
| 154 | + 'prefer-arrow-callback': 2, |
| 155 | + |
| 156 | + 'prefer-const': [2, { |
| 157 | + destructuring: 'all', |
| 158 | + }], |
| 159 | + |
| 160 | + 'prefer-destructuring': [2, { |
| 161 | + array: false, |
| 162 | + object: true, |
| 163 | + }], |
| 164 | + |
| 165 | + 'prefer-object-spread': 2, |
| 166 | + 'prefer-regex-literals': 2, |
| 167 | + 'prefer-rest-params': 2, |
| 168 | + 'quote-props': [2, 'as-needed'], |
| 169 | + |
| 170 | + quotes: [2, 'single', { |
| 171 | + avoidEscape: true, |
| 172 | + }], |
| 173 | + |
| 174 | + radix: 2, |
| 175 | + 'require-atomic-updates': 0, |
| 176 | + semi: [2, 'always'], |
| 177 | + |
| 178 | + 'sort-imports': [2, { |
| 179 | + ignoreCase: true, |
| 180 | + ignoreDeclarationSort: true, |
| 181 | + memberSyntaxSortOrder: ['none', 'all', 'single', 'multiple'], |
| 182 | + }], |
| 183 | + |
| 184 | + 'space-before-blocks': 2, |
| 185 | + |
| 186 | + 'space-before-function-paren': [2, { |
| 187 | + anonymous: 'always', |
| 188 | + asyncArrow: 'always', |
| 189 | + named: 'never', |
| 190 | + }], |
| 191 | + |
| 192 | + 'space-unary-ops': [2, { |
| 193 | + nonwords: false, |
| 194 | + |
| 195 | + overrides: { |
| 196 | + '!': true, |
| 197 | + }, |
| 198 | + |
| 199 | + words: true, |
| 200 | + }], |
| 201 | + |
| 202 | + 'spaced-comment': [2, 'always', { |
| 203 | + markers: ['!'], |
| 204 | + }], |
| 205 | + |
| 206 | + 'unicorn/catch-error-name': 2, |
| 207 | + 'unicorn/no-array-for-each': 2, |
| 208 | + 'unicorn/no-for-loop': 2, |
| 209 | + 'unicorn/no-lonely-if': 2, |
| 210 | + 'unicorn/no-negated-condition': 2, |
| 211 | + 'unicorn/no-nested-ternary': 2, |
| 212 | + 'unicorn/no-typeof-undefined': 2, |
| 213 | + 'unicorn/no-useless-fallback-in-spread': 2, |
| 214 | + 'unicorn/no-useless-promise-resolve-reject': 2, |
| 215 | + 'unicorn/no-zero-fractions': 2, |
| 216 | + 'unicorn/numeric-separators-style': 2, |
| 217 | + 'unicorn/prefer-array-find': 2, |
| 218 | + 'unicorn/prefer-array-flat-map': 2, |
| 219 | + 'unicorn/prefer-array-index-of': 2, |
| 220 | + 'unicorn/prefer-at': 2, |
| 221 | + 'unicorn/prefer-date-now': 2, |
| 222 | + |
| 223 | + 'unicorn/prefer-export-from': [2, { |
| 224 | + ignoreUsedVariables: true, |
| 225 | + }], |
| 226 | + |
| 227 | + 'unicorn/prefer-includes': 2, |
| 228 | + 'unicorn/prefer-logical-operator-over-ternary': 2, |
| 229 | + 'unicorn/prefer-node-protocol': 2, |
| 230 | + 'unicorn/prefer-starts-ends-with': 2, |
| 231 | + 'unicorn/prefer-string-replace-all': 2, |
| 232 | + 'unicorn/prefer-ternary': 2, |
| 233 | + 'unicorn/require-array-join-separator': 2, |
| 234 | + 'unicorn/throw-new-error': 2, |
| 235 | + yoda: 2, |
| 236 | + }, |
| 237 | + }, |
| 238 | + { |
| 239 | + files: ['test/test.js'], |
| 240 | + languageOptions: { |
| 241 | + globals: { |
| 242 | + expect: 'readonly', |
| 243 | + }, |
| 244 | + }, |
| 245 | + |
| 246 | + rules: { |
| 247 | + 'mocha/max-top-level-suites': 0, |
| 248 | + 'mocha/no-mocha-arrows': 0, |
| 249 | + 'mocha/no-return-from-async': 2, |
| 250 | + 'mocha/no-setup-in-describe': 0, |
| 251 | + 'mocha/no-skipped-tests': 0, |
| 252 | + 'mocha/no-top-level-hooks': 0, |
| 253 | + 'mocha/prefer-arrow-callback': 2, |
| 254 | + 'mocha/valid-test-description': 2, |
| 255 | + 'no-unused-expressions': 0, |
| 256 | + 'prefer-arrow-callback': 0, |
| 257 | + }, |
| 258 | + }, |
| 259 | +]; |
0 commit comments