Skip to content

Commit

Permalink
feat(eslint-config): only enable eslint-plugin-sonar with typescript …
Browse files Browse the repository at this point in the history
…available
  • Loading branch information
JounQin committed Jun 17, 2021
1 parent e974202 commit 0506b89
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 39 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/react": "^17.0.11",
"@types/unist": "^2.0.3",
"core-js": "^3.14.0",
"postcss": "^8.3.4",
"postcss": "^8.3.5",
"react": "^17.0.2",
"rxjs": "^7.1.0",
"svelte": "^3.38.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@pkgr/es-modules": "^0.4.2",
"@pkgr/imagemin": "^1.0.1",
"browserslist": "^4.16.6",
"postcss": "^8.3.4",
"postcss": "^8.3.5",
"stylelint": "^13.13.1"
},
"publishConfig": {
Expand Down
7 changes: 4 additions & 3 deletions packages/eslint-config/base.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { isTsAvailable } = require('@pkgr/utils')
const { getGlobals } = require('eslint-plugin-mdx')

const { isWebpackAvailable, magicNumbers, webpackSpecVars } = require('./_util')
Expand All @@ -10,11 +11,11 @@ module.exports = {
'plugin:node/recommended',
'plugin:promise/recommended',
'plugin:sonarjs/recommended',
'plugin:sonar/recommended',
isTsAvailable && 'plugin:sonar/recommended',
'plugin:unicorn/recommended',
'standard',
'plugin:prettier/recommended',
],
].filter(Boolean),
globals: isWebpackAvailable ? getGlobals(webpackSpecVars) : undefined,
rules: {
'arrow-body-style': 2,
Expand Down Expand Up @@ -53,7 +54,7 @@ module.exports = {
},
],
'no-empty-function': 2,
'no-labels': 0, // sonar/no-labels
'no-labels': isTsAvailable ? 2 : 0, // sonar/no-labels
'no-magic-numbers': [
2,
{
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ exports.react = [
eventHandlerPropPrefix: 'on',
},
],
'sonar/function-name': [2, { format: '^_?[a-zA-Z][a-zA-Z0-9]*\\$?$' }],
'sonar/function-name': isTsAvailable
? [2, { format: '^_?[a-zA-Z][a-zA-Z0-9]*\\$?$' }]
: 0,
},
...reactJsx,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-sonar": "^0.5.1",
"eslint-plugin-sonar": "^0.6.0",
"eslint-plugin-sonarjs": "^0.8.0-125",
"eslint-plugin-svelte": "^1.1.2",
"eslint-plugin-unicorn": "^33.0.1",
Expand Down
50 changes: 18 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
semver "^6.3.0"
source-map "^0.5.0"

"@babel/eslint-parser@^7.0.0", "@babel/eslint-parser@^7.12.16", "@babel/eslint-parser@^7.14.5":
"@babel/eslint-parser@^7.12.16", "@babel/eslint-parser@^7.14.5":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.14.5.tgz#441c04e2fe9825ea628c2b4e5524d40129cbbccd"
integrity sha512-20BlOHuGf3UXS7z1QPyllM9Gz8SEgcp/UcKeUmdHIFZO6HF1n+3KaLpeyfwWvjY/Os/ynPX3k8qXE/nZ5dw/0g==
Expand Down Expand Up @@ -2477,7 +2477,7 @@
"@typescript-eslint/experimental-utils" "4.27.0"
lodash "^4.17.21"

"@typescript-eslint/eslint-plugin@^4.0.0", "@typescript-eslint/eslint-plugin@^4.27.0":
"@typescript-eslint/eslint-plugin@^4.27.0":
version "4.27.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.27.0.tgz#0b7fc974e8bc9b2b5eb98ed51427b0be529b4ad0"
integrity sha512-DsLqxeUfLVNp3AO7PC3JyaddmEHTtI9qTSAs+RB6ja27QvIM0TA8Cizn1qcS6vOu+WDLFJzkwkgweiyFhssDdQ==
Expand All @@ -2503,7 +2503,7 @@
eslint-scope "^5.0.0"
eslint-utils "^2.0.0"

"@typescript-eslint/experimental-utils@4.27.0", "@typescript-eslint/experimental-utils@^4.0.0", "@typescript-eslint/experimental-utils@^4.0.1":
"@typescript-eslint/experimental-utils@4.27.0", "@typescript-eslint/experimental-utils@^4.0.1":
version "4.27.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.27.0.tgz#78192a616472d199f084eab8f10f962c0757cd1c"
integrity sha512-n5NlbnmzT2MXlyT+Y0Jf0gsmAQzCnQSWXKy4RGSXVStjDvS5we9IWbh7qRVKdGcxT0WYlgcCYUK/HRg7xFhvjQ==
Expand All @@ -2515,7 +2515,7 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"

