Skip to content

Commit 2256454

Browse files
committed
chore: update to latest eslint and linting rules
This brings us in line with the rest of the linting rules we are wanting to use on the npm cli repos. There were several hundred over-length lines and instead of editing them all by hand I piped the failing file through `prettier` and back through `eslint` just to save some time and energy. This means there may be some quirks in the linting those files have, but we can fix those if we see them and they bother us. Other than that there were about 50 lines that are legitimately over-length, all are now explicitly overridden. Many are tests that could be snapshots. PR-URL: #3995 Credit: @wraithgar Close: #3995 Reviewed-by: @lukekarrys
1 parent de45f90 commit 2256454

File tree

175 files changed

+5782
-5134
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+5782
-5134
lines changed

.eslintrc.json

+1-212
Original file line numberDiff line numberDiff line change
@@ -1,214 +1,3 @@
11
{
2-
"parserOptions": {
3-
"ecmaVersion": 2018,
4-
"ecmaFeatures": {},
5-
"sourceType": "script"
6-
},
7-
8-
"env": {
9-
"es6": true,
10-
"node": true
11-
},
12-
13-
"plugins": [
14-
"import",
15-
"node",
16-
"promise",
17-
"standard"
18-
],
19-
20-
"globals": {
21-
"document": "readonly",
22-
"navigator": "readonly",
23-
"window": "readonly"
24-
},
25-
26-
"rules": {
27-
"accessor-pairs": "error",
28-
"array-bracket-spacing": ["error", "never"],
29-
"arrow-spacing": ["error", { "before": true, "after": true }],
30-
"block-spacing": ["error", "always"],
31-
"brace-style": ["error", "1tbs", { "allowSingleLine": false }],
32-
"camelcase": ["error", { "properties": "never" }],
33-
"comma-dangle": ["error", {
34-
"arrays": "always-multiline",
35-
"objects": "always-multiline",
36-
"imports": "always-multiline",
37-
"exports": "always-multiline",
38-
"functions": "never"
39-
}],
40-
"comma-spacing": ["error", { "before": false, "after": true }],
41-
"comma-style": ["error", "last"],
42-
"computed-property-spacing": ["error", "never"],
43-
"constructor-super": "error",
44-
"curly": ["error", "multi-or-nest"],
45-
"dot-location": ["error", "property"],
46-
"dot-notation": ["error", { "allowKeywords": true }],
47-
"eol-last": "error",
48-
"eqeqeq": ["error", "always", { "null": "ignore" }],
49-
"func-call-spacing": ["error", "never"],
50-
"generator-star-spacing": ["error", { "before": true, "after": true }],
51-
"handle-callback-err": ["error", "^(err|error)$" ],
52-
"indent": ["error", 2, {
53-
"SwitchCase": 1,
54-
"VariableDeclarator": 1,
55-
"outerIIFEBody": 1,
56-
"MemberExpression": 1,
57-
"FunctionDeclaration": { "parameters": 1, "body": 1 },
58-
"FunctionExpression": { "parameters": 1, "body": 1 },
59-
"CallExpression": { "arguments": 1 },
60-
"ArrayExpression": 1,
61-
"ObjectExpression": 1,
62-
"ImportDeclaration": 1,
63-
"flatTernaryExpressions": true,
64-
"ignoreComments": false,
65-
"ignoredNodes": ["TemplateLiteral *"]
66-
}],
67-
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
68-
"keyword-spacing": ["error", { "before": true, "after": true }],
69-
"lines-between-class-members": ["error", "always", { "exceptAfterSingleLine": true }],
70-
"max-len": ["error", 80, {
71-
"ignoreUrls": true,
72-
"ignoreComments": false,
73-
"ignoreRegExpLiterals": true,
74-
"ignoreStrings": true,
75-
"ignoreTemplateLiterals": true
76-
}],
77-
"new-cap": ["error", { "newIsCap": true, "capIsNew": false, "properties": true }],
78-
"new-parens": "error",
79-
"no-array-constructor": "error",
80-
"no-async-promise-executor": "error",
81-
"no-caller": "error",
82-
"no-case-declarations": "error",
83-
"no-class-assign": "error",
84-
"no-compare-neg-zero": "error",
85-
"no-cond-assign": "off",
86-
"no-const-assign": "error",
87-
"no-constant-condition": ["error", { "checkLoops": false }],
88-
"no-control-regex": "error",
89-
"no-debugger": "error",
90-
"no-delete-var": "error",
91-
"no-dupe-args": "error",
92-
"no-dupe-class-members": "error",
93-
"no-dupe-keys": "error",
94-
"no-duplicate-case": "error",
95-
"no-empty-character-class": "error",
96-
"no-empty-pattern": "error",
97-
"no-eval": "error",
98-
"no-ex-assign": "error",
99-
"no-extend-native": "error",
100-
"no-extra-bind": "error",
101-
"no-extra-boolean-cast": "error",
102-
"no-extra-parens": ["error", "functions"],
103-
"no-fallthrough": "error",
104-
"no-floating-decimal": "error",
105-
"no-func-assign": "error",
106-
"no-global-assign": "error",
107-
"no-implied-eval": "error",
108-
"no-inner-declarations": ["error", "functions"],
109-
"no-invalid-regexp": "error",
110-
"no-irregular-whitespace": "error",
111-
"no-iterator": "error",
112-
"no-labels": ["error", { "allowLoop": true, "allowSwitch": false }],
113-
"no-lone-blocks": "error",
114-
"no-misleading-character-class": "error",
115-
"no-prototype-builtins": "error",
116-
"no-useless-catch": "error",
117-
"no-mixed-operators": "off",
118-
"no-mixed-spaces-and-tabs": "error",
119-
"no-multi-spaces": "error",
120-
"no-multi-str": "error",
121-
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 0 }],
122-
"no-negated-in-lhs": "error",
123-
"no-new": "off",
124-
"no-new-func": "error",
125-
"no-new-object": "error",
126-
"no-new-require": "error",
127-
"no-new-symbol": "error",
128-
"no-new-wrappers": "error",
129-
"no-obj-calls": "error",
130-
"no-octal": "error",
131-
"no-octal-escape": "error",
132-
"no-path-concat": "error",
133-
"no-proto": "error",
134-
"no-redeclare": ["error", { "builtinGlobals": false }],
135-
"no-regex-spaces": "error",
136-
"no-return-assign": "off",
137-
"no-self-assign": "off",
138-
"no-self-compare": "error",
139-
"no-sequences": "error",
140-
"no-shadow-restricted-names": "error",
141-
"no-sparse-arrays": "error",
142-
"no-tabs": "error",
143-
"no-template-curly-in-string": "off",
144-
"no-this-before-super": "error",
145-
"no-throw-literal": "off",
146-
"no-trailing-spaces": "error",
147-
"no-undef": "error",
148-
"no-undef-init": "error",
149-
"no-unexpected-multiline": "error",
150-
"no-unmodified-loop-condition": "error",
151-
"no-unneeded-ternary": ["error", { "defaultAssignment": false }],
152-
"no-unreachable": "error",
153-
"no-unsafe-finally": 0,
154-
"no-unsafe-negation": "error",
155-
"no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true, "allowTaggedTemplates": true }],
156-
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": true }],
157-
"no-use-before-define": ["error", { "functions": false, "classes": false, "variables": false }],
158-
"no-useless-call": "error",
159-
"no-useless-computed-key": "error",
160-
"no-useless-constructor": "error",
161-
"no-useless-escape": "error",
162-
"no-useless-rename": "error",
163-
"no-useless-return": "error",
164-
"no-void": "error",
165-
"no-whitespace-before-property": "error",
166-
"no-with": "error",
167-
"nonblock-statement-body-position": [2, "below"],
168-
"object-curly-newline": "off",
169-
"object-curly-spacing": "off",
170-
"object-property-newline": ["error", { "allowMultiplePropertiesPerLine": true }],
171-
"one-var": ["error", { "initialized": "never" }],
172-
"operator-linebreak": "off",
173-
"padded-blocks": ["error", { "blocks": "never", "switches": "never", "classes": "never" }],
174-
"prefer-const": ["error", {"destructuring": "all"}],
175-
"prefer-promise-reject-errors": "error",
176-
"quote-props": ["error", "as-needed"],
177-
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }],
178-
"rest-spread-spacing": ["error", "never"],
179-
"semi": ["error", "never"],
180-
"semi-spacing": ["error", { "before": false, "after": true }],
181-
"space-before-blocks": ["error", "always"],
182-
"space-before-function-paren": ["error", "always"],
183-
"space-in-parens": ["error", "never"],
184-
"space-infix-ops": "error",
185-
"space-unary-ops": ["error", { "words": true, "nonwords": false }],
186-
"spaced-comment": ["error", "always", {
187-
"line": { "markers": ["*package", "!", "/", ",", "="] },
188-
"block": { "balanced": true, "markers": ["*package", "!", ",", ":", "::", "flow-include"], "exceptions": ["*"] }
189-
}],
190-
"symbol-description": "error",
191-
"template-curly-spacing": ["error", "never"],
192-
"template-tag-spacing": ["error", "never"],
193-
"unicode-bom": ["error", "never"],
194-
"use-isnan": "error",
195-
"valid-typeof": ["error", { "requireStringLiterals": true }],
196-
"wrap-iife": ["error", "any", { "functionPrototypeMethods": true }],
197-
"yield-star-spacing": ["error", "both"],
198-
"yoda": ["error", "never"],
199-
200-
"import/export": "error",
201-
"import/first": "error",
202-
"import/no-absolute-path": ["error", { "esmodule": true, "commonjs": true, "amd": false }],
203-
"import/no-duplicates": "error",
204-
"import/no-named-default": "error",
205-
"import/no-webpack-loader-syntax": "error",
206-
207-
"node/no-deprecated-api": "error",
208-
"node/process-exit-as-throw": "error",
209-
210-
"promise/param-names": "off",
211-
212-
"standard/no-callback-literal": "error"
213-
}
2+
"extends": ["@npmcli"]
2143
}

