Skip to content

Commit 4c3a08b

Browse files
authored
[ESLint] enable sonar/prefer-promise-shorthand and sonar/no-dead-store rules (#3143)
1 parent 7bf9092 commit 4c3a08b

File tree

11 files changed

+355
-176
lines changed

11 files changed

+355
-176
lines changed

.changeset/grumpy-experts-speak.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'graphql-language-service-server': patch
3+
'vscode-graphql-execution': patch
4+
---
5+
6+
[ESLint] enable `sonar/prefer-promise-shorthand` and `sonar/no-dead-store` rules

.changeset/hip-maps-study.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'vscode-graphql-execution': minor
3+
---
4+
5+
`GraphQLContentProvider.getCurrentHtml` should not return `Promise`

.eslintrc.js

+150-142
Original file line numberDiff line numberDiff line change
@@ -52,93 +52,91 @@ module.exports = {
5252
rules: {
5353
'@arthurgeron/react-usememo/require-usememo': [
5454
'error',
55-
{
56-
checkHookCalls: false,
57-
},
55+
{ checkHookCalls: false },
5856
],
5957
// Possible Errors (http://eslint.org/docs/rules/#possible-errors)
6058
'no-console': 'error',
61-
'no-constant-binary-expression': 2,
62-
'no-empty': [1, { allowEmptyCatch: true }],
63-
'no-extra-parens': 0,
64-
'no-template-curly-in-string': 0,
65-
'valid-jsdoc': 0,
59+
'no-constant-binary-expression': 'error',
60+
'no-empty': ['error', { allowEmptyCatch: true }],
61+
'no-extra-parens': 'off',
62+
'no-template-curly-in-string': 'off',
63+
'valid-jsdoc': 'off',
6664

6765
// Best Practices (http://eslint.org/docs/rules/#best-practices)
68-
'accessor-pairs': 1,
69-
'array-callback-return': 0,
70-
'block-scoped-var': 0,
71-
'class-methods-use-this': 0,
72-
complexity: 0,
73-
'consistent-return': 0,
74-
curly: 1,
75-
'default-case': 0,
76-
'dot-notation': 1,
77-
eqeqeq: [1, 'allow-null'],
78-
'guard-for-in': 0,
66+
'accessor-pairs': 'error',
67+
'array-callback-return': 'off',
68+
'block-scoped-var': 'off',
69+
'class-methods-use-this': 'off',
70+
complexity: 'off',
71+
'consistent-return': 'off',
72+
curly: 'error',
73+
'default-case': 'off',
74+
'dot-notation': 'error',
75+
eqeqeq: ['error', 'allow-null'],
76+
'guard-for-in': 'off',
7977
'no-alert': 'error',
80-
'no-await-in-loop': 1,
81-
'no-caller': 1,
82-
'no-case-declarations': 0,
83-
'no-div-regex': 1,
78+
'no-await-in-loop': 'error',
79+
'no-caller': 'error',
80+
'no-case-declarations': 'off',
81+
'no-div-regex': 'error',
8482
'no-else-return': ['error', { allowElseIf: false }],
85-
'no-eq-null': 0,
86-
'no-eval': 1,
87-
'no-extend-native': 1,
88-
'no-extra-bind': 1,
89-
'no-extra-label': 1,
90-
'no-floating-decimal': 0, // prettier --list-different
91-
'no-implicit-coercion': 1,
92-
'no-implicit-globals': 0,
93-
'no-implied-eval': 1,
94-
'no-invalid-this': 0,
95-
'no-iterator': 1,
96-
'no-labels': 1,
97-
'no-lone-blocks': 1,
98-
'no-loop-func': 0,
99-
'no-magic-numbers': 0,
100-
'no-multi-str': 0,
101-
'no-new-func': 1,
102-
'no-new-wrappers': 1,
83+
'no-eq-null': 'off',
84+
'no-eval': 'error',
85+
'no-extend-native': 'error',
86+
'no-extra-bind': 'error',
87+
'no-extra-label': 'error',
88+
'no-floating-decimal': 'off', // prettier --list-different
89+
'no-implicit-coercion': 'error',
90+
'no-implicit-globals': 'off',
91+
'no-implied-eval': 'error',
92+
'no-invalid-this': 'off',
93+
'no-iterator': 'error',
94+
'no-labels': 'error',
95+
'no-lone-blocks': 'error',
96+
'no-loop-func': 'off',
97+
'no-magic-numbers': 'off',
98+
'no-multi-str': 'off',
99+
'no-new-func': 'error',
100+
'no-new-wrappers': 'error',
103101
'no-new': 'error',
104-
'no-octal-escape': 1,
105-
'no-param-reassign': 1,
106-
'no-proto': 1,
107-
'no-restricted-properties': 0,
108-
'no-return-assign': 1,
109-
'no-return-await': 1,
110-
'no-script-url': 1,
111-
'no-self-compare': 1,
112-
'no-sequences': 1,
102+
'no-octal-escape': 'error',
103+
'no-param-reassign': 'error',
104+
'no-proto': 'error',
105+
'no-restricted-properties': 'off',
106+
'no-return-assign': 'error',
107+
'no-return-await': 'error',
108+
'no-script-url': 'error',
109+
'no-self-compare': 'error',
110+
'no-sequences': 'error',
113111
'no-throw-literal': 'error',
114-
'no-unmodified-loop-condition': 0,
115-
'no-useless-call': 1,
116-
'no-useless-concat': 1,
117-
'no-useless-return': 0,
112+
'no-unmodified-loop-condition': 'off',
113+
'no-useless-call': 'error',
114+
'no-useless-concat': 'error',
115+
'no-useless-return': 'off',
118116
'@typescript-eslint/prefer-optional-chain': 'error',
119-
'no-warning-comments': 0,
117+
'no-warning-comments': 'off',
120118
radix: 'error',
121-
'require-await': 0,
122-
'vars-on-top': 0,
123-
yoda: 1,
119+
'require-await': 'off',
120+
'vars-on-top': 'off',
121+
yoda: 'error',
124122
'unicorn/prefer-string-slice': 'error',
125123
'sonarjs/no-identical-functions': 'error',
126124
'sonarjs/no-unused-collection': 'error',
127125
'sonarjs/no-extra-arguments': 'error',
128126
'unicorn/no-useless-undefined': 'error',
129127
'no-var': 'error',
130128
// Strict Mode (http://eslint.org/docs/rules/#strict-mode)
131-
strict: 0,
129+
strict: 'off',
132130

133131
// Variables (http://eslint.org/docs/rules/#variables)
134-
'init-declarations': 0,
135-
'no-catch-shadow': 1,
136-
'no-label-var': 1,
137-
'no-restricted-globals': 0,
132+
'init-declarations': 'off',
133+
'no-catch-shadow': 'error',
134+
'no-label-var': 'error',
135+
'no-restricted-globals': 'off',
138136
'no-shadow': 'off',
139137
'@typescript-eslint/no-shadow': 'error',
140-
'no-undef-init': 0,
141-
'no-undefined': 0,
138+
'no-undef-init': 'off',
139+
'no-undefined': 'off',
142140

143141
'@typescript-eslint/no-unused-vars': [
144142
'error',
@@ -149,56 +147,56 @@ module.exports = {
149147
},
150148
],
151149

152-
'no-use-before-define': 0,
150+
'no-use-before-define': 'off',
153151

154152
'unicorn/no-useless-switch-case': 'error',
155153
// Node.js and CommonJS (http://eslint.org/docs/rules/#nodejs-and-commonjs)
156-
'callback-return': 0,
157-
'global-require': 0,
158-
'handle-callback-err': 1,
159-
'no-mixed-requires': 1,
160-
'no-new-require': 1,
161-
'no-path-concat': 1,
162-
'no-process-env': 0,
163-
'no-process-exit': 0,
164-
'no-restricted-modules': 0,
165-
'no-sync': 0,
154+
'callback-return': 'off',
155+
'global-require': 'off',
156+
'handle-callback-err': 'error',
157+
'no-mixed-requires': 'error',
158+
'no-new-require': 'error',
159+
'no-path-concat': 'error',
160+
'no-process-env': 'off',
161+
'no-process-exit': 'off',
162+
'no-restricted-modules': 'off',
163+
'no-sync': 'off',
166164

167165
// Stylistic Issues (http://eslint.org/docs/rules/#stylistic-issues)
168-
camelcase: 0,
169-
'capitalized-comments': 0,
170-
'consistent-this': 0,
171-
'func-name-matching': 0,
172-
'func-names': 0,
173-
'func-style': 0,
174-
'id-blacklist': 0,
175-
'id-length': 0,
176-
'id-match': 0,
177-
indent: 0,
178-
'line-comment-position': 0,
179-
'linebreak-style': 0, // prettier --list-different
180-
'lines-around-comment': 0,
181-
'lines-around-directive': 0,
182-
'max-depth': 0,
183-
'max-lines': 0,
184-
'max-nested-callbacks': 0,
185-
'max-params': 0,
186-
'max-statements-per-line': 0,
187-
'max-statements': 0,
188-
'multiline-ternary': 0,
189-
'new-cap': 0,
190-
'newline-after-var': 0,
191-
'newline-before-return': 0,
192-
'newline-per-chained-call': 0,
193-
'no-bitwise': 1,
194-
'no-continue': 0,
195-
'no-inline-comments': 0,
196-
'no-mixed-operators': 0,
166+
camelcase: 'off',
167+
'capitalized-comments': 'off',
168+
'consistent-this': 'off',
169+
'func-name-matching': 'off',
170+
'func-names': 'off',
171+
'func-style': 'off',
172+
'id-blacklist': 'off',
173+
'id-length': 'off',
174+
'id-match': 'off',
175+
indent: 'off',
176+
'line-comment-position': 'off',
177+
'linebreak-style': 'off', // prettier --list-different
178+
'lines-around-comment': 'off',
179+
'lines-around-directive': 'off',
180+
'max-depth': 'off',
181+
'max-lines': 'off',
182+
'max-nested-callbacks': 'off',
183+
'max-params': 'off',
184+
'max-statements-per-line': 'off',
185+
'max-statements': 'off',
186+
'multiline-ternary': 'off',
187+
'new-cap': 'off',
188+
'newline-after-var': 'off',
189+
'newline-before-return': 'off',
190+
'newline-per-chained-call': 'off',
191+
'no-bitwise': 'error',
192+
'no-continue': 'off',
193+
'no-inline-comments': 'off',
194+
'no-mixed-operators': 'off',
197195
'no-negated-condition': 'off',
198196
'unicorn/no-negated-condition': 'error',
199-
'no-nested-ternary': 0,
200-
'no-new-object': 1,
201-
'no-plusplus': 0,
197+
'no-nested-ternary': 'off',
198+
'no-new-object': 'error',
199+
'no-plusplus': 'off',
202200
'no-restricted-syntax': [
203201
'error',
204202
{
@@ -215,34 +213,34 @@ module.exports = {
215213
message: 'Use `.key` instead of `.keyCode`',
216214
},
217215
],
218-
'no-ternary': 0,
219-
'no-underscore-dangle': 0,
220-
'no-unneeded-ternary': 0,
221-
'object-curly-newline': 0,
222-
'object-property-newline': 0,
223-
'one-var-declaration-per-line': 0,
224-
'one-var': [1, 'never'],
225-
'operator-assignment': 1,
226-
'operator-linebreak': 0,
227-
'require-jsdoc': 0,
228-
'sort-keys': 0,
229-
'sort-vars': 0,
216+
'no-ternary': 'off',
217+
'no-underscore-dangle': 'off',
218+
'no-unneeded-ternary': 'off',
219+
'object-curly-newline': 'off',
220+
'object-property-newline': 'off',
221+
'one-var-declaration-per-line': 'off',
222+
'one-var': ['error', 'never'],
223+
'operator-assignment': 'error',
224+
'operator-linebreak': 'off',
225+
'require-jsdoc': 'off',
226+
'sort-keys': 'off',
227+
'sort-vars': 'off',
230228
'spaced-comment': ['error', 'always', { markers: ['/'] }],
231-
'wrap-regex': 0,
229+
'wrap-regex': 'off',
232230
'unicorn/prefer-dom-node-remove': 'error',
233231
// ECMAScript 6 (http://eslint.org/docs/rules/#ecmascript-6)
234-
'arrow-body-style': 0,
235-
'no-duplicate-imports': 0,
236-
'no-restricted-imports': 0,
237-
'no-useless-computed-key': 1,
238-
'no-useless-constructor': 0,
239-
'no-useless-rename': 1,
240-
'object-shorthand': 1,
241-
'prefer-arrow-callback': [0, { allowNamedFunctions: true }], // prettier --list-different
242-
'prefer-numeric-literals': 0,
243-
'prefer-template': 0,
244-
'sort-imports': 0,
245-
'symbol-description': 1,
232+
'arrow-body-style': 'off',
233+
'no-duplicate-imports': 'off',
234+
'no-restricted-imports': 'off',
235+
'no-useless-computed-key': 'error',
236+
'no-useless-constructor': 'off',
237+
'no-useless-rename': 'error',
238+
'object-shorthand': 'error',
239+
'prefer-arrow-callback': ['off', { allowNamedFunctions: true }], // prettier --list-different
240+
'prefer-numeric-literals': 'off',
241+
'prefer-template': 'off',
242+
'sort-imports': 'off',
243+
'symbol-description': 'error',
246244

247245
'sonarjs/no-ignored-return': 'error',
248246
'unicorn/no-array-push-push': 'error',
@@ -258,7 +256,7 @@ module.exports = {
258256
'react/jsx-pascal-case': 'error',
259257
'react/no-did-mount-set-state': 'error',
260258
'react/no-did-update-set-state': 'error',
261-
'react/prop-types': 0,
259+
'react/prop-types': 'off',
262260
'react/prefer-es6-class': 'error',
263261
'react/prefer-stateless-function': 'error',
264262
'react/self-closing-comp': 'error',
@@ -298,6 +296,8 @@ module.exports = {
298296
'@typescript-eslint/no-unused-expressions': 'error',
299297
'sonarjs/no-small-switch': 'error',
300298
'sonarjs/no-duplicated-branches': 'error',
299+
'sonar/prefer-promise-shorthand': 'error',
300+
'sonar/no-dead-store': 'error',
301301
'unicorn/prefer-node-protocol': 'error',
302302
'import/no-unresolved': ['error', { ignore: ['^node:'] }],
303303
'unicorn/prefer-string-replace-all': 'error',
@@ -307,17 +307,16 @@ module.exports = {
307307
'unicorn/prefer-switch': 'error',
308308
'unicorn/prefer-dom-node-text-content': 'error',
309309
// TODO: Fix all errors for the following rules included in recommended config
310-
'@typescript-eslint/no-explicit-any': 'off',
311310
'@typescript-eslint/no-var-requires': 'off',
312-
'@typescript-eslint/no-non-null-assertion': 'off',
313-
'@typescript-eslint/ban-ts-comment': 'off',
314-
'@typescript-eslint/ban-types': 'off',
315-
'@typescript-eslint/no-empty-function': 'off',
316-
'@typescript-eslint/triple-slash-reference': 'off',
317-
'@typescript-eslint/no-namespace': 'off',
318311
},
319312

320-
plugins: ['promise', 'sonarjs', 'unicorn', '@arthurgeron/react-usememo'],
313+
plugins: [
314+
'promise',
315+
'sonarjs',
316+
'unicorn',
317+
'@arthurgeron/react-usememo',
318+
'sonar',
319+
],
321320
},
322321
{
323322
// Rules that requires type information
@@ -328,6 +327,14 @@ module.exports = {
328327
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
329328
'@typescript-eslint/no-floating-promises': 'error',
330329
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
330+
// TODO: Fix all errors for the following rules included in recommended config
331+
'@typescript-eslint/no-explicit-any': 'off',
332+
'@typescript-eslint/no-non-null-assertion': 'off',
333+
'@typescript-eslint/ban-ts-comment': 'off',
334+
'@typescript-eslint/ban-types': 'off',
335+
'@typescript-eslint/no-empty-function': 'off',
336+
'@typescript-eslint/triple-slash-reference': 'off',
337+
'@typescript-eslint/no-namespace': 'off',
331338
},
332339
parserOptions: {
333340
project: [
@@ -426,6 +433,7 @@ module.exports = {
426433
'react/jsx-no-undef': 'off',
427434
'react-hooks/rules-of-hooks': 'off',
428435
'@arthurgeron/react-usememo/require-usememo': 'off',
436+
'sonar/no-dead-store': 'off',
429437
},
430438
},
431439
],

0 commit comments

Comments
 (0)