|
1 |
| -import path from 'node:path' |
2 |
| -import { fileURLToPath } from 'node:url' |
3 |
| - |
4 |
| -import { FlatCompat } from '@eslint/eslintrc' |
5 | 1 | import eslintPluginJs from '@eslint/js'
|
6 | 2 | import eslintPluginStylistic from '@stylistic/eslint-plugin'
|
7 | 3 | import eslintPluginImport from 'eslint-plugin-import'
|
8 | 4 | import eslintPluginMocha from 'eslint-plugin-mocha'
|
9 | 5 | import eslintPluginN from 'eslint-plugin-n'
|
| 6 | +import eslintPluginPromise from 'eslint-plugin-promise' |
10 | 7 | import eslintPluginUnicorn from 'eslint-plugin-unicorn'
|
11 | 8 | import globals from 'globals'
|
12 | 9 |
|
13 | 10 | import eslintProcessEnv from './eslint-rules/eslint-process-env.mjs'
|
14 | 11 | import eslintEnvAliases from './eslint-rules/eslint-env-aliases.mjs'
|
15 | 12 | import eslintSafeTypeOfObject from './eslint-rules/eslint-safe-typeof-object.mjs'
|
16 | 13 |
|
17 |
| -const __filename = fileURLToPath(import.meta.url) |
18 |
| -const __dirname = path.dirname(__filename) |
19 |
| -const compat = new FlatCompat({ baseDirectory: __dirname }) |
20 |
| - |
21 | 14 | const SRC_FILES = [
|
22 | 15 | '*.js',
|
23 | 16 | '*.mjs',
|
@@ -59,7 +52,236 @@ export default [
|
59 | 52 | ]
|
60 | 53 | },
|
61 | 54 | { name: '@eslint/js/recommended', ...eslintPluginJs.configs.recommended },
|
62 |
| - ...compat.extends('standard').map((config, i) => ({ name: config.name || `standard/${i + 1}`, ...config })), |
| 55 | + { |
| 56 | + // The following config and rules have been inlined from `eslint-config-standard` with the following modifications: |
| 57 | + // - Rules that were overridden elsewhere in this file have been removed. |
| 58 | + // - Deprecated rules have been replaced with their official replacements. |
| 59 | + // |
| 60 | + // We've inlined these to avoid having to depend on `eslint-config-standard` as: |
| 61 | + // 1. It's no longer maintained. |
| 62 | + // 2. It came with an older bundled version of `eslint-plugin-n` which conflicted with our version. |
| 63 | + // |
| 64 | + // TODO: Move these rules to dd-trace/defaults or where they otherwise belong. |
| 65 | + name: 'standard', |
| 66 | + languageOptions: { |
| 67 | + ecmaVersion: 2022, |
| 68 | + sourceType: 'module', |
| 69 | + parserOptions: { |
| 70 | + ecmaFeatures: { |
| 71 | + jsx: true |
| 72 | + } |
| 73 | + }, |
| 74 | + globals: { |
| 75 | + ...globals.es2021, |
| 76 | + ...globals.node, |
| 77 | + document: 'readonly', |
| 78 | + navigator: 'readonly', |
| 79 | + window: 'readonly' |
| 80 | + } |
| 81 | + }, |
| 82 | + plugins: { |
| 83 | + '@stylistic': eslintPluginStylistic, |
| 84 | + import: eslintPluginImport, |
| 85 | + n: eslintPluginN, |
| 86 | + promise: eslintPluginPromise |
| 87 | + }, |
| 88 | + rules: { |
| 89 | + '@stylistic/array-bracket-spacing': ['error', 'never'], |
| 90 | + '@stylistic/arrow-spacing': ['error', { before: true, after: true }], |
| 91 | + '@stylistic/block-spacing': ['error', 'always'], |
| 92 | + '@stylistic/comma-spacing': ['error', { before: false, after: true }], |
| 93 | + '@stylistic/computed-property-spacing': ['error', 'never', { enforceForClassMembers: true }], |
| 94 | + '@stylistic/dot-location': ['error', 'property'], |
| 95 | + '@stylistic/eol-last': 'error', |
| 96 | + '@stylistic/generator-star-spacing': ['error', { before: true, after: true }], |
| 97 | + '@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true }], |
| 98 | + '@stylistic/keyword-spacing': ['error', { before: true, after: true }], |
| 99 | + '@stylistic/lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }], |
| 100 | + '@stylistic/multiline-ternary': ['error', 'always-multiline'], |
| 101 | + '@stylistic/new-parens': 'error', |
| 102 | + '@stylistic/no-extra-parens': ['error', 'functions'], |
| 103 | + '@stylistic/no-floating-decimal': 'error', |
| 104 | + '@stylistic/no-mixed-spaces-and-tabs': 'error', |
| 105 | + '@stylistic/no-multi-spaces': 'error', |
| 106 | + '@stylistic/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }], |
| 107 | + '@stylistic/no-tabs': 'error', |
| 108 | + '@stylistic/no-trailing-spaces': 'error', |
| 109 | + '@stylistic/no-whitespace-before-property': 'error', |
| 110 | + '@stylistic/operator-linebreak': [ |
| 111 | + 'error', |
| 112 | + 'after', |
| 113 | + { overrides: { '?': 'before', ':': 'before', '|>': 'before' } } |
| 114 | + ], |
| 115 | + '@stylistic/padded-blocks': [ |
| 116 | + 'error', |
| 117 | + { blocks: 'never', switches: 'never', classes: 'never' } |
| 118 | + ], |
| 119 | + '@stylistic/quote-props': ['error', 'as-needed'], |
| 120 | + '@stylistic/quotes': [ |
| 121 | + 'error', |
| 122 | + 'single', |
| 123 | + { avoidEscape: true, allowTemplateLiterals: false } |
| 124 | + ], |
| 125 | + '@stylistic/rest-spread-spacing': ['error', 'never'], |
| 126 | + '@stylistic/semi': ['error', 'never'], |
| 127 | + '@stylistic/semi-spacing': ['error', { before: false, after: true }], |
| 128 | + '@stylistic/space-before-blocks': ['error', 'always'], |
| 129 | + '@stylistic/space-before-function-paren': ['error', 'always'], |
| 130 | + '@stylistic/space-in-parens': ['error', 'never'], |
| 131 | + '@stylistic/space-infix-ops': 'error', |
| 132 | + '@stylistic/space-unary-ops': ['error', { words: true, nonwords: false }], |
| 133 | + '@stylistic/spaced-comment': [ |
| 134 | + 'error', |
| 135 | + 'always', |
| 136 | + { |
| 137 | + line: { markers: ['*package', '!', '/', ',', '='] }, |
| 138 | + block: { |
| 139 | + balanced: true, |
| 140 | + markers: ['*package', '!', ',', ':', '::', 'flow-include'], |
| 141 | + exceptions: ['*'] |
| 142 | + } |
| 143 | + } |
| 144 | + ], |
| 145 | + '@stylistic/template-curly-spacing': ['error', 'never'], |
| 146 | + '@stylistic/template-tag-spacing': ['error', 'never'], |
| 147 | + '@stylistic/wrap-iife': ['error', 'any', { functionPrototypeMethods: true }], |
| 148 | + '@stylistic/yield-star-spacing': ['error', 'both'], |
| 149 | + 'accessor-pairs': ['error', { setWithoutGet: true, enforceForClassMembers: true }], |
| 150 | + 'array-callback-return': ['error', { allowImplicit: false, checkForEach: false }], |
| 151 | + 'brace-style': [ // TODO: Deprecated, use @stylistic/brace-style instead |
| 152 | + 'error', |
| 153 | + '1tbs', |
| 154 | + { allowSingleLine: true } |
| 155 | + ], |
| 156 | + camelcase: [ |
| 157 | + 'error', |
| 158 | + { |
| 159 | + allow: ['^UNSAFE_'], |
| 160 | + properties: 'never', |
| 161 | + ignoreGlobals: true |
| 162 | + } |
| 163 | + ], |
| 164 | + 'comma-style': ['error', 'last'], // TODO: Deprecated, use @stylistic/comma-style instead |
| 165 | + curly: ['error', 'multi-line'], |
| 166 | + 'default-case-last': 'error', |
| 167 | + 'dot-notation': ['error', { allowKeywords: true }], |
| 168 | + eqeqeq: ['error', 'always', { null: 'ignore' }], |
| 169 | + 'func-call-spacing': ['error', 'never'], // TODO: Deprecated, use @stylistic/func-call-spacing instead |
| 170 | + indent: [ // TODO: Deprecated, use @stylistic/indent instead |
| 171 | + 'error', |
| 172 | + 2, |
| 173 | + { |
| 174 | + SwitchCase: 1, |
| 175 | + VariableDeclarator: 1, |
| 176 | + outerIIFEBody: 1, |
| 177 | + MemberExpression: 1, |
| 178 | + FunctionDeclaration: { parameters: 1, body: 1 }, |
| 179 | + FunctionExpression: { parameters: 1, body: 1 }, |
| 180 | + CallExpression: { arguments: 1 }, |
| 181 | + ArrayExpression: 1, |
| 182 | + ObjectExpression: 1, |
| 183 | + ImportDeclaration: 1, |
| 184 | + flatTernaryExpressions: false, |
| 185 | + ignoreComments: false, |
| 186 | + ignoredNodes: [ |
| 187 | + 'TemplateLiteral *', |
| 188 | + 'JSXElement', |
| 189 | + 'JSXElement > *', |
| 190 | + 'JSXAttribute', |
| 191 | + 'JSXIdentifier', |
| 192 | + 'JSXNamespacedName', |
| 193 | + 'JSXMemberExpression', |
| 194 | + 'JSXSpreadAttribute', |
| 195 | + 'JSXExpressionContainer', |
| 196 | + 'JSXOpeningElement', |
| 197 | + 'JSXClosingElement', |
| 198 | + 'JSXFragment', |
| 199 | + 'JSXOpeningFragment', |
| 200 | + 'JSXClosingFragment', |
| 201 | + 'JSXText', |
| 202 | + 'JSXEmptyExpression', |
| 203 | + 'JSXSpreadChild' |
| 204 | + ], |
| 205 | + offsetTernaryExpressions: true |
| 206 | + } |
| 207 | + ], |
| 208 | + 'import/export': 'error', |
| 209 | + 'import/first': 'error', |
| 210 | + 'import/no-absolute-path': ['error', { esmodule: true, commonjs: true, amd: false }], |
| 211 | + 'import/no-duplicates': 'error', |
| 212 | + 'import/no-named-default': 'error', |
| 213 | + 'import/no-webpack-loader-syntax': 'error', |
| 214 | + 'n/handle-callback-err': ['error', '^(err|error)$'], |
| 215 | + 'n/no-callback-literal': 'error', |
| 216 | + 'n/no-deprecated-api': 'error', |
| 217 | + 'n/no-exports-assign': 'error', |
| 218 | + 'n/no-new-require': 'error', |
| 219 | + 'n/no-path-concat': 'error', |
| 220 | + 'n/process-exit-as-throw': 'error', |
| 221 | + 'new-cap': ['error', { newIsCap: true, capIsNew: false, properties: true }], |
| 222 | + 'no-array-constructor': 'error', |
| 223 | + 'no-caller': 'error', |
| 224 | + 'no-constant-condition': ['error', { checkLoops: false }], // override config from @eslint/js/recommended |
| 225 | + 'no-empty': ['error', { allowEmptyCatch: true }], // override config from @eslint/js/recommended |
| 226 | + 'no-eval': 'error', |
| 227 | + 'no-extend-native': 'error', |
| 228 | + 'no-extra-bind': 'error', |
| 229 | + 'no-implied-eval': 'error', |
| 230 | + 'no-iterator': 'error', |
| 231 | + 'no-labels': ['error', { allowLoop: false, allowSwitch: false }], |
| 232 | + 'no-lone-blocks': 'error', |
| 233 | + 'no-multi-str': 'error', |
| 234 | + 'no-new': 'error', |
| 235 | + 'no-new-func': 'error', |
| 236 | + 'no-new-wrappers': 'error', |
| 237 | + 'no-object-constructor': 'error', |
| 238 | + 'no-octal-escape': 'error', |
| 239 | + 'no-proto': 'error', |
| 240 | + 'no-redeclare': ['error', { builtinGlobals: false }], // override config from @eslint/js/recommended |
| 241 | + 'no-return-assign': ['error', 'except-parens'], |
| 242 | + 'no-self-compare': 'error', |
| 243 | + 'no-sequences': 'error', |
| 244 | + 'no-template-curly-in-string': 'error', |
| 245 | + 'no-throw-literal': 'error', |
| 246 | + 'no-undef-init': 'error', |
| 247 | + 'no-unmodified-loop-condition': 'error', |
| 248 | + 'no-unneeded-ternary': ['error', { defaultAssignment: false }], |
| 249 | + 'no-unreachable-loop': 'error', |
| 250 | + 'no-unused-vars': [ // override config from @eslint/js/recommended |
| 251 | + 'error', |
| 252 | + { |
| 253 | + args: 'none', |
| 254 | + caughtErrors: 'none', |
| 255 | + ignoreRestSiblings: true, |
| 256 | + vars: 'all' |
| 257 | + } |
| 258 | + ], |
| 259 | + 'no-use-before-define': ['error', { functions: false, classes: false, variables: false }], |
| 260 | + 'no-useless-call': 'error', |
| 261 | + 'no-useless-computed-key': 'error', |
| 262 | + 'no-useless-constructor': 'error', |
| 263 | + 'no-useless-rename': 'error', |
| 264 | + 'no-useless-return': 'error', |
| 265 | + 'no-void': 'error', |
| 266 | + 'object-property-newline': [ // TODO: Deprecated, use @stylistic/object-property-newline instead |
| 267 | + 'error', |
| 268 | + { allowMultiplePropertiesPerLine: true } |
| 269 | + ], |
| 270 | + 'object-shorthand': ['warn', 'properties'], |
| 271 | + 'one-var': ['error', { initialized: 'never' }], |
| 272 | + 'prefer-const': ['error', { destructuring: 'all' }], |
| 273 | + 'prefer-promise-reject-errors': 'error', |
| 274 | + 'prefer-regex-literals': ['error', { disallowRedundantWrapping: true }], |
| 275 | + 'promise/param-names': 'error', |
| 276 | + 'symbol-description': 'error', |
| 277 | + 'unicode-bom': ['error', 'never'], |
| 278 | + 'use-isnan': [ // override config from @eslint/js/recommended |
| 279 | + 'error', |
| 280 | + { enforceForSwitchCase: true, enforceForIndexOf: true } |
| 281 | + ], |
| 282 | + yoda: ['error', 'never'] |
| 283 | + } |
| 284 | + }, |
63 | 285 | {
|
64 | 286 | name: 'dd-trace/defaults',
|
65 | 287 |
|
@@ -100,14 +322,11 @@ export default [
|
100 | 322 | importAttributes: 'always-multiline',
|
101 | 323 | dynamicImports: 'always-multiline'
|
102 | 324 | }],
|
103 |
| - 'comma-dangle': 'off', // Override (turned on by @eslint/js/recommended) |
104 | 325 | 'import/no-extraneous-dependencies': 'error',
|
105 | 326 | 'n/no-restricted-require': ['error', ['diagnostics_channel']],
|
106 | 327 | 'no-console': 'error',
|
107 |
| - 'no-mixed-operators': 'off', // Override (turned on by standard) |
108 | 328 | 'no-prototype-builtins': 'off', // Override (turned on by @eslint/js/recommended)
|
109 |
| - 'no-unused-expressions': 'off', // Override (turned on by standard) |
110 |
| - 'no-var': 'error', // Override (set to warn in standard) |
| 329 | + 'no-var': 'error', |
111 | 330 | 'require-await': 'error'
|
112 | 331 | }
|
113 | 332 | },
|
|
0 commit comments