]> source.dussan.org Git - sonarqube.git/commitdiff
update eslint and plugins, add new rules (#3041)
authorStas Vilchik <stas.vilchik@sonarsource.com>
Fri, 9 Feb 2018 08:04:25 +0000 (09:04 +0100)
committerGitHub <noreply@github.com>
Fri, 9 Feb 2018 08:04:25 +0000 (09:04 +0100)
14 files changed:
server/sonar-web/.eslintrc
server/sonar-web/package.json
server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBranchesMenu.tsx
server/sonar-web/src/main/js/app/components/search/Search.js
server/sonar-web/src/main/js/apps/code/components/ComponentName.tsx
server/sonar-web/src/main/js/apps/tutorials/onboarding/AnalysisStep.js
server/sonar-web/src/main/js/apps/tutorials/onboarding/NewProjectForm.js
server/sonar-web/src/main/js/apps/tutorials/onboarding/Step.js
server/sonar-web/src/main/js/apps/tutorials/onboarding/commands/Command.js
server/sonar-web/src/main/js/components/charts/TreeMap.js
server/sonar-web/src/main/js/components/common/SelectListItem.js
server/sonar-web/src/main/js/components/issue/Issue.js
server/sonar-web/src/main/js/components/tags/TagsSelector.tsx
server/sonar-web/yarn.lock

index 00b12a8d6b484d92d66d57c14e0c3403492aff0f..16ebf9a4f53f6fded7e733bff48943bb3f9773ee 100644 (file)
     "no-return-await": "error",
     "no-self-compare": "error",
     "no-sequences": "error",
-    "no-throw-literal": "warn",
+    "no-throw-literal": "error",
     "no-unmodified-loop-condition": "error",
-    "no-unused-expressions": "warn",
+    "no-unused-expressions": "error",
     "no-useless-call": "error",
-    "no-useless-concat": "warn",
-    "no-useless-escape": "warn",
-    "no-useless-return": "warn",
+    "no-useless-concat": "error",
+    "no-useless-escape": "error",
+    "no-useless-return": "error",
     "no-void": "error",
     "no-with": "error",
     "radix": "error",
     "require-await": "error",
     "wrap-iife": "error",
-    "yoda": "warn",
+    "yoda": "error",
 
     // stylistic
     "camelcase": "warn",
 
     // react
     // TODO turn all rules to "error" eventually
+    "react/button-has-type": "warn",
     "react/display-name": "warn",
     "react/jsx-boolean-value": ["error", "always"],
     "react/jsx-no-comment-textnodes": "warn",
     "react/jsx-no-target-blank": "warn",
     "react/jsx-pascal-case": "error",
+    "react/jsx-sort-default-props": "warn",
+    "react/jsx-sort-props": "warn",
+    "react/no-access-state-in-setstate": "warn",
     "react/no-find-dom-node": "warn",
     "react/no-string-refs": "warn",
+    "react/no-this-in-sfc": "error",
     "react/self-closing-comp": "error",
     "react/sort-comp": [
       "error",
index 8089b41e56292115c064f8162be527ad41a850ac..8e3b92e311629636979300ea3e2626c93138c557 100644 (file)
     "enzyme": "3.3.0",
     "enzyme-adapter-react-16": "1.1.1",
     "enzyme-to-json": "3.3.0",
-    "eslint": "4.9.0",
+    "eslint": "4.17.0",
     "eslint-plugin-import": "2.8.0",
     "eslint-plugin-jsx-a11y": "6.0.2",
     "eslint-plugin-promise": "3.6.0",
-    "eslint-plugin-react": "7.4.0",
+    "eslint-plugin-react": "7.6.1",
     "expose-loader": "0.7.3",
     "extract-text-webpack-plugin": "3.0.1",
     "flow-bin": "^0.52.0",
     "style-loader": "0.19.0",
     "ts-jest": "22.0.1",
     "typescript": "2.6.2",
-    "typescript-eslint-parser": "11.0.0",
+    "typescript-eslint-parser": "12.0.0",
     "webpack": "3.8.1",
     "webpack-bundle-analyzer": "2.9.0",
     "webpack-dev-server": "2.9.3"
index 1a3034408185359d48c9a4af238d907a86948268..1ac0cc50ae903bf1abc5a9462426b57184109da4 100644 (file)
@@ -91,6 +91,8 @@ export default class ComponentNavBranchesMenu extends React.PureComponent<Props,
       case 40:
         event.preventDefault();
         this.selectNext();
+        // keep this return to prevent fall-through in case more cases will be adder later
+        // eslint-disable-next-line no-useless-return
         return;
     }
   };
