Skip to content

Commit 94868e6

Browse files
committed
ESLint: drop unnecessary rules
Most rules are derived from the `airbnb` template. Some "bad" rule exceptions remain, but they require too many changes to fix, so we leave it to a future refactoring.
1 parent 705f238 commit 94868e6

7 files changed

Lines changed: 22 additions & 260 deletions

File tree

.eslintrc.js

Lines changed: 14 additions & 252 deletions
Original file line numberDiff line numberDiff line change
@@ -39,312 +39,74 @@ module.exports = {
3939
},
4040

4141
'rules': {
42-
// Auto generated rules:
43-
'accessor-pairs': 'error',
44-
'array-bracket-newline': 'error',
45-
'array-bracket-spacing': [
46-
'error',
47-
'never'
48-
],
49-
'array-callback-return': 'error',
50-
'array-element-newline': 'off',
5142
'arrow-body-style': 'off',
52-
'arrow-parens': [
53-
'error',
54-
'as-needed'
55-
],
56-
'arrow-spacing': [
57-
'error',
58-
{
59-
'after': true,
60-
'before': true
61-
}
62-
],
63-
'block-spacing': [
64-
'error',
65-
'always'
66-
],
67-
'brace-style': 'off',
68-
'callback-return': 'error',
69-
'camelcase': [
70-
'error',
71-
{
72-
'properties': 'never'
73-
}
74-
],
75-
'capitalized-comments': 'off',
43+
'arrow-parens': ['error','as-needed'],
7644
'class-methods-use-this': 'off',
77-
'comma-dangle': [ 'error', 'never' ],
45+
'comma-dangle': ['error', 'never'],
7846
'comma-spacing': 'off',
79-
'comma-style': [
80-
'error',
81-
'last'
82-
],
83-
'complexity': 'off',
84-
'computed-property-spacing': [
85-
'error',
86-
'never'
87-
],
8847
'consistent-return': 'off',
89-
'consistent-this': 'error',
90-
'curly': 'error',
9148
'default-case': 'off',
9249
'default-param-last': 'off',
93-
'dot-location': 'error',
94-
'dot-notation': [
95-
'error',
96-
{
97-
'allowKeywords': true
98-
}
99-
],
10050
'eol-last': ['error', 'always'],
101-
'eqeqeq': 'error',
102-
'for-direction': 'error',
103-
'func-call-spacing': 'error',
10451
'function-call-argument-newline': 'off',
105-
'func-name-matching': 'error',
106-
'func-names': [
107-
'error',
108-
'never'
109-
],
110-
'func-style': 'off',
52+
'func-names': ['error', 'never'],
11153
'function-paren-newline': 'off',
112-
'generator-star-spacing': 'error',
113-
'getter-return': 'error',
11454
'global-require': 'off',
115-
'guard-for-in': 'off',
116-
'handle-callback-err': 'error',
117-
'id-blacklist': 'error',
118-
'id-length': 'off',
119-
'id-match': 'error',
120-
'implicit-arrow-linebreak': [
121-
'error',
122-
'beside'
123-
],
124-
'init-declarations': 'off',
125-
'jsx-quotes': 'error',
12655
'key-spacing': 'off',
12756
'keyword-spacing': 'error',
128-
'line-comment-position': 'off',
129-
'linebreak-style': [
130-
'error',
131-
'unix'
132-
],
133-
'lines-around-comment': 'off',
134-
'lines-around-directive': 'error',
135-
'lines-between-class-members': 'error',
13657
'max-classes-per-file': 'off',
137-
'max-depth': 'off',
13858
'max-len': 'off',
139-
'max-lines': 'off',
140-
'max-nested-callbacks': 'error',
141-
'max-params': 'off',
142-
'max-statements': 'off',
143-
'max-statements-per-line': 'off',
144-
'multiline-comment-style': 'off',
145-
'multiline-ternary': 'off',
146-
'new-parens': 'error',
147-
'newline-after-var': 'off',
148-
'newline-before-return': 'off',
14959
'newline-per-chained-call': 'off',
150-
'no-alert': 'error',
151-
'no-array-constructor': 'error',
15260
'no-bitwise': 'off',
153-
'no-buffer-constructor': 'error',
154-
'no-caller': 'error',
155-
'no-catch-shadow': 'error',
156-
'no-confusing-arrow': 'error',
15761
'no-continue': 'off',
158-
'no-div-regex': 'error',
159-
'no-duplicate-imports': 'error',
16062
'no-else-return': 'off',
161-
'no-empty': [
162-
'error',
163-
{
164-
'allowEmptyCatch': true
165-
}
166-
],
167-
'no-empty-function': 'off',
168-
'no-eq-null': 'error',
169-
'no-eval': 'error',
170-
'no-extend-native': 'error',
171-
'no-extra-bind': 'error',
172-
'no-extra-label': 'error',
173-
'no-extra-parens': 'off',
174-
'no-floating-decimal': 'error',
175-
'no-implicit-globals': 'error',
176-
'no-implied-eval': 'error',
177-
'no-inline-comments': 'off',
178-
'no-inner-declarations': [
179-
'error',
180-
'functions'
181-
],
182-
'no-invalid-this': 'error',
183-
'no-iterator': 'error',
184-
'no-label-var': 'error',
185-
'no-labels': 'error',
186-
'no-lone-blocks': 'error',
187-
'no-lonely-if': 'error',
188-
'no-loop-func': 'error',
189-
'no-magic-numbers': 'off',
190-
'no-mixed-operators': 'off',
191-
'no-mixed-requires': 'error',
192-
'no-multi-assign': 'error',
193-
'no-multi-spaces': [
194-
'error',
195-
{
196-
'ignoreEOLComments': true
197-
}
198-
],
199-
'no-multi-str': 'error',
63+
'no-empty': ['error', { 'allowEmptyCatch': true }],
20064
'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 1, 'maxBOF':0 }],
201-
'no-native-reassign': 'error',
202-
'no-negated-condition': 'off',
203-
'no-negated-in-lhs': 'error',
20465
'no-nested-ternary': 'off',
205-
'no-new': 'error',
206-
'no-new-func': 'error',
207-
'no-new-object': 'error',
208-
'no-new-require': 'error',
209-
'no-new-wrappers': 'error',
210-
'no-octal-escape': 'error',
211-
'no-param-reassign': 'off',
212-
'no-path-concat': 'error',
66+
'no-param-reassign': 'off', // TODO get rid of this
21367
'no-plusplus': 'off',
214-
'no-process-env': 'error',
215-
'no-process-exit': 'error',
216-
'no-proto': 'error',
217-
'no-prototype-builtins': 'off',
218-
'no-restricted-globals': 'error',
219-
'no-restricted-imports': 'error',
220-
'no-restricted-modules': 'error',
221-
'no-restricted-properties': 'error',
22268
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
223-
'no-return-assign': 'error',
224-
'no-return-await': 'error',
225-
'no-script-url': 'error',
226-
'no-self-compare': 'error',
227-
'no-shadow': 'off',
228-
'no-shadow-restricted-names': 'error',
229-
'no-spaced-func': 'error',
230-
'no-sync': 'error',
231-
'no-tabs': 'error',
232-
'no-template-curly-in-string': 'error',
233-
'no-ternary': 'off',
234-
'no-throw-literal': 'error',
235-
'no-undef-init': 'error',
236-
'no-undefined': 'off',
237-
'no-unmodified-loop-condition': 'error',
238-
'no-unneeded-ternary': [
239-
'error',
240-
{
241-
'defaultAssignment': true
242-
}
243-
],
244-
'no-use-before-define': 'off',
245-
'no-useless-call': 'error',
246-
'no-useless-computed-key': 'error',
247-
'no-useless-concat': 'error',
248-
'no-useless-constructor': 'error',
249-
'no-useless-rename': 'error',
250-
'no-useless-return': 'error',
251-
'no-void': 'error',
252-
'no-warning-comments': 'off',
253-
'no-whitespace-before-property': 'error',
254-
'no-with': 'error',
255-
'nonblock-statement-body-position': 'error',
25669
'object-curly-newline': 'off',
257-
'object-curly-spacing': 'error',
70+
'no-shadow': 'off', // TODO get rid of this
25871
'object-property-newline': [
25972
'error',
26073
{
26174
'allowMultiplePropertiesPerLine': true
26275
}
26376
],
26477
'object-shorthand': 'off',
265-
'one-var-declaration-per-line': [
266-
'error',
267-
'initializations'
268-
],
26978
'operator-assignment': 'off',
27079
'operator-linebreak': [
27180
'error',
27281
'after'
27382
],
27483
'padded-blocks': 'off',
275-
'padding-line-between-statements': 'error',
27684
'prefer-arrow-callback': 'off',
27785
'prefer-destructuring': 'off',
278-
'prefer-numeric-literals': 'error',
279-
'prefer-promise-reject-errors': 'error',
280-
'prefer-reflect': 'off',
281-
'prefer-rest-params': 'off',
282-
'prefer-spread': 'off',
86+
'prefer-rest-params': 'off', // TODO get rid of this
87+
'prefer-spread': 'off', // TODO get rid of this
28388
'prefer-template': 'off',
28489
'quote-props': 'off',
28590
'quotes': ['error', 'single', { 'avoidEscape': true }],
286-
'require-await': 'error',
287-
'require-jsdoc': 'off',
288-
'semi-spacing': [
289-
'error',
290-
{
291-
'after': true,
292-
'before': false
293-
}
294-
],
295-
'semi-style': [
296-
'error',
297-
'last'
298-
],
299-
'sort-imports': 'off',
300-
'sort-keys': 'off',
301-
'sort-vars': 'off',
302-
'space-before-blocks': 'off',
30391
'space-before-function-paren': 'off',
304-
'space-in-parens': [
305-
'error',
306-
'never'
307-
],
308-
'space-infix-ops': 'error',
309-
'space-unary-ops': 'error',
31092
'spaced-comment': 'off',
311-
'strict': 'off',
312-
'switch-colon-spacing': 'error',
313-
'symbol-description': 'error',
314-
'template-curly-spacing': 'error',
315-
'template-tag-spacing': 'error',
316-
'unicode-bom': [
317-
'error',
318-
'never'
319-
],
320-
'wrap-iife': 'error',
321-
'wrap-regex': 'off',
322-
'yield-star-spacing': 'error',
323-
'yoda': [
324-
'error',
325-
'never'
326-
],
32793
'indent': ['error', 2, { 'SwitchCase': 1 }],
32894
'no-unused-vars': 'error',
32995

33096
// eslint-plugin-import rules:
33197
'import/named': 'error',
33298
'import/extensions': 'error',
333-
'import/no-extraneous-dependencies': ['error', {'devDependencies': true, 'optionalDependencies': false, 'peerDependencies': false}],
99+
'import/no-extraneous-dependencies': ['error', { 'devDependencies': true, 'optionalDependencies': false, 'peerDependencies': false }],
334100
'import/no-unassigned-import': 'error',
335101
'import/prefer-default-export': 'off',
336102

337103
// Custom silencers:
338-
'camelcase': 0,
339-
'require-await': 0,
340-
'no-multi-assign': 0,
341-
'no-underscore-dangle': 0,
342-
'no-await-in-loop': 0,
104+
'camelcase': 'off', // used in tests, need to fix separately
105+
'no-multi-assign': 'off',
106+
'no-underscore-dangle': 'off',
107+
'no-await-in-loop': 'off',
343108

344109
// Custom errors:
345-
'no-undef': 2,
346-
'no-trailing-spaces': 2,
347-
'no-mixed-operators': [2, { 'groups': [['&', '|', '^', '~', '<<', '>>', '>>>'], ['&&', '||']] }],
348110
'no-use-before-define': [2, { 'functions': false, 'classes': true, 'variables': false }],
349111
'no-constant-condition': [2, { 'checkLoops': false }],
350112
'new-cap': [2, { 'properties': false, 'capIsNewExceptionPattern': 'EAX|OCB|GCM|CMAC|CBC|OMAC|CTR', 'newIsCapExceptionPattern': 'type|hash*' }],
@@ -353,6 +115,6 @@ module.exports = {
353115
'chai-friendly/no-unused-expressions': [2, { 'allowShortCircuit': true }],
354116

355117
// Custom warnings:
356-
'no-console': 1,
118+
'no-console': 1
357119
}
358120
};

