From d2ffe2c80fed224ead7a51066bc514bb1bd9f1d7 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 1 Feb 2020 17:55:28 +0700 Subject: [PATCH] Require Node.js 10 --- .travis.yml | 1 - index.js | 1 + package.json | 11 +++++++---- readme.md | 6 +----- rules/no-zero-fractions.js | 18 ++++++++++++------ 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index ef24806f83..895f1970dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: node_js node_js: - '12' - '10' - - '8' cache: npm: false matrix: diff --git a/index.js b/index.js index 6a509a7320..5e23e2de64 100644 --- a/index.js +++ b/index.js @@ -54,6 +54,7 @@ module.exports = { 'unicorn/prefer-node-remove': 'error', 'unicorn/prefer-query-selector': 'error', 'unicorn/prefer-reflect-apply': 'error', + // TODO: Enable this by default when it's shipping in a Node.js LTS version. 'unicorn/prefer-replace-all': 'off', 'unicorn/prefer-spread': 'error', 'unicorn/prefer-starts-ends-with': 'error', diff --git a/package.json b/package.json index 666268c825..58d6fc794e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "url": "sindresorhus.com" }, "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { "test": "xo && nyc ava", @@ -48,7 +48,7 @@ "regexpp": "^3.0.0", "reserved-words": "^0.1.2", "safe-regex": "^2.1.1", - "semver": "^6.3.0" + "semver": "^7.1.2" }, "devDependencies": { "@lubien/fixture-beta-package": "^1.0.0-beta.1", @@ -60,10 +60,10 @@ "del": "^5.1.0", "eslint": "^6.8.0", "eslint-ava-rule-tester": "^4.0.0", - "eslint-plugin-eslint-plugin": "2.1.0", + "eslint-plugin-eslint-plugin": "^2.2.1", "execa": "^4.0.0", "listr": "^0.14.3", - "nyc": "^14.1.1", + "nyc": "^15.0.0", "outdent": "^0.7.0", "pify": "^4.0.1", "tempy": "^0.3.0", @@ -85,6 +85,9 @@ "extends": [ "plugin:eslint-plugin/all" ], + "rules": { + "prefer-named-capture-group": "off" + }, "overrides": [ { "files": "rules/utils/*.js", diff --git a/readme.md b/readme.md index 42f17d6ff6..d76c5830dc 100644 --- a/readme.md +++ b/readme.md @@ -8,14 +8,12 @@ You might want to check out [XO](https://github.com/xojs/xo), which includes thi [**Propose or contribute a new rule ➡**](.github/contributing.md) - ## Install ```console $ npm install --save-dev eslint eslint-plugin-unicorn ``` - ## Usage Configure it in `package.json`. @@ -87,7 +85,6 @@ Configure it in `package.json`. } ``` - ## Rules - [catch-error-name](docs/rules/catch-error-name.md) - Enforce a specific parameter name in catch clauses. @@ -160,15 +157,14 @@ See the [ESLint docs](http://eslint.org/docs/user-guide/configuring#extending-co **Note**: This config will also enable the correct [parser options](http://eslint.org/docs/user-guide/configuring#specifying-parser-options) and [environment](http://eslint.org/docs/user-guide/configuring#specifying-environments). - ## Maintainers - [Sindre Sorhus](https://github.com/sindresorhus) - [Adam Babcock](https://github.com/MrHen) - [futpib](https://github.com/futpib) -- [Sam Verschueren](https://github.com/SamVerschueren) - [Fisker Cheung](https://github.com/fisker) ###### Former - [Jeroen Engels](https://github.com/jfmengels) +- [Sam Verschueren](https://github.com/SamVerschueren) diff --git a/rules/no-zero-fractions.js b/rules/no-zero-fractions.js index ea793e0cfa..3e0f7c8e3b 100644 --- a/rules/no-zero-fractions.js +++ b/rules/no-zero-fractions.js @@ -5,11 +5,11 @@ const MESSAGE_ZERO_FRACTION = 'Don\'t use a zero fraction in the number.'; const MESSAGE_DANGLING_DOT = 'Don\'t use a dangling dot in the number.'; // Groups: -// 1. Integer part -// 2. Dangling dot or dot with zeroes -// 3. Dot with digits except last zeroes -// 4. Scientific notation -const RE_DANGLINGDOT_OR_ZERO_FRACTIONS = /^([+-]?\d*)(?:(\.0*)|(\.\d*[1-9])0+)(e[+-]?\d+)?$/; // TODO: Possibly use named capture groups when targeting Node.js 10 +// 1. Integer part. +// 2. Dangling dot or dot with zeroes. +// 3. Dot with digits except last zeroes. +// 4. Scientific notation. +const RE_DANGLINGDOT_OR_ZERO_FRACTIONS = /^(?[+-]?\d*)(?:(?\.0*)|(?\.\d*[1-9])0+)(?e[+-]?\d+)?$/; const create = context => { return { @@ -23,7 +23,13 @@ const create = context => { return; } - const [, integerPart, dotAndZeroes, dotAndDigits, scientificNotationSuffix] = match; + const { + integerPart, + dotAndZeroes, + dotAndDigits, + scientificNotationSuffix + } = match.groups; + const isDanglingDot = dotAndZeroes === '.'; context.report({