Skip to content

Commit 16ac399

Browse files
committed
chore(lint): add eslint-plugin-eslint-plugin internally and fix violations
This PR adds [eslint-plugin-eslint-plugin](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin) (a popular plugin for linting eslint plugins), enables relevant rules from it, and fixes violations. The primary changes included are: 1. Adds missing rule schemas ([require-meta-schema](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-schema.md)). Note that `schema: []` is added to enforce when a rule should have no schema. 2. Adds missing rule `type` property to `no-unused-modules` rule ([require-meta-type](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/require-meta-type.md)). 3. Removes duplicate test cases ([no-identical-tests](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/no-identical-tests.md)).
1 parent 99647f1 commit 16ac399

32 files changed

+57
-33
lines changed

.eslintrc.yml

+12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
plugins:
3+
- eslint-plugin
34
- import
45
extends:
56
- eslint:recommended
7+
- plugin:eslint-plugin/recommended
68
- plugin:import/recommended
79

810
env:
@@ -26,6 +28,16 @@ rules:
2628
- allowTemplateLiterals: true
2729
avoidEscape: true
2830

31+
eslint-plugin/consistent-output: "error"
32+
eslint-plugin/meta-property-ordering: "error"
33+
eslint-plugin/no-deprecated-context-methods: "error"
34+
eslint-plugin/no-deprecated-report-api: "off"
35+
eslint-plugin/prefer-output-null: "error"
36+
eslint-plugin/prefer-replace-text: "error"
37+
eslint-plugin/report-message-format: "error"
38+
eslint-plugin/require-meta-schema: "error"
39+
eslint-plugin/require-meta-type: "error"
40+
2941
# dog fooding
3042
import/no-extraneous-dependencies: "error"
3143
import/unambiguous: "off"

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
1010
- [`extensions`]: for invalid code where `name` does not exist, do not crash ([#1613], thanks [@ljharb])
1111
- [`extentions`]: Fix scope regex ([#1611], thanks [@yordis])
1212
- [`no-duplicates`]: allow duplicate imports if one is a namespace and the other not ([#1612], thanks [@sveyret])
13+
- Add some missing rule meta schemas and types ([#1620], thanks [@bmish])
1314

1415
### Changed
1516
- [`import/external-module-folders` setting] behavior is more strict now: it will only match complete path segments ([#1605], thanks [@skozin])

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
6969
"eslint-import-test-order-redirect": "file:./tests/files/order-redirect",
7070
"eslint-module-utils": "file:./utils",
71+
"eslint-plugin-eslint-plugin": "^2.2.1",
7172
"eslint-plugin-import": "2.x",
7273
"linklocal": "^2.8.2",
7374
"mocha": "^3.5.3",

src/rules/default.js

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module.exports = {
77
docs: {
88
url: docsUrl('default'),
99
},
10+
schema: [],
1011
},
1112

1213
create: function (context) {

src/rules/export.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ module.exports = {
4545
docs: {
4646
url: docsUrl('export'),
4747
},
48+
schema: [],
4849
},
4950

5051
create: function (context) {

src/rules/exports-last.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
docs: {
1313
url: docsUrl('exports-last'),
1414
},
15+
schema: [],
1516
},
1617

1718
create: function (context) {

src/rules/first.js

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ module.exports = {
77
url: docsUrl('first'),
88
},
99
fixable: 'code',
10+
schema: [
11+
{
12+
type: 'string',
13+
enum: ['absolute-first'],
14+
},
15+
],
1016
},
1117

1218
create: function (context) {

src/rules/named.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
docs: {
99
url: docsUrl('named'),
1010
},
11+
schema: [],
1112
},
1213

1314
create: function (context) {

src/rules/newline-after-import.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ module.exports = {
4949
docs: {
5050
url: docsUrl('newline-after-import'),
5151
},
52+
fixable: 'whitespace',
5253
schema: [
5354
{
5455
'type': 'object',
@@ -61,7 +62,6 @@ module.exports = {
6162
'additionalProperties': false,
6263
},
6364
],
64-
fixable: 'whitespace',
6565
},
6666
create: function (context) {
6767
let level = 0

src/rules/no-amd.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
docs: {
1616
url: docsUrl('no-amd'),
1717
},
18+
schema: [],
1819
},
1920

2021
create: function (context) {

src/rules/no-default-export.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
meta: {
33
type: 'suggestion',
44
docs: {},
5+
schema: [],
56
},
67

78
create(context) {

src/rules/no-deprecated.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = {
2121
docs: {
2222
url: docsUrl('no-deprecated'),
2323
},
24+
schema: [],
2425
},
2526

2627
create: function (context) {

src/rules/no-dynamic-require.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = {
1919
docs: {
2020
url: docsUrl('no-dynamic-require'),
2121
},
22+
schema: [],
2223
},
2324

2425
create: function (context) {

src/rules/no-mutable-exports.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
docs: {
77
url: docsUrl('no-mutable-exports'),
88
},
9+
schema: [],
910
},
1011

1112
create: function (context) {

src/rules/no-named-as-default-member.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
docs: {
1919
url: docsUrl('no-named-as-default-member'),
2020
},
21+
schema: [],
2122
},
2223

2324
create: function(context) {

src/rules/no-named-as-default.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
docs: {
99
url: docsUrl('no-named-as-default'),
1010
},
11+
schema: [],
1112
},
1213

1314
create: function (context) {

src/rules/no-named-default.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
docs: {
77
url: docsUrl('no-named-default'),
88
},
9+
schema: [],
910
},
1011

1112
create: function (context) {

src/rules/no-named-export.js

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = {
44
meta: {
55
type: 'suggestion',
66
docs: { url: docsUrl('no-named-export') },
7+
schema: [],
78
},
89

910
create(context) {

src/rules/no-namespace.js

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module.exports = {
1717
url: docsUrl('no-namespace'),
1818
},
1919
fixable: 'code',
20+
schema: [],
2021
},
2122

2223
create: function (context) {

src/rules/no-nodejs-modules.js

+15
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ module.exports = {
1414
docs: {
1515
url: docsUrl('no-nodejs-modules'),
1616
},
17+
schema: [
18+
{
19+
type: 'object',
20+
properties: {
21+
allow: {
22+
type: 'array',
23+
uniqueItems: true,
24+
items: {
25+
type: 'string',
26+
},
27+
},
28+
},
29+
additionalProperties: false,
30+
},
31+
],
1732
},
1833

1934
create: function (context) {

src/rules/no-unused-modules.js

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ const fileIsInPkg = file => {
305305

306306
module.exports = {
307307
meta: {
308+
type: 'suggestion',
308309
docs: { url: docsUrl('no-unused-modules') },
309310
schema: [{
310311
properties: {

src/rules/no-useless-path-segments.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ module.exports = {
4343
url: docsUrl('no-useless-path-segments'),
4444
},
4545

46+
fixable: 'code',
47+
4648
schema: [
4749
{
4850
type: 'object',
@@ -53,8 +55,6 @@ module.exports = {
5355
additionalProperties: false,
5456
},
5557
],
56-
57-
fixable: 'code',
5858
},
5959

6060
create(context) {

src/rules/no-webpack-loader-syntax.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports = {
1515
docs: {
1616
url: docsUrl('no-webpack-loader-syntax'),
1717
},
18+
schema: [],
1819
},
1920

2021
create: function (context) {

src/rules/prefer-default-export.js

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
docs: {
99
url: docsUrl('prefer-default-export'),
1010
},
11+
schema: [],
1112
},
1213

1314
create: function(context) {

src/rules/unambiguous.js

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
docs: {
1313
url: docsUrl('unambiguous'),
1414
},
15+
schema: [],
1516
},
1617

1718
create: function (context) {

tests/src/rules/default.js

-5
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,6 @@ ruleTester.run('default', rule, {
105105
errors: [{ message: 'No default export found in imported module "./named-exports".'
106106
, type: 'ImportDefaultSpecifier'}]}),
107107

108-
test({
109-
code: "import Foo from './jsx/FooES7.js';",
110-
errors: ["Parse errors in imported module './jsx/FooES7.js': Unexpected token = (6:16)"],
111-
}),
112-
113108
// es7 export syntax
114109
test({
115110
code: 'export baz from "./named-exports"',

tests/src/rules/export.js

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ ruleTester.run('export', rule, {
1515
test({ code: 'export var foo = "foo", bar = "bar";' }),
1616
test({ code: 'export var { foo, bar } = object;' }),
1717
test({ code: 'export var [ foo, bar ] = array;' }),
18-
test({ code: 'export var { foo, bar } = object;' }),
19-
test({ code: 'export var [ foo, bar ] = array;' }),
2018
test({ code: 'let foo; export { foo, foo as bar }' }),
2119
test({ code: 'let bar; export { bar }; export * from "./export-all"' }),
2220
test({ code: 'export * from "./export-all"' }),

tests/src/rules/named.js

-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ ruleTester.run('named', rule, {
173173

174174
test({
175175
code: 'import { a } from "./re-export-names"',
176-
options: [2, 'es6-only'],
177176
errors: [error('a', './re-export-names')],
178177
}),
179178

tests/src/rules/newline-after-import.js

-10
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,6 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
210210
} ],
211211
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
212212
},
213-
{
214-
code: `var foo = require('foo-module');\nvar something = 123;`,
215-
output: `var foo = require('foo-module');\n\nvar something = 123;`,
216-
errors: [ {
217-
line: 1,
218-
column: 1,
219-
message: REQUIRE_ERROR_MESSAGE,
220-
} ],
221-
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
222-
},
223213
{
224214
code: `import foo from 'foo';\nvar a = 123;\n\nimport { bar } from './bar-lib';\nvar b=456;`,
225215
output: `import foo from 'foo';\n\nvar a = 123;\n\nimport { bar } from './bar-lib';\n\nvar b=456;`,

tests/src/rules/no-commonjs.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {
1313
// imports
1414
{ code: 'import "x";', parserOptions: { ecmaVersion: 2015, sourceType: 'module' } },
1515
{ code: 'import x from "x"', parserOptions: { ecmaVersion: 2015, sourceType: 'module' } },
16-
{ code: 'import x from "x"', parserOptions: { ecmaVersion: 2015, sourceType: 'module' } },
1716
{ code: 'import { x } from "x"', parserOptions: { ecmaVersion: 2015, sourceType: 'module' } },
1817

1918
// exports
@@ -61,7 +60,7 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {
6160
{ code: 'if (typeof window !== "undefined") require("x")', options: [{ allowRequire: false }] },
6261
{ code: 'if (typeof window !== "undefined") { require("x") }', options: [{ allowRequire: true }] },
6362
{ code: 'if (typeof window !== "undefined") { require("x") }', options: [{ allowRequire: false }] },
64-
63+
6564
{ code: 'try { require("x") } catch (error) {}' },
6665
],
6766

tests/src/rules/no-extraneous-dependencies.js

-9
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
6666
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
6767
filename: path.join(process.cwd(), 'foo.spec.js'),
6868
}),
69-
test({
70-
code: 'import chai from "chai"',
71-
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
72-
filename: path.join(process.cwd(), 'foo.spec.js'),
73-
}),
7469
test({ code: 'require(6)' }),
7570
test({
7671
code: 'import "doctrine"',
@@ -101,10 +96,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
10196
code: 'import leftpad from "left-pad";',
10297
options: [{packageDir: [packageDirMonoRepoRoot, packageDirMonoRepoWithNested]}],
10398
}),
104-
test({
105-
code: 'import leftpad from "left-pad";',
106-
options: [{packageDir: [packageDirMonoRepoWithNested, packageDirMonoRepoRoot]}],
107-
}),
10899
test({
109100
code: 'import rightpad from "right-pad";',
110101
options: [{packageDir: [packageDirMonoRepoRoot, packageDirMonoRepoWithNested]}],

tests/src/rules/no-unassigned-import.js

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ ruleTester.run('no-unassigned-import', rule, {
2323
test({ code: 'const {foo} = require("lodash")'}),
2424
test({ code: 'const {foo: bar} = require("lodash")'}),
2525
test({ code: 'const [a, b] = require("lodash")'}),
26-
test({ code: 'const _ = require("lodash")'}),
2726
test({ code: 'const _ = require("./")'}),
2827
test({ code: 'foo(require("lodash"))'}),
2928
test({ code: 'require("lodash").foo'}),

0 commit comments

Comments
 (0)