bin/npx-cli.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const removed = new Set([
2626

2727
const { definitions, shorthands } = require('../lib/utils/config/index.js')
2828
const npmSwitches = Object.entries(definitions)
29-
.filter(([key, {type}]) => type === Boolean ||
29+
.filter(([key, { type }]) => type === Boolean ||
3030
(Array.isArray(type) && type.includes(Boolean)))
3131
.map(([key]) => key)
3232

@@ -65,9 +65,9 @@ let i
6565
let sawRemovedFlags = false
6666
for (i = 3; i < process.argv.length; i++) {
6767
const arg = process.argv[i]
68-
if (arg === '--')
68+
if (arg === '--') {
6969
break
70-
else if (/^-/.test(arg)) {
70+
} else if (/^-/.test(arg)) {
7171
const [key, ...v] = arg.replace(/^-+/, '').split('=')
7272

7373
switch (key) {
@@ -87,8 +87,9 @@ for (i = 3; i < process.argv.length; i++) {
8787
// resolve shorthands and run again
8888
if (shorthands[key] && !removed.has(key)) {
8989
const a = [...shorthands[key]]
90-
if (v.length)
90+
if (v.length) {
9191
a.push(v.join('='))
92+
}
9293
process.argv.splice(i, 1, ...a)
9394
i--
9495
continue
@@ -109,8 +110,9 @@ for (i = 3; i < process.argv.length; i++) {
109110
if (removed.has(key)) {
110111
// also remove the value for the cut key.
111112
process.argv.splice(i + 1, 1)
112-
} else
113+
} else {
113114
i++
115+
}
114116
}
115117
} else {
116118
// found a positional arg, put -- in front of it, and we're done
@@ -119,7 +121,8 @@ for (i = 3; i < process.argv.length; i++) {
119121
}
120122
}
121123

122-
if (sawRemovedFlags)
124+
if (sawRemovedFlags) {
123125
console.error('See `npm help exec` for more information')
126+
}
124127

125128
cli(process)

0 commit comments

Comments
 (0)