Skip to content

Commit

Permalink
chore(lint): add eslint-plugin-eslint-plugin internally and fix viola…
Browse files Browse the repository at this point in the history
…tions

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)).
4. Adds missing test case `output` assertions ([consistent-output](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/consistent-output.md)).
5. Switches some test cases to use the string shorthand ([test-case-shorthand-strings](https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/blob/master/docs/rules/test-case-shorthand-strings.md)).
  • Loading branch information
bmish committed Jan 20, 2020
1 parent f84d457 commit d87a5c0
Show file tree
Hide file tree
Showing 35 changed files with 100 additions and 51 deletions.
13 changes: 13 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
plugins:
- eslint-plugin
- import
extends:
- eslint:recommended
- plugin:eslint-plugin/recommended
- plugin:import/recommended

env:
Expand All @@ -26,6 +28,17 @@ rules:
- allowTemplateLiterals: true
avoidEscape: true

eslint-plugin/consistent-output: ["error", "always"]
eslint-plugin/meta-property-ordering: "error"
eslint-plugin/no-deprecated-context-methods: "error"
eslint-plugin/no-deprecated-report-api: "off"
eslint-plugin/prefer-output-null: "error"
eslint-plugin/prefer-replace-text: "error"
eslint-plugin/report-message-format: "error"
eslint-plugin/require-meta-schema: "error"
eslint-plugin/require-meta-type: "error"
eslint-plugin/test-case-shorthand-strings: "error"

# dog fooding
import/no-extraneous-dependencies: "error"
import/unambiguous: "off"
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
- [`extensions`]: for invalid code where `name` does not exist, do not crash ([#1613], thanks [@ljharb])
- [`extentions`]: Fix scope regex ([#1611], thanks [@yordis])
- [`no-duplicates`]: allow duplicate imports if one is a namespace and the other not ([#1612], thanks [@sveyret])
- Add some missing rule meta schemas and types

### Changed
- [`import/external-module-folders` setting] behavior is more strict now: it will only match complete path segments ([#1605], thanks [@skozin])
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
"eslint-import-test-order-redirect": "file:./tests/files/order-redirect",
"eslint-module-utils": "file:./utils",
"eslint-plugin-eslint-plugin": "^2.2.1",
"eslint-plugin-import": "2.x",
"linklocal": "^2.8.2",
"mocha": "^3.5.3",
Expand Down
1 change: 1 addition & 0 deletions src/rules/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
docs: {
url: docsUrl('default'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = {
docs: {
url: docsUrl('export'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/exports-last.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
docs: {
url: docsUrl('exports-last'),
},
schema: [],
},

create: function (context) {
Expand Down
6 changes: 6 additions & 0 deletions src/rules/first.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ module.exports = {
url: docsUrl('first'),
},
fixable: 'code',
schema: [
{
type: 'string',
enum: ['absolute-first'],
},
],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
docs: {
url: docsUrl('named'),
},
schema: [],
},

create: function (context) {
Expand Down
2 changes: 1 addition & 1 deletion src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module.exports = {
docs: {
url: docsUrl('newline-after-import'),
},
fixable: 'whitespace',
schema: [
{
'type': 'object',
Expand All @@ -61,7 +62,6 @@ module.exports = {
'additionalProperties': false,
},
],
fixable: 'whitespace',
},
create: function (context) {
let level = 0
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
docs: {
url: docsUrl('no-amd'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
meta: {
type: 'suggestion',
docs: {},
schema: [],
},

create(context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = {
docs: {
url: docsUrl('no-deprecated'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-dynamic-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = {
docs: {
url: docsUrl('no-dynamic-require'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-mutable-exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
docs: {
url: docsUrl('no-mutable-exports'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-named-as-default-member.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = {
docs: {
url: docsUrl('no-named-as-default-member'),
},
schema: [],
},

create: function(context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-named-as-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
docs: {
url: docsUrl('no-named-as-default'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-named-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
docs: {
url: docsUrl('no-named-default'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-named-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
meta: {
type: 'suggestion',
docs: { url: docsUrl('no-named-export') },
schema: [],
},

create(context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
url: docsUrl('no-namespace'),
},
fixable: 'code',
schema: [],
},

create: function (context) {
Expand Down
11 changes: 11 additions & 0 deletions src/rules/no-nodejs-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ module.exports = {
docs: {
url: docsUrl('no-nodejs-modules'),
},
schema: [
{
type: 'object',
properties: {
allow: {
type: 'array',
},
},
additionalProperties: false,
},
],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ const fileIsInPkg = file => {

module.exports = {
meta: {
type: 'suggestion',
docs: { url: docsUrl('no-unused-modules') },
schema: [{
properties: {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-useless-path-segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ module.exports = {
url: docsUrl('no-useless-path-segments'),
},

fixable: 'code',

schema: [
{
type: 'object',
Expand All @@ -53,8 +55,6 @@ module.exports = {
additionalProperties: false,
},
],

fixable: 'code',
},

create(context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/no-webpack-loader-syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
docs: {
url: docsUrl('no-webpack-loader-syntax'),
},
schema: [],
},

create: function (context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports = {
docs: {
url: docsUrl('prefer-default-export'),
},
schema: [],
},

create: function(context) {
Expand Down
1 change: 1 addition & 0 deletions src/rules/unambiguous.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module.exports = {
docs: {
url: docsUrl('unambiguous'),
},
schema: [],
},

create: function (context) {
Expand Down
Empty file removed tests/files/CaseyKasem.js
Empty file.
5 changes: 0 additions & 5 deletions tests/src/rules/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ ruleTester.run('default', rule, {
errors: [{ message: 'No default export found in imported module "./named-exports".'
, type: 'ImportDefaultSpecifier'}]}),

test({
code: "import Foo from './jsx/FooES7.js';",
errors: ["Parse errors in imported module './jsx/FooES7.js': Unexpected token = (6:16)"],
}),

// es7 export syntax
test({
code: 'export baz from "./named-exports"',
Expand Down
Loading

0 comments on commit d87a5c0

Please sign in to comment.