index 069f84e67c8aee0aca706b427c06514ad65c648c..5912990d2560f6987283d7c8f9b548e9f8c5c0f5 100644 (file)
@@ -294,6 +294,8 @@ export default class Search extends React.PureComponent {
       case 40:
         event.preventDefault();
         this.selectNext();
+        // keep this return to prevent fall-through in case more cases will be adder later
+        // eslint-disable-next-line no-useless-return
         return;
     }
   };
index 7f43fc1ab50d746a60751402ab71d3b04efae2f6..7abb5e51a2d718662f485a842f9e6dcfae96b16e 100644 (file)
@@ -43,7 +43,7 @@ function mostCommitPrefix(strings: string[]) {
     i++;
   }
   const prefix = firstString.substr(0, i);
-  const prefixTokens = prefix.split(/[\s\\\/]/);
+  const prefixTokens = prefix.split(/[\s\\/]/);
   const lastPrefixPart = prefixTokens[prefixTokens.length - 1];
   return prefix.substr(0, prefix.length - lastPrefixPart.length);
 }
index 885ec7e275486aee5971b2bae4f1aaa7542ac8eb..05f71b3224b4694b0084194705146f63e57d3e18 100644 (file)
@@ -83,6 +83,8 @@ export default class AnalysisStep extends React.PureComponent {
   };
 
   renderFormattedCommand = (...lines /*: Array<string> */) => (
+    // keep this "useless" concatentation for the readability reason
+    // eslint-disable-next-line no-useless-concat
     <pre>{lines.join(' ' + '\\' + '\n' + '  ')}</pre>
   );
 
index 143e19e1fc948ecfb316df0a3afa15575faafdae..0e7a96a5b466803bdcee7d4b5a5fef5a0dad887e 100644 (file)
@@ -68,7 +68,7 @@ export default class NewProjectForm extends React.PureComponent {
     }
   };
 
