Skip to content

Commit

Permalink
[ESLint] enable sonar/prefer-promise-shorthand and `sonar/no-dead-s…
Browse files Browse the repository at this point in the history
…tore` rules (#3143)
  • Loading branch information
dimaMachina authored May 27, 2023
1 parent 7bf9092 commit 4c3a08b
Show file tree
Hide file tree
Showing 11 changed files with 355 additions and 176 deletions.
6 changes: 6 additions & 0 deletions .changeset/grumpy-experts-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'graphql-language-service-server': patch
'vscode-graphql-execution': patch
---

[ESLint] enable `sonar/prefer-promise-shorthand` and `sonar/no-dead-store` rules
5 changes: 5 additions & 0 deletions .changeset/hip-maps-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'vscode-graphql-execution': minor
---

`GraphQLContentProvider.getCurrentHtml` should not return `Promise`
292 changes: 150 additions & 142 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,93 +52,91 @@ module.exports = {
rules: {
'@arthurgeron/react-usememo/require-usememo': [
'error',
{
checkHookCalls: false,
},
{ checkHookCalls: false },
],
// Possible Errors (http://eslint.org/docs/rules/#possible-errors)
'no-console': 'error',
'no-constant-binary-expression': 2,
'no-empty': [1, { allowEmptyCatch: true }],
'no-extra-parens': 0,
'no-template-curly-in-string': 0,
'valid-jsdoc': 0,
'no-constant-binary-expression': 'error',
'no-empty': ['error', { allowEmptyCatch: true }],
'no-extra-parens': 'off',
'no-template-curly-in-string': 'off',
'valid-jsdoc': 'off',

// Best Practices (http://eslint.org/docs/rules/#best-practices)
'accessor-pairs': 1,
'array-callback-return': 0,
'block-scoped-var': 0,
'class-methods-use-this': 0,
complexity: 0,
'consistent-return': 0,
curly: 1,
'default-case': 0,
'dot-notation': 1,
eqeqeq: [1, 'allow-null'],
'guard-for-in': 0,
'accessor-pairs': 'error',
'array-callback-return': 'off',
'block-scoped-var': 'off',
'class-methods-use-this': 'off',
complexity: 'off',
'consistent-return': 'off',
curly: 'error',
'default-case': 'off',
'dot-notation': 'error',
eqeqeq: ['error', 'allow-null'],
'guard-for-in': 'off',
'no-alert': 'error',
'no-await-in-loop': 1,
'no-caller': 1,
'no-case-declarations': 0,
'no-div-regex': 1,
'no-await-in-loop': 'error',
'no-caller': 'error',
'no-case-declarations': 'off',
'no-div-regex': 'error',
'no-else-return': ['error', { allowElseIf: false }],
'no-eq-null': 0,
'no-eval': 1,
'no-extend-native': 1,
'no-extra-bind': 1,
'no-extra-label': 1,
'no-floating-decimal': 0, // prettier --list-different
'no-implicit-coercion': 1,
'no-implicit-globals': 0,
'no-implied-eval': 1,
'no-invalid-this': 0,
'no-iterator': 1,
'no-labels': 1,
'no-lone-blocks': 1,
'no-loop-func': 0,
'no-magic-numbers': 0,
'no-multi-str': 0,
'no-new-func': 1,
'no-new-wrappers': 1,
'no-eq-null': 'off',
'no-eval': 'error',
'no-extend-native': 'error',
'no-extra-bind': 'error',
'no-extra-label': 'error',
'no-floating-decimal': 'off', // prettier --list-different
'no-implicit-coercion': 'error',
'no-implicit-globals': 'off',
'no-implied-eval': 'error',
'no-invalid-this': 'off',
'no-iterator': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-loop-func': 'off',
'no-magic-numbers': 'off',
'no-multi-str': 'off',
'no-new-func': 'error',
'no-new-wrappers': 'error',
'no-new': 'error',
'no-octal-escape': 1,
'no-param-reassign': 1,
'no-proto': 1,
'no-restricted-properties': 0,
'no-return-assign': 1,
'no-return-await': 1,
'no-script-url': 1,
'no-self-compare': 1,
'no-sequences': 1,
'no-octal-escape': 'error',
'no-param-reassign': 'error',
'no-proto': 'error',
'no-restricted-properties': 'off',
'no-return-assign': 'error',
'no-return-await': 'error',
'no-script-url': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-throw-literal': 'error',
'no-unmodified-loop-condition': 0,
'no-useless-call': 1,
'no-useless-concat': 1,
'no-useless-return': 0,
'no-unmodified-loop-condition': 'off',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-return': 'off',
'@typescript-eslint/prefer-optional-chain': 'error',
'no-warning-comments': 0,
'no-warning-comments': 'off',
radix: 'error',
'require-await': 0,
'vars-on-top': 0,
yoda: 1,
'require-await': 'off',
'vars-on-top': 'off',
yoda: 'error',
'unicorn/prefer-string-slice': 'error',
'sonarjs/no-identical-functions': 'error',
'sonarjs/no-unused-collection': 'error',
'sonarjs/no-extra-arguments': 'error',
'unicorn/no-useless-undefined': 'error',
'no-var': 'error',
// Strict Mode (http://eslint.org/docs/rules/#strict-mode)
strict: 0,
strict: 'off',

// Variables (http://eslint.org/docs/rules/#variables)
'init-declarations': 0,
'no-catch-shadow': 1,
'no-label-var': 1,
'no-restricted-globals': 0,
'init-declarations': 'off',
'no-catch-shadow': 'error',
'no-label-var': 'error',
'no-restricted-globals': 'off',
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
'no-undef-init': 0,
'no-undefined': 0,
'no-undef-init': 'off',
'no-undefined': 'off',

'@typescript-eslint/no-unused-vars': [
'error',
Expand All @@ -149,56 +147,56 @@ module.exports = {
},
],

'no-use-before-define': 0,
'no-use-before-define': 'off',

'unicorn/no-useless-switch-case': 'error',
// Node.js and CommonJS (http://eslint.org/docs/rules/#nodejs-and-commonjs)
'callback-return': 0,
'global-require': 0,
'handle-callback-err': 1,
'no-mixed-requires': 1,
'no-new-require': 1,
'no-path-concat': 1,
'no-process-env': 0,
'no-process-exit': 0,
'no-restricted-modules': 0,
'no-sync': 0,
'callback-return': 'off',
'global-require': 'off',
'handle-callback-err': 'error',
'no-mixed-requires': 'error',
'no-new-require': 'error',
'no-path-concat': 'error',
'no-process-env': 'off',
'no-process-exit': 'off',
'no-restricted-modules': 'off',
'no-sync': 'off',

// Stylistic Issues (http://eslint.org/docs/rules/#stylistic-issues)
camelcase: 0,
'capitalized-comments': 0,
'consistent-this': 0,
'func-name-matching': 0,
'func-names': 0,
'func-style': 0,
'id-blacklist': 0,
'id-length': 0,
'id-match': 0,
indent: 0,
'line-comment-position': 0,
'linebreak-style': 0, // prettier --list-different
'lines-around-comment': 0,
'lines-around-directive': 0,
'max-depth': 0,
'max-lines': 0,
'max-nested-callbacks': 0,
'max-params': 0,
'max-statements-per-line': 0,
'max-statements': 0,
'multiline-ternary': 0,
'new-cap': 0,
'newline-after-var': 0,
'newline-before-return': 0,
'newline-per-chained-call': 0,
'no-bitwise': 1,
'no-continue': 0,
'no-inline-comments': 0,
'no-mixed-operators': 0,
camelcase: 'off',
'capitalized-comments': 'off',
'consistent-this': 'off',
'func-name-matching': 'off',
'func-names': 'off',
'func-style': 'off',
'id-blacklist': 'off',
'id-length': 'off',
'id-match': 'off',
indent: 'off',
'line-comment-position': 'off',
'linebreak-style': 'off', // prettier --list-different
'lines-around-comment': 'off',
'lines-around-directive': 'off',
'max-depth': 'off',
'max-lines': 'off',
'max-nested-callbacks': 'off',
'max-params': 'off',
'max-statements-per-line': 'off',
'max-statements': 'off',
'multiline-ternary': 'off',
'new-cap': 'off',
'newline-after-var': 'off',
'newline-before-return': 'off',
'newline-per-chained-call': 'off',
'no-bitwise': 'error',
'no-continue': 'off',
'no-inline-comments': 'off',
'no-mixed-operators': 'off',
'no-negated-condition': 'off',
'unicorn/no-negated-condition': 'error',
'no-nested-ternary': 0,
'no-new-object': 1,
'no-plusplus': 0,
'no-nested-ternary': 'off',
'no-new-object': 'error',
'no-plusplus': 'off',
'no-restricted-syntax': [
'error',
{
Expand All @@ -215,34 +213,34 @@ module.exports = {
message: 'Use `.key` instead of `.keyCode`',
},
],
'no-ternary': 0,
'no-underscore-dangle': 0,
'no-unneeded-ternary': 0,
'object-curly-newline': 0,
'object-property-newline': 0,
'one-var-declaration-per-line': 0,
'one-var': [1, 'never'],
'operator-assignment': 1,
'operator-linebreak': 0,
'require-jsdoc': 0,
'sort-keys': 0,
'sort-vars': 0,
'no-ternary': 'off',
'no-underscore-dangle': 'off',
'no-unneeded-ternary': 'off',
'object-curly-newline': 'off',
'object-property-newline': 'off',
'one-var-declaration-per-line': 'off',
'one-var': ['error', 'never'],
'operator-assignment': 'error',
'operator-linebreak': 'off',
'require-jsdoc': 'off',
'sort-keys': 'off',
'sort-vars': 'off',
'spaced-comment': ['error', 'always', { markers: ['/'] }],
'wrap-regex': 0,
'wrap-regex': 'off',
'unicorn/prefer-dom-node-remove': 'error',
// ECMAScript 6 (http://eslint.org/docs/rules/#ecmascript-6)
'arrow-body-style': 0,
'no-duplicate-imports': 0,
'no-restricted-imports': 0,
'no-useless-computed-key': 1,
'no-useless-constructor': 0,
'no-useless-rename': 1,
'object-shorthand': 1,
'prefer-arrow-callback': [0, { allowNamedFunctions: true }], // prettier --list-different
'prefer-numeric-literals': 0,
'prefer-template': 0,
'sort-imports': 0,
'symbol-description': 1,
'arrow-body-style': 'off',
'no-duplicate-imports': 'off',
'no-restricted-imports': 'off',
'no-useless-computed-key': 'error',
'no-useless-constructor': 'off',
'no-useless-rename': 'error',
'object-shorthand': 'error',
'prefer-arrow-callback': ['off', { allowNamedFunctions: true }], // prettier --list-different
'prefer-numeric-literals': 'off',
'prefer-template': 'off',
'sort-imports': 'off',
'symbol-description': 'error',

'sonarjs/no-ignored-return': 'error',
'unicorn/no-array-push-push': 'error',
Expand All @@ -258,7 +256,7 @@ module.exports = {
'react/jsx-pascal-case': 'error',
'react/no-did-mount-set-state': 'error',
'react/no-did-update-set-state': 'error',
'react/prop-types': 0,
'react/prop-types': 'off',
'react/prefer-es6-class': 'error',
'react/prefer-stateless-function': 'error',
'react/self-closing-comp': 'error',
Expand Down Expand Up @@ -298,6 +296,8 @@ module.exports = {
'@typescript-eslint/no-unused-expressions': 'error',
'sonarjs/no-small-switch': 'error',
'sonarjs/no-duplicated-branches': 'error',
'sonar/prefer-promise-shorthand': 'error',
'sonar/no-dead-store': 'error',
'unicorn/prefer-node-protocol': 'error',
'import/no-unresolved': ['error', { ignore: ['^node:'] }],
'unicorn/prefer-string-replace-all': 'error',
Expand All @@ -307,17 +307,16 @@ module.exports = {
'unicorn/prefer-switch': 'error',
'unicorn/prefer-dom-node-text-content': 'error',
// TODO: Fix all errors for the following rules included in recommended config
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-namespace': 'off',
},

plugins: ['promise', 'sonarjs', 'unicorn', '@arthurgeron/react-usememo'],
plugins: [
'promise',
'sonarjs',
'unicorn',
'@arthurgeron/react-usememo',
'sonar',
],
},
{
// Rules that requires type information
Expand All @@ -328,6 +327,14 @@ module.exports = {
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/non-nullable-type-assertion-style': 'error',
// TODO: Fix all errors for the following rules included in recommended config
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/triple-slash-reference': 'off',
'@typescript-eslint/no-namespace': 'off',
},
parserOptions: {
project: [
Expand Down Expand Up @@ -426,6 +433,7 @@ module.exports = {
'react/jsx-no-undef': 'off',
'react-hooks/rules-of-hooks': 'off',
'@arthurgeron/react-usememo/require-usememo': 'off',
'sonar/no-dead-store': 'off',
},
},
],
Expand Down
Loading

0 comments on commit 4c3a08b

Please sign in to comment.