src/crypto/cmac.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function pad(data, padding, padding2) {
5151
return rightXORMut(data, padding);
5252
}
5353
// else return (M || 10^(n−1−(|M| mod n))) xor→ P
54-
const padded = new Uint8Array(data.length + (blockLength - data.length % blockLength));
54+
const padded = new Uint8Array(data.length + (blockLength - (data.length % blockLength)));
5555
padded.set(data);
5656
padded[data.length] = 0b10000000;
5757
return rightXORMut(padded, padding2);

src/key/helper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ export async function getLatestValidSignature(signatures, publicKey, signatureTy
6262
throw util.wrapError(
6363
`Could not find valid ${enums.read(enums.signature, signatureType)} signature in key ${publicKey.getKeyID().toHex()}`
6464
.replace('certGeneric ', 'self-')
65-
.replace(/([a-z])([A-Z])/g, (_, $1, $2) => $1 + ' ' + $2.toLowerCase())
66-
, exception);
65+
.replace(/([a-z])([A-Z])/g, (_, $1, $2) => $1 + ' ' + $2.toLowerCase()),
66+
exception);
6767
}
6868
return latestValid;
6969
}

src/key/key.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Key {
6363

6464
if (packet instanceof UnparseablePacket) {
6565
const isUnparseableKeyPacket = keyPacketTags.has(packet.tag);
66-
if (isUnparseableKeyPacket && !ignoreUntil){
66+
if (isUnparseableKeyPacket && !ignoreUntil) {
6767
// Since non-key packets apply to the preceding key packet, if a (sub)key is Unparseable we must
6868
// discard all non-key packets that follow, until another (sub)key packet is found.
6969
if (mainKeyPacketTags.has(packet.tag)) {

src/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ const debugMode = (() => {
3535

3636
const util = {
3737
isString: function(data) {
38-
return typeof data === 'string' || String.prototype.isPrototypeOf(data);
38+
return typeof data === 'string' || data instanceof String;
3939
},
4040

4141
isArray: function(data) {
42-
return Array.prototype.isPrototypeOf(data);
42+
return data instanceof Array;
4343
},
4444

4545
isUint8Array: stream.isUint8Array,

test/general/openpgp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ module.exports = () => describe('OpenPGP.js public api tests', function() {
11301130
passphrase: 'incorrect'
11311131
}).then(function() {
11321132
throw new Error('Should not decrypt with incorrect passphrase');
1133-
}).catch(function(error){
1133+
}).catch(function(error) {
11341134
expect(error.message).to.match(/Incorrect key passphrase/);
11351135
// original key should be unchanged
11361136
expect(privateKey.isDecrypted()).to.be.false;

test/general/testInputs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Generates a 64 character long javascript string out of the whole utf-8 range.
33
*/
4-
function createSomeMessage(){
4+
function createSomeMessage() {
55
const arr = [];
66
for (let i = 0; i < 30; i++) {
77
arr.push(Math.floor(Math.random() * 10174) + 1);

0 commit comments

Comments
 (0)