]> source.dussan.org Git - sonarqube.git/commitdiff
add eslint-plugin-sonarjs (#153)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Tue, 17 Apr 2018 12:25:25 +0000 (14:25 +0200)
committerSonarTech <sonartech@sonarsource.com>
Tue, 17 Apr 2018 18:20:48 +0000 (20:20 +0200)
server/sonar-vsts/.eslintrc
server/sonar-vsts/package.json
server/sonar-vsts/yarn.lock
server/sonar-web/.eslintrc
server/sonar-web/package.json
server/sonar-web/src/main/js/apps/permissions/shared/store/filter.js
server/sonar-web/src/main/js/apps/permissions/shared/store/selectedPermission.js
server/sonar-web/yarn.lock

index 298cd8bbc893a410dadaed3d3acafca1675dcdf2..ddca3b05c683ca459794a92ab5a26a26616e42f4 100644 (file)
@@ -4,7 +4,8 @@
     "plugin:import/errors",
     "plugin:react/recommended",
     "plugin:jsx-a11y/recommended",
-    "plugin:promise/recommended"
+    "plugin:promise/recommended",
+    "plugin:sonarjs/recommended"
   ],
 
   "env": {
@@ -25,7 +26,7 @@
 
   "parser": "typescript-eslint-parser",
 
-  "plugins": ["import", "jsx-a11y", "react", "promise"],
+  "plugins": ["import", "jsx-a11y", "react", "promise", "sonarjs"],
 
   "rules": {
     // possible errors
     "promise/catch-or-return": ["warn", { "allowThen": true }],
 
     "promise/always-return": "off",
-    "promise/avoid-new": "off"
+    "promise/avoid-new": "off",
+
+    // sonarjs
+    "sonarjs/cognitive-complexity": "warn",
+    "sonarjs/no-identical-functions": "warn"
   },
 
   "settings": {
index 2ad9444fa637207f6a45878a61ba9e5928081b58..9a06101442035cfab15eba3b82fbfc48a476308a 100644 (file)
@@ -46,6 +46,7 @@
     "eslint-plugin-jsx-a11y": "6.0.2",
     "eslint-plugin-promise": "3.6.0",
     "eslint-plugin-react": "7.6.1",
+    "eslint-plugin-sonarjs": "0.1.0",
     "html-webpack-plugin": "3.0.6",
     "jest": "22.0.6",
     "postcss-calc": "6.0.1",
index 1fad7fa5983e594d5349044d5fc6fd10cde07081..5d03d335354d84855ed3730092fbd1852d893cdc 100644 (file)
@@ -2479,6 +2479,10 @@ eslint-plugin-react@7.6.1:
     jsx-ast-utils "^2.0.1"
     prop-types "^15.6.0"
 
+eslint-plugin-sonarjs@0.1.0:
+  version "0.1.0"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.1.0.tgz#fedf6e67296c30470002c48d10a701d69e40af8a"
+
 eslint-scope@^3.7.1:
   version "3.7.1"
   resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
@@ -7607,4 +7611,3 @@ yargs@~3.10.0:
     cliui "^2.1.0"
     decamelize "^1.0.0"
     window-size "0.1.0"
-
index 2e02ba0490f00df708f57bdf33cfe043bda77993..e03bc7b4c637ab376fea6854cfc9588a0114c4b8 100644 (file)
@@ -4,7 +4,8 @@
     "plugin:import/errors",
     "plugin:react/recommended",
     "plugin:jsx-a11y/recommended",
-    "plugin:promise/recommended"
+    "plugin:promise/recommended",
+    "plugin:sonarjs/recommended"
   ],
 
   "env": {
@@ -30,7 +31,7 @@
 
   "parser": "typescript-eslint-parser",
 
-  "plugins": ["import", "jsx-a11y", "react", "promise"],
+  "plugins": ["import", "jsx-a11y", "react", "promise", "sonarjs"],
 
   "rules": {
     // possible errors
     "promise/catch-or-return": ["warn", { "allowThen": true }],
 
     "promise/always-return": "off",
-    "promise/avoid-new": "off"
+    "promise/avoid-new": "off",
+
+    // sonarjs
+    "sonarjs/cognitive-complexity": "warn",
+    "sonarjs/no-identical-functions": "warn"
   },
 
   "settings": {
index 78e0324d5a36ad9a41d2ec757cdde5f11a4dcf58..113fc9abe2541ffc317643f16543309aa5386257 100644 (file)
@@ -82,6 +82,7 @@
     "eslint-plugin-jsx-a11y": "6.0.2",
     "eslint-plugin-promise": "3.6.0",
     "eslint-plugin-react": "7.6.1",
+    "eslint-plugin-sonarjs": "0.1.0",
     "expose-loader": "0.7.5",
     "flow-bin": "^0.52.0",
     "html-webpack-plugin": "3.0.6",
index c665d74a979f56ceb57f34acf1e585dfc991b0b8..9c9fcf464b183b70111b4ee358609867f5f00cee 100644 (file)
 import { UPDATE_FILTER } from './actions';
 
 const filter = (state = 'all', action = {}) => {
-  switch (action.type) {
-    case UPDATE_FILTER:
-      return action.filter;
-    default:
-      return state;
+  if (action.type === UPDATE_FILTER) {
+    return action.filter;
   }
+  return state;
 };
 
 export default filter;
index 8eec8057c71bfbcf6eb7f4bf457215a906abf8cd..4a0e4496deb2c091d77716f795e61920b754a195 100644 (file)
 import { SELECT_PERMISSION } from './actions';
 
 const selectedPermission = (state = null, action = {}) => {
-  switch (action.type) {
-    case SELECT_PERMISSION:
-      return action.permission;
-    default:
-      return state;
+  if (action.type === SELECT_PERMISSION) {
+    return action.permission;
   }
+  return state;
 };
 
 export default selectedPermission;
index ad4e577368c20e57020e524de97fcd215fe137f9..a2087e788b9d18a7b9acb9093d532823736bf2cb 100644 (file)
@@ -2677,6 +2677,10 @@ eslint-plugin-react@7.6.1:
     jsx-ast-utils "^2.0.1"
     prop-types "^15.6.0"
 
+eslint-plugin-sonarjs@0.1.0:
+  version "0.1.0"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.1.0.tgz#fedf6e67296c30470002c48d10a701d69e40af8a"
+
 eslint-scope@^3.7.1:
   version "3.7.1"
   resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"