Skip to content

Commit 32fae9b

Browse files
authored
Inline eslint-config-standard config/rules in eslint.config.mjs (#6020)
The `eslint-config-standard` plugin has been inlined because: 1. It is no longer maintained. 2. It used a lot of deprecated rules. 3. It came with an older bundled version of `eslint-plugin-n` which conflicted with our version. 4. Blocked us from making some other changes to the ESLint config that we want to make.
1 parent 4f0d900 commit 32fae9b

File tree

4 files changed

+232
-20
lines changed

4 files changed

+232
-20
lines changed

LICENSE-3rdparty.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ dev,benchmark,MIT,Copyright 2010-2016 Mathias Bynens Robert Kieffer John-David D
4444
dev,body-parser,MIT,Copyright 2014 Jonathan Ong 2014-2015 Douglas Christopher Wilson
4545
dev,chai,MIT,Copyright 2017 Chai.js Assertion Library
4646
dev,eslint,MIT,Copyright JS Foundation and other contributors https://js.foundation
47-
dev,eslint-config-standard,MIT,Copyright Feross Aboukhadijeh
4847
dev,eslint-plugin-import,MIT,Copyright 2015 Ben Mosher
4948
dev,eslint-plugin-mocha,MIT,Copyright 2014 Mathias Schreck
5049
dev,eslint-plugin-n,MIT,Copyright 2015 Toru Nagashima

eslint.config.mjs

Lines changed: 232 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
import path from 'node:path'
2-
import { fileURLToPath } from 'node:url'
3-
4-
import { FlatCompat } from '@eslint/eslintrc'
51
import eslintPluginJs from '@eslint/js'
62
import eslintPluginStylistic from '@stylistic/eslint-plugin'
73
import eslintPluginImport from 'eslint-plugin-import'
84
import eslintPluginMocha from 'eslint-plugin-mocha'
95
import eslintPluginN from 'eslint-plugin-n'
6+
import eslintPluginPromise from 'eslint-plugin-promise'
107
import eslintPluginUnicorn from 'eslint-plugin-unicorn'
118
import globals from 'globals'
129

1310
import eslintProcessEnv from './eslint-rules/eslint-process-env.mjs'
1411
import eslintEnvAliases from './eslint-rules/eslint-env-aliases.mjs'
1512
import eslintSafeTypeOfObject from './eslint-rules/eslint-safe-typeof-object.mjs'
1613

17-
const __filename = fileURLToPath(import.meta.url)
18-
const __dirname = path.dirname(__filename)
19-
const compat = new FlatCompat({ baseDirectory: __dirname })
20-
2114
const SRC_FILES = [
2215
'*.js',
2316
'*.mjs',
@@ -59,7 +52,236 @@ export default [
5952
]
6053
},
6154
{ 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+
},
63285
{
64286
name: 'dd-trace/defaults',
65287

@@ -100,14 +322,11 @@ export default [
100322
importAttributes: 'always-multiline',
101323
dynamicImports: 'always-multiline'
102324
}],
103-
'comma-dangle': 'off', // Override (turned on by @eslint/js/recommended)
104325
'import/no-extraneous-dependencies': 'error',
105326
'n/no-restricted-require': ['error', ['diagnostics_channel']],
106327
'no-console': 'error',
107-
'no-mixed-operators': 'off', // Override (turned on by standard)
108328
'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',
111330
'require-await': 'error'
112331
}
113332
},

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
"body-parser": "^2.2.0",
133133
"chai": "^4.5.0",
134134
"eslint": "^9.29.0",
135-
"eslint-config-standard": "^17.1.0",
136135
"eslint-plugin-import": "^2.32.0",
137136
"eslint-plugin-mocha": "^10.5.0",
138137
"eslint-plugin-n": "^17.20.0",

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,11 +1970,6 @@ eslint-compat-utils@^0.5.1:
19701970
dependencies:
19711971
semver "^7.5.4"
19721972

1973-
eslint-config-standard@^17.1.0:
1974-
version "17.1.0"
1975-
resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-17.1.0.tgz#40ffb8595d47a6b242e07cbfd49dc211ed128975"
1976-
integrity sha512-IwHwmaBNtDK4zDHQukFDW5u/aTb8+meQWZvNFWkiGmbWjD6bqyuSSBxxXKkCftCUzc1zwCH2m/baCNDLGmuO5Q==
1977-
19781973
eslint-import-resolver-node@^0.3.9:
19791974
version "0.3.9"
19801975
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.9.tgz#d4eaac52b8a2e7c3cd1903eb00f7e053356118ac"

0 commit comments

Comments
 (0)