From 159e122942879cae66eb53bc14b835c5a5baf437 Mon Sep 17 00:00:00 2001 From: Damien Lebrun Date: Wed, 14 Sep 2016 11:46:09 +0100 Subject: [PATCH] Update eslint to 3.5.0 (and the linking command) --- .travis.yml | 2 +- docs/lint.md | 27 +++----- package.json | 8 +-- packages/eslint-config-singpath/README.md | 2 +- packages/eslint-config-singpath/default.yml | 66 ++++++++++++++------ packages/eslint-config-singpath/package.json | 5 +- 6 files changed, 67 insertions(+), 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4896978..da4c86f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ node_js: before_install: npm install script: - - npm run lint-no-fix + - npm run lint - npm run test - npm run coveralls diff --git a/docs/lint.md b/docs/lint.md index 2c6af3b..6749c41 100644 --- a/docs/lint.md +++ b/docs/lint.md @@ -11,7 +11,7 @@ npm run lint Install `eslint` and the set of default rules (`eslint-config-singpath`) and a plugin to handle html files: ```shell -npm install --save-dev eslint eslint-plugin-html eslint-config-singpath +npm install --save-dev eslint@3 eslint-plugin-html eslint-config-singpath ``` Setup a YAML or JSON encoded eslint config file: @@ -26,6 +26,7 @@ in the `scripts` object): { "scripts": { "lint": "eslint src/ index.html", + "format": "npm run lint -- --fix", "test": "bash ./tools/bin/test.sh" } } @@ -38,7 +39,7 @@ npm run lint To auto fix most formatting issue: ```shell -npm run lint -- --fix +npm run format ``` @@ -102,19 +103,8 @@ rules: - "never" ``` -Once the rules are stable, you can change the the lint command to: -```json -{ - "scripts": { - "lint": "eslint src/ index*.js --fix", - "lint-no-fix": "eslint src/ index*.js", - "test": "bash ./tools/bin/test.sh" - } -} -``` - -`npm run lint` will fix trivial errors (like trailing white spaces). The -`lint-no-fix` command could be used in git hook or a CI test. +`npm run format` will fix trivial errors (like trailing white spaces). The +`lint` command could be used in git hook or a CI test. ## Rule exceptions @@ -139,6 +129,9 @@ Or by disabling the rules: ## Precommit hook +To lint changes on commit, you can use a git pre-commit hook. npm "pre-commit" +module can setup it for you. + Install `pre-commit`: ``` npm install pre-commit --save-dev @@ -147,7 +140,7 @@ npm install pre-commit --save-dev Update `package.json` with: ```json { - "pre-commit": [ "lint-no-fix" ] + "pre-commit": [ "lint" ] } ``` @@ -158,7 +151,7 @@ Update `package.json` with: `packages/eslint-config-singpath`. The rules are defined in `default.yml`. Specific node or jspm settings are defined in `node.js` and `module.js`. -`default.yml` has each rule commented, included if it's recommended by eslint +`default.yml` has each rule commented; it emntion if it's recommended by eslint and if it's fixable (using `--fix` CLI option). To publish it: diff --git a/package.json b/package.json index c7a7174..a298a63 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "archiver": "^1.0.0", "babel-eslint": "^6.0.4", "coveralls": "^2.11.9", - "eslint": "^2.13.1", + "eslint": "^3.5.0", "eslint-plugin-babel": "^3.2.0", "eslint-plugin-html": "^1.5.1", "http-server": "^0.9.0", @@ -139,15 +139,15 @@ "clean": "node ./tools/bin/clean.js", "cover": "node ./tools/bin/cover.js", "coveralls": "node ./tools/bin/cover.js && cat ./coverage/lcov.info | coveralls", - "lint": "npm run lint-no-fix -- --fix", - "lint-no-fix": "eslint src/ packages/ tools/ index.html", + "format": "npm run lint -- --fix", + "lint": "eslint src/ packages/ tools/ index.html", "postinstall": "jspm install", "start": "http-server -c-1 -p 8000", "start:build": "http-server dist/ -c-1 -p 8000", "test": "node ./tools/bin/test.js" }, "pre-commit": [ - "lint-no-fix" + "lint" ], "repository": { "type": "git", diff --git a/packages/eslint-config-singpath/README.md b/packages/eslint-config-singpath/README.md index 653ac40..4ab23e5 100644 --- a/packages/eslint-config-singpath/README.md +++ b/packages/eslint-config-singpath/README.md @@ -11,7 +11,7 @@ Contains the default ESLint configuration for SingPath projects. You can install ESLint using npm: ```js -npm install eslint --save-dev +npm install eslint@3 --save-dev ``` Then install this configuration: diff --git a/packages/eslint-config-singpath/default.yml b/packages/eslint-config-singpath/default.yml index f793b11..c7ead4b 100644 --- a/packages/eslint-config-singpath/default.yml +++ b/packages/eslint-config-singpath/default.yml @@ -29,7 +29,7 @@ rules: no-ex-assign: error # disallow unnecessary boolean casts (recommended) no-extra-boolean-cast: error - # disallow unnecessary parentheses + # disallow unnecessary parentheses (fixable) no-extra-parens: 'off' # disallow unnecessary semicolons (recommended) (fixable) no-extra-semi: error @@ -41,8 +41,8 @@ rules: no-invalid-regexp: error # disallow irregular whitespace outside of strings and comments (recommended) no-irregular-whitespace: error - # disallow negating the left operand in `in` expressions (recommended) - no-negated-in-lhs: error + # disallow negating the left operand in `in` expressions (recommended) (deprecated) + no-negated-in-lhs: 'off' # disallow calling global object properties as functions (recommended) no-obj-calls: error # Disallow use of `Object.prototypes` builtins directly @@ -51,12 +51,16 @@ rules: no-regex-spaces: error # disallow sparse arrays (recommended) no-sparse-arrays: error + # Disallow template literal placeholder syntax in regular strings + no-template-curly-in-string: error # disallow confusing multiline expressions (recommended) no-unexpected-multiline: error # disallow unreachable code after `return`, `throw`, `continue`, and `break` statements (recommended) no-unreachable: error # disallow control flow statements in `finally` blocks (recommended) no-unsafe-finally: error + # disallow negating the left operand of relational operators (recommended) (fixable) + no-unsafe-negation: error # require calls to `isNaN()` when checking for `NaN` (recommended) use-isnan: error # enforce valid JSDoc comments @@ -84,7 +88,9 @@ rules: - next # enforce the use of variables within the scope they are defined block-scoped-var: 'off' - # enforce a maximum cyclomatic complexity allowed in a program + # enforce that class methods utilize `this` + class-methods-use-this: 'off' + # enforce a maximum cyclomatic complexity allowed in a program (recommended) complexity: - error - 20 @@ -100,7 +106,7 @@ rules: dot-location: - error - property - # enforce dot notation whenever possible + # enforce dot notation whenever possible (fixable) dot-notation: - error - allowKeywords: true @@ -136,9 +142,11 @@ rules: no-extra-label: 'off' # disallow fallthrough of `case` statements (recommended) no-fallthrough: error - # disallow leading or trailing decimal points in numeric literals + # disallow leading or trailing decimal points in numeric literals (fixable) no-floating-decimal: error - # disallow shorthand type conversions + # disallow assignments to native objects or read-only global variables (recommended) + no-global-assign: error + # disallow shorthand type conversions (fixable) no-implicit-coercion: 'off' # disallow `var` and named `function` declarations in the global scope no-implicit-globals: 'off' @@ -160,8 +168,8 @@ rules: no-multi-spaces: error # disallow multiline strings no-multi-str: error - # disallow reassigning native objects - no-native-reassign: error + # disallow reassigning native objects (recommended) (deprecated) + no-native-reassign: 'off' # disallow `new` operators outside of assignments or comparisons no-new: error # disallow `new` operators with the `Function` object @@ -284,6 +292,8 @@ rules: no-process-exit: error # disallow specified modules when loaded by `require` no-restricted-modules: 'off' + # disallow certain properties on certain objects + no-restricted-properties: 'off' # disallow synchronous methods no-sync: 'off' @@ -309,7 +319,7 @@ rules: comma-dangle: error # enforce consistent spacing before and after commas (fixable) comma-spacing: error - # enforce consistent comma style + # enforce consistent comma style (fixable) comma-style: - error - last @@ -321,6 +331,10 @@ rules: consistent-this: 'off' # enforce at least one newline at the end of files (fixable) eol-last: error + # require or disallow spacing between `function` identifiers and their invocations (fixable) + func-call-spacing: + - error + - never # require or disallow named `function` expressions func-names: 'off' # enforce the consistent use of either `function` declarations or expressions @@ -359,6 +373,10 @@ rules: afterLineComment: false beforeBlockComment: true beforeLineComment: true + # require or disallow newlines around directives + lines-around-directive: 'off' + # enforce position of line comments + line-comment-position: 'off' # enforce a maximum depth that blocks can be nested max-depth: 'off' # enforce a maximum line length @@ -376,16 +394,18 @@ rules: max-statements: 'off' # enforce a maximum number of statements allowed per line max-statements-per-line: 'off' + # enforce newlines between operands of ternary expressions + multiline-ternary: 'off' # require constructor `function` names to begin with a capital letter new-cap: - error - newIsCapExceptions: - controller - # require parentheses when invoking a constructor with no arguments + # require parentheses when invoking a constructor with no arguments (fixable) new-parens: error # require or disallow an empty line after `var` declarations newline-after-var: error - # require an empty line before `return` statements + # require an empty line before `return` statements (fixable) newline-before-return: 'off' # require a newline after each call in a method chain newline-per-chained-call: 'off' @@ -421,8 +441,10 @@ rules: no-plusplus: 'off' # disallow specified syntax no-restricted-syntax: 'off' - # disallow spacing between `function` identifiers and their applications (fixable) - no-spaced-func: error + # disallow spacing between `function` identifiers and their applications (fixable) (deprecated) + no-spaced-func: 'off' + # Disallow tabs in file + no-tabs: 'off' # disallow ternary operators no-ternary: 'off' # disallow trailing whitespace at the end of lines (fixable) @@ -477,6 +499,8 @@ rules: - error - after: true before: false + # requires object keys to be sorted + sort-keys: 'off' # require variables within the same declaration block to be sorted sort-vars: 'off' # enforce consistent spacing before blocks (fixable) @@ -502,7 +526,7 @@ rules: - '-' # require or disallow the Unicode BOM (fixable) unicode-bom: 'off' - # require parenthesis around regex literals + # require parenthesis around regex literals (fixable) wrap-regex: 'off' ## ECMAScript 6 @@ -511,7 +535,7 @@ rules: # # require braces around arrow function bodies arrow-body-style: 'off' - # require parentheses around arrow function arguments + # require parentheses around arrow function arguments (fixable) arrow-parens: 'off' # enforce consistent spacing before and after the arrow in arrow functions (fixable) arrow-spacing: 'off' @@ -541,14 +565,16 @@ rules: no-useless-constructor: 'off' # disallow renaming import, export, and destructured assignments to the same name (fixable) no-useless-rename: error - # require `let` or `const` instead of `var` + # require `let` or `const` instead of `var` (fixable) no-var: 'off' # require or disallow method and property shorthand syntax for object literals object-shorthand: 'off' - # require arrow functions as callbacks + # require arrow functions as callbacks (fixable) prefer-arrow-callback: 'off' - # require `const` declarations for variables that are never reassigned after declared + # require `const` declarations for variables that are never reassigned after declared (fixable) prefer-const: 'off' + # disallow `parseInt()` in favor of binary, octal, and hexadecimal literals + prefer-numeric-literals: error # require `Reflect` methods where applicable prefer-reflect: 'off' # require rest parameters instead of `arguments` @@ -563,6 +589,8 @@ rules: rest-spread-spacing: 'off' # enforce sorted import declarations within modules sort-imports: 'off' + # require symbol descriptions + symbol-description: error # require or disallow spacing around embedded expressions of template strings (fixable) template-curly-spacing: 'off' # require or disallow spacing around the `*` in `yield*` expressions (fixable) diff --git a/packages/eslint-config-singpath/package.json b/packages/eslint-config-singpath/package.json index aead817..e039e5f 100644 --- a/packages/eslint-config-singpath/package.json +++ b/packages/eslint-config-singpath/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-singpath", - "version": "0.0.4", + "version": "0.0.6", "main": "index.js", "author": "Chris Boesch", "description": "Default ESLint configuration for Singpath projects.", @@ -24,6 +24,9 @@ "dependencies": { "js-yaml": "^3.5.1" }, + "peerDependencies": { + "eslint": "^3.5.0" + }, "keywords": [ "singpathconfig", "eslint-config",