"@typescript-eslint/parser@^4.0.0", "@typescript-eslint/parser@^4.27.0":
"@typescript-eslint/parser@^4.27.0":
version "4.27.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.27.0.tgz#85447e573364bce4c46c7f64abaa4985aadf5a94"
integrity sha512-XpbxL+M+gClmJcJ5kHnUpBGmlGdgNvy6cehgR6ufyxkEJMGP25tZKCaKyC0W/JVpuhU3VU1RBn7SYUPKSMqQvQ==
Expand Down Expand Up @@ -3525,12 +3525,12 @@ builtin-modules@^1.1.1:
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"
integrity sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=

builtin-modules@^3.0.0, builtin-modules@^3.1.0:
builtin-modules@^3.0.0, builtin-modules@^3.1.0, builtin-modules@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-3.2.0.tgz#45d5db99e7ee5e6bc4f362e008bf917ab5049887"
integrity sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==

bytes@^3.0.0:
bytes@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6"
integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==
Expand Down Expand Up @@ -5130,11 +5130,6 @@ eslint-module-utils@^2.6.1:
debug "^3.2.7"
pkg-dir "^2.0.0"

"eslint-plugin-chai-friendly@^0.5.0 || ^0.6.0":
version "0.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-chai-friendly/-/eslint-plugin-chai-friendly-0.6.0.tgz#54052fab79302ed0cea76ab997351ea4809bfb77"
integrity sha512-Uvvv1gkbRGp/qfN15B0kQyQWg+oFA8buDSqrwmW3egNSk/FpqH2MjQqKOuKwmEL6w4QIQrIjDp+gg6kGGmD3oQ==

eslint-plugin-es@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz#75a7cdfdccddc0589934aeeb384175f221c57893"
Expand Down Expand Up @@ -5265,24 +5260,15 @@ eslint-plugin-react@^7.24.0:
resolve "^2.0.0-next.3"
string.prototype.matchall "^4.0.5"

eslint-plugin-sonar@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-sonar/-/eslint-plugin-sonar-0.5.1.tgz#77e4450ce817c0aec1d57a1de875d5ac6f03983b"
integrity sha512-1aXXAwu7bzJ5j+jG3wGGI7OMW1w8U76ovVwBx6arqa0GndUhPXSZrnWbyW+zvRFLykJQiyL+pXYktGBVb9Es4w==
dependencies:
"@babel/eslint-parser" "^7.0.0"
"@typescript-eslint/eslint-plugin" "^4.0.0"
"@typescript-eslint/experimental-utils" "^4.0.0"
"@typescript-eslint/parser" "^4.0.0"
builtin-modules "^3.0.0"
bytes "^3.0.0"
eslint-plugin-chai-friendly "^0.5.0 || ^0.6.0"
eslint-plugin-sonarjs "^0.6.0"

eslint-plugin-sonarjs@^0.6.0:
eslint-plugin-sonar@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.6.0.tgz#3ee3b04f1f9587ef02b255a5d2f96e500c4789bb"
integrity sha512-y+sXXWsYVW2kNEjmZI87laFspwC/hic7wyMjsPFoST8aQ2hESUVavkZjnTeVdHMOmlmcloKkyX/GJJetmfBY4Q==
resolved "https://registry.yarnpkg.com/eslint-plugin-sonar/-/eslint-plugin-sonar-0.6.0.tgz#654d33313f54769a78318f3c741d9f0ed78fd94a"
integrity sha512-/QcSjh0wtOAEzkMAbuwMx4czWsoq9dMCwKqYlIe8tiTRJwyQqunA918KmV5LusJtYJRzuECxlv4FxCMw64EzPQ==
dependencies:
"@babel/eslint-parser" "^7.14.5"
builtin-modules "^3.2.0"
bytes "^3.1.0"
eslint-plugin-sonarjs "^0.8.0-125"

eslint-plugin-sonarjs@^0.8.0-125:
version "0.8.0-125"
Expand Down Expand Up @@ -10160,10 +10146,10 @@ postcss@^7.0.0, postcss@^7.0.1, postcss@^7.0.14, postcss@^7.0.17, postcss@^7.0.2
source-map "^0.6.1"
supports-color "^6.1.0"

postcss@^8.1.10, postcss@^8.1.4, postcss@^8.2.4, postcss@^8.3.4:
version "8.3.4"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.4.tgz#41ece1c43f2f7c74dc7d90144047ce052757b822"
integrity sha512-/tZY0PXExXXnNhKv3TOvZAOUYRyuqcCbBm2c17YMDK0PlVII3K7/LKdt3ScHL+hhouddjUWi+1sKDf9xXW+8YA==
postcss@^8.1.10, postcss@^8.1.4, postcss@^8.2.4, postcss@^8.3.5:
version "8.3.5"
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.5.tgz#982216b113412bc20a86289e91eb994952a5b709"
integrity sha512-NxTuJocUhYGsMiMFHDUkmjSKT3EdH4/WbGF6GCi1NDGk+vbcUTun4fpbOqaPtD8IIsztA2ilZm2DhYCuyN58gA==
dependencies:
colorette "^1.2.2"
nanoid "^3.1.23"
Expand Down

0 comments on commit 0506b89

Please sign in to comment.