-  sanitizeProjectKey = (projectKey /*: string */) => projectKey.replace(/[^a-zA-Z0-9-_\.:]/, '');
+  sanitizeProjectKey = (projectKey /*: string */) => projectKey.replace(/[^-_a-zA-Z0-9.:]/, '');
 
   handleProjectKeyChange = (event /*: { target: HTMLInputElement } */) => {
     this.setState({ projectKey: this.sanitizeProjectKey(event.target.value) });
index 49178149921ec31e96830e70188eca80b223c46d..572eb59b49bbbff946afbfcb76d1e89685b37656 100644 (file)
@@ -42,7 +42,7 @@ export default function Step(props /*: Props */) {
   const clickable = !props.open && props.finished;
 
   const handleClick = (event /*: Event */) => {
-    event.preventDefault;
+    event.preventDefault();
     props.onOpen();
   };
 
index ab46a73e512eefd9e8ce989537fafcd6c07d5835..5e3706585f2307ea0752765d0e135a3d13e2a4f4 100644 (file)
@@ -30,6 +30,8 @@ type Props = {
 };
 */
 
+// keep this "useless" concatentation for the readability reason
+// eslint-disable-next-line no-useless-concat
 const s = ' \\' + '\n  ';
 
 export default class Command extends React.PureComponent {
index f76b3f826db9c101e535900ab1ef183a7b318486..2b526fd0fe24920a1ba024c222bc4f19b12d579a 100644 (file)
@@ -53,7 +53,7 @@ export default class TreeMap extends React.PureComponent {
       i++;
     }
     const prefix = firstLabel.substr(0, i);
-    const prefixTokens = prefix.split(/[\s\\\/]/);
+    const prefixTokens = prefix.split(/[\s\\/]/);
     const lastPrefixPart = prefixTokens[prefixTokens.length - 1];
     return prefix.substr(0, prefix.length - lastPrefixPart.length);
   };
index e12f6f2af805bebd2227fc3477caa4dd125126fe..83926ea37df158b095833b3bccf07f3a6faa88bd 100644 (file)
@@ -38,11 +38,15 @@ export default class SelectListItem extends React.PureComponent {
 
   handleSelect = (evt /*: SyntheticInputEvent */) => {
     evt.preventDefault();
-    this.props.onSelect && this.props.onSelect(this.props.item);
+    if (this.props.onSelect) {
+      this.props.onSelect(this.props.item);
+    }
   };
 
   handleHover = () => {
-    this.props.onHover && this.props.onHover(this.props.item);
+    if (this.props.onHover) {
+      this.props.onHover(this.props.item);
+    }
   };
 
   renderLink() {
index d66c6e12814323d909988e479456613b2c02cafe..0100ba16b5b044aecd07f0ed815deccaa42beb36 100644 (file)
@@ -91,7 +91,9 @@ export default class Issue extends React.PureComponent {
       return false;
     });
     key('m', 'issues', () => {
-      this.props.issue.actions.includes('assign') && this.handleAssignement('_me');
+      if (this.props.issue.actions.includes('assign')) {
+        this.handleAssignement('_me');
+      }
       return false;
     });
     key('i', 'issues', () => {
index f9ed202989ced7e9533659831b912314898bea6b..82d42c93710fae3064485b313bbabbc4f93f1a31 100644 (file)
@@ -54,5 +54,5 @@ export default function TagsSelector(props: Props) {
 
 export function validateTag(value: string) {
   // Allow only a-z, 0-9, '+', '-', '#', '.'
-  return value.toLowerCase().replace(/[^a-z0-9\+\-#.]/gi, '');
+  return value.toLowerCase().replace(/[^-a-z0-9+#.]/gi, '');
 }
index 5c33dbc9e4756f1b3d3076c1f9691511da1114b0..550e6492815290a13cdc4c6491bef21f7e03437b 100644 (file)
@@ -175,6 +175,10 @@ acorn@^5.1.2:
   version "5.3.0"
   resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822"
 
+acorn@^5.4.0:
+  version "5.4.1"
+  resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.4.1.tgz#fdc58d9d17f4a4e98d102ded826a9b9759125102"
+
 add-dom-event-listener@1.x:
   version "1.0.2"
   resolved "https://registry.yarnpkg.com/add-dom-event-listener/-/add-dom-event-listener-1.0.2.tgz#8faed2c41008721cf111da1d30d995b85be42bed"
@@ -200,7 +204,7 @@ ajv@^4.9.1:
     co "^4.6.0"
     json-stable-stringify "^1.0.1"
 
-ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.2.0, ajv@^5.2.3:
+ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.2.3:
   version "5.3.0"
   resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.3.0.tgz#4414ff74a50879c208ee5fdc826e32c303549eda"
   dependencies:
@@ -209,6 +213,15 @@ ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.2.0, ajv@^5.2.3:
     fast-json-stable-stringify "^2.0.0"
     json-schema-traverse "^0.3.0"
 
+ajv@^5.3.0:
+  version "5.5.2"
+  resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"
+  dependencies:
+    co "^4.6.0"
+    fast-deep-equal "^1.0.0"
+    fast-json-stable-stringify "^2.0.0"
+    json-schema-traverse "^0.3.0"
+
 align-text@^0.1.1, align-text@^0.1.3:
   version "0.1.4"
   resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117"
@@ -2131,7 +2144,7 @@ debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.6, debug@^2.6.
   dependencies:
     ms "2.0.0"
 
-debug@^3.0.1, debug@^3.1.0:
+debug@^3.1.0:
   version "3.1.0"
   resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
   dependencies:
@@ -2301,12 +2314,11 @@ doctrine@1.5.0:
     esutils "^2.0.2"
     isarray "^1.0.0"
 
-doctrine@^2.0.0:
-  version "2.0.0"
-  resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.0.tgz#c73d8d2909d22291e1a007a395804da8b665fe63"
+doctrine@^2.0.2, doctrine@^2.1.0:
+  version "2.1.0"
+  resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
   dependencies:
     esutils "^2.0.2"
-    isarray "^1.0.0"
 
 dom-align@1.x:
   version "1.6.5"
@@ -2667,14 +2679,14 @@ eslint-plugin-promise@3.6.0:
   version "3.6.0"
   resolved "https://registry.yarnpkg.com/eslint-plugin-promise/-/eslint-plugin-promise-3.6.0.tgz#54b7658c8f454813dc2a870aff8152ec4969ba75"
 
-eslint-plugin-react@7.4.0:
-  version "7.4.0"
-  resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.4.0.tgz#300a95861b9729c087d362dd64abcc351a74364a"
+eslint-plugin-react@7.6.1:
+  version "7.6.1"
+  resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.6.1.tgz#5d0e908be599f0c02fbf4eef0c7ed6f29dff7633"
   dependencies:
-    doctrine "^2.0.0"
+    doctrine "^2.0.2"
     has "^1.0.1"
-    jsx-ast-utils "^2.0.0"
-    prop-types "^15.5.10"
+    jsx-ast-utils "^2.0.1"
+    prop-types "^15.6.0"
 
 eslint-scope@^3.7.1:
   version "3.7.1"
@@ -2683,32 +2695,36 @@ eslint-scope@^3.7.1:
     esrecurse "^4.1.0"
     estraverse "^4.1.1"
 
-eslint@4.9.0:
-  version "4.9.0"
-  resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.9.0.tgz#76879d274068261b191fe0f2f56c74c2f4208e8b"
+eslint-visitor-keys@^1.0.0:
+  version "1.0.0"
+  resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"
+
+eslint@4.17.0:
+  version "4.17.0"
+  resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.17.0.tgz#dc24bb51ede48df629be7031c71d9dc0ee4f3ddf"
   dependencies:
-    ajv "^5.2.0"
+    ajv "^5.3.0"
     babel-code-frame "^6.22.0"
     chalk "^2.1.0"
     concat-stream "^1.6.0"
     cross-spawn "^5.1.0"
-    debug "^3.0.1"
-    doctrine "^2.0.0"
+    debug "^3.1.0"
+    doctrine "^2.1.0"
     eslint-scope "^3.7.1"
-    espree "^3.5.1"
+    eslint-visitor-keys "^1.0.0"
+    espree "^3.5.2"
     esquery "^1.0.0"
-    estraverse "^4.2.0"
     esutils "^2.0.2"
     file-entry-cache "^2.0.0"
     functional-red-black-tree "^1.0.1"
     glob "^7.1.2"
-    globals "^9.17.0"
+    globals "^11.0.1"
     ignore "^3.3.3"
     imurmurhash "^0.1.4"
     inquirer "^3.0.6"
     is-resolvable "^1.0.0"
     js-yaml "^3.9.1"
-    json-stable-stringify "^1.0.1"
+    json-stable-stringify-without-jsonify "^1.0.1"
     levn "^0.3.0"
     lodash "^4.17.4"
     minimatch "^3.0.2"
@@ -2725,11 +2741,11 @@ eslint@4.9.0:
     table "^4.0.1"
     text-table "~0.2.0"
 
-espree@^3.5.1:
-  version "3.5.1"
-  resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.1.tgz#0c988b8ab46db53100a1954ae4ba995ddd27d87e"
+espree@^3.5.2:
+  version "3.5.3"
+  resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.3.tgz#931e0af64e7fbbed26b050a29daad1fc64799fa6"
   dependencies:
-    acorn "^5.1.1"
+    acorn "^5.4.0"
     acorn-jsx "^3.0.0"
 
 esprima@^2.6.0:
@@ -3320,7 +3336,11 @@ global-prefix@^1.0.1:
     is-windows "^1.0.1"
     which "^1.2.14"
 
-globals@^9.17.0, globals@^9.18.0:
+globals@^11.0.1:
+  version "11.3.0"
+  resolved "https://registry.yarnpkg.com/globals/-/globals-11.3.0.tgz#e04fdb7b9796d8adac9c8f64c14837b2313378b0"
+
+globals@^9.18.0:
   version "9.18.0"
   resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"
 
@@ -4535,6 +4555,10 @@ json-schema@0.2.3:
   version "0.2.3"
   resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"
 
+json-stable-stringify-without-jsonify@^1.0.1:
+  version "1.0.1"
+  resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"
+
 json-stable-stringify@^1.0.1:
   version "1.0.1"
   resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af"
@@ -4582,7 +4606,7 @@ jsx-ast-utils@^1.4.0:
   version "1.4.1"
   resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1"
 
-jsx-ast-utils@^2.0.0:
+jsx-ast-utils@^2.0.1:
   version "2.0.1"
   resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz#e801b1b39985e20fffc87b40e3748080e2dcac7f"
   dependencies:
@@ -7526,9 +7550,9 @@ typedarray@^0.0.6:
   version "0.0.6"
   resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
 
-typescript-eslint-parser@11.0.0:
-  version "11.0.0"
-  resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-11.0.0.tgz#37dba6a0130dd307504aa4b4b21b0d3dc7d4e9f2"
+typescript-eslint-parser@12.0.0:
+  version "12.0.0"
+  resolved "https://registry.yarnpkg.com/typescript-eslint-parser/-/typescript-eslint-parser-12.0.0.tgz#caea4b4e89e83f25765b310b924a03ba95a6dd19"
   dependencies:
     lodash.unescape "4.0.1"
     semver "5.4.1"