From 93d082cce48da79bf7305df70e4fd0061b482e88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=96=9B=E5=AE=9A=E8=B0=94=E7=9A=84=E7=8C=AB?= Date: Wed, 8 Apr 2020 23:07:07 +0800 Subject: [PATCH 1/4] Upgrade: eslint and other deps (#92) * Upgrade: eslint v6 * Upgrade: eslint v7 * Fix: no-deprecated-report-api error * Fix: require-meta-fixable reported error --- .eslintrc.yml | 5 +++++ package.json | 10 +++++----- tests/lib/rules/no-deprecated-report-api.js | 2 +- tests/lib/rules/require-meta-fixable.js | 4 ++-- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 92759fea..07136078 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -7,6 +7,11 @@ extends: - plugin:self/all root: true rules: + comma-dangle: + - error + - arrays: always-multiline + objects: always-multiline + functions: never # disallow trailing commas in function(es2017) require-jsdoc: error self/meta-property-ordering: off self/require-meta-docs-url: off diff --git a/package.json b/package.json index 38ba0c15..6295b8ae 100644 --- a/package.json +++ b/package.json @@ -34,14 +34,14 @@ "chai": "^4.1.0", "dirty-chai": "^2.0.1", "escope": "^3.6.0", - "eslint": "^5.9.0", + "eslint": "^7.0.0-alpha.3", "eslint-config-not-an-aardvark": "^2.1.0", - "eslint-plugin-node": "^8.0.0", + "eslint-plugin-node": "^11.1.0", "eslint-plugin-self": "^1.0.1", - "espree": "^4.1.0", - "estraverse": "^4.2.0", + "espree": "^6.2.1", + "estraverse": "^5.0.0", "lodash": "^4.17.2", - "mocha": "^5.2.0" + "mocha": "^7.1.1" }, "peerDependencies": { "eslint": ">=5.0.0" diff --git a/tests/lib/rules/no-deprecated-report-api.js b/tests/lib/rules/no-deprecated-report-api.js index b46043c7..24a81272 100644 --- a/tests/lib/rules/no-deprecated-report-api.js +++ b/tests/lib/rules/no-deprecated-report-api.js @@ -11,7 +11,7 @@ const rule = require('../../../lib/rules/no-deprecated-report-api'); const RuleTester = require('eslint').RuleTester; -const ERROR = [{ message: 'Use the new-style context.report() API.', type: 'CallExpression' }]; +const ERROR = { message: 'Use the new-style context.report() API.', type: 'Identifier' }; // ------------------------------------------------------------------------------ // Tests diff --git a/tests/lib/rules/require-meta-fixable.js b/tests/lib/rules/require-meta-fixable.js index a4a8c9bf..5916515b 100644 --- a/tests/lib/rules/require-meta-fixable.js +++ b/tests/lib/rules/require-meta-fixable.js @@ -12,8 +12,8 @@ const rule = require('../../../lib/rules/require-meta-fixable'); const RuleTester = require('eslint').RuleTester; -const MISSING_ERROR = [{ message: 'Fixable rules must export a `meta.fixable` property.', type: 'FunctionExpression' }]; -const INVALID_ERROR = [{ message: '`meta.fixable` must be either `code`, `whitespace` or `null`.', type: 'Property' }]; +const MISSING_ERROR = { message: 'Fixable rules must export a `meta.fixable` property.', type: 'FunctionExpression' }; +const INVALID_ERROR = { message: '`meta.fixable` must be either `code`, `whitespace` or `null`.', type: 'Property' }; // ------------------------------------------------------------------------------ // Tests From 68059b1ed2cb2710a4d6c4aa1d05afad8de565f0 Mon Sep 17 00:00:00 2001 From: Kevin Partington Date: Tue, 12 May 2020 01:24:33 -0500 Subject: [PATCH 2/4] Docs: Fix incorrect rule reference in meta-property-ordering (#96) --- docs/rules/meta-property-ordering.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/rules/meta-property-ordering.md b/docs/rules/meta-property-ordering.md index 29ce4c98..8115af82 100644 --- a/docs/rules/meta-property-ordering.md +++ b/docs/rules/meta-property-ordering.md @@ -45,7 +45,7 @@ module.exports = { Examples of **correct** code for this rule: ```js -/* eslint eslint-plugin/test-case-property-ordering: ["error", +/* eslint eslint-plugin/meta-property-ordering: ["error", ["type", "docs", "fixable", "schema", "messages"] ] */ From 45a09a67942c55230fcae893633c1911b089a514 Mon Sep 17 00:00:00 2001 From: Brad Zacher Date: Tue, 9 Jun 2020 17:29:08 -0700 Subject: [PATCH 3/4] Fix: handle spreads in rule meta objects (#100) --- lib/utils.js | 4 ++++ tests/lib/rules/require-meta-fixable.js | 13 +++++++++++++ tests/lib/utils.js | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/lib/utils.js b/lib/utils.js index 0fd86bd4..40d38b84 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -184,6 +184,10 @@ module.exports = { * @returns {string|null} The key name, or `null` if the name cannot be determined statically. */ getKeyName (property) { + if (!property.key) { + // likely a SpreadElement or another non-standard node + return null; + } if (!property.computed && property.key.type === 'Identifier') { return property.key.name; } diff --git a/tests/lib/rules/require-meta-fixable.js b/tests/lib/rules/require-meta-fixable.js index 5916515b..875e7016 100644 --- a/tests/lib/rules/require-meta-fixable.js +++ b/tests/lib/rules/require-meta-fixable.js @@ -105,6 +105,19 @@ ruleTester.run('require-meta-fixable', rule, { create(context) { context.report(node, message, data, fix); } }; `, + { + code: ` + const meta = {}; + module.exports = { + ...meta, + meta: {}, + create(context) { context.report(node, message, data, fix); } + }; + `, + parserOptions: { + ecmaVersion: 9, + }, + }, ], invalid: [ diff --git a/tests/lib/utils.js b/tests/lib/utils.js index fbe78bfc..c92d9f88 100644 --- a/tests/lib/utils.js +++ b/tests/lib/utils.js @@ -183,6 +183,17 @@ describe('utils', () => { assert.strictEqual(utils.getKeyName(ast.body[0].expression.properties[0]), CASES[objectSource]); }); }); + + const CASES_ES9 = { + '({ ...foo })': null, + }; + Object.keys(CASES_ES9).forEach(objectSource => { + it(objectSource, () => { + const ast = espree.parse(objectSource, { ecmaVersion: 9 }); + + assert.strictEqual(utils.getKeyName(ast.body[0].expression.properties[0]), CASES_ES9[objectSource]); + }); + }); }); describe('getTestInfo', () => { From f50d3b82a7762f87ac072814aa8df97ba7e8b77f Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Tue, 9 Jun 2020 20:29:44 -0400 Subject: [PATCH 4/4] Build: update package.json and changelog for v2.2.2 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e03ddaf..f67701fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## v2.2.2 (2020-06-10) + +* Fix: handle spreads in rule meta objects ([#100](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/100)) ([45a09a6](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/commit/45a09a67942c55230fcae893633c1911b089a514)) +* Docs: Fix incorrect rule reference in meta-property-ordering ([#96](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/96)) ([68059b1](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/commit/68059b1ed2cb2710a4d6c4aa1d05afad8de565f0)) +* Upgrade: eslint and other deps ([#92](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/92)) ([93d082c](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/commit/93d082cce48da79bf7305df70e4fd0061b482e88)) + ## v2.2.1 (2020-01-17) * Fix: update `require-meta-schema` rule to allow object schemas (in addition to array schemas) ([#90](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/90)) ([e582cb6](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/commit/e582cb61d0f51c15a8e5d9e38c82d1c73f2d6edd)) diff --git a/package.json b/package.json index 6295b8ae..d1a634b6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-eslint-plugin", - "version": "2.2.1", + "version": "2.2.2", "description": "An ESLint plugin for linting ESLint plugins", "author": "Teddy Katz", "main": "lib/index.js",