Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add eslint-plugin-eslint-plugin internally and fix violations #1620

Merged
merged 2 commits into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 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,16 @@ rules:
- allowTemplateLiterals: true
avoidEscape: true

eslint-plugin/consistent-output: "error"
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"

# dog fooding
import/no-extraneous-dependencies: "error"
import/unambiguous: "off"
Expand Down
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ env:
# osx backlog is often deep, so to be polite we can just hit these highlights
matrix:
include:
- env: LINT=true
node_js: lts/*
- env: PACKAGE=resolvers/node
node_js: 13
- env: PACKAGE=resolvers/node
Expand Down Expand Up @@ -81,7 +83,7 @@ install:
- 'if [ -n "${ESLINT_VERSION}" ]; then ./tests/dep-time-travel.sh; fi'

script:
- 'npm test'
- 'if [ -n "${LINT-}" ]; then npm run posttest ; else npm run tests-only ; fi'

after_success:
- npm run coveralls
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 ([#1620], thanks [@bmish])

### Changed
- [`import/external-module-folders` setting] behavior is more strict now: it will only match complete path segments ([#1605], thanks [@skozin])
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"pretest": "linklocal",
"posttest": "eslint .",
"mocha": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot --recursive -t 5s",
"test": "npm run mocha tests/src",
"tests-only": "npm run mocha tests/src",
"test": "npm run tests-only",
"test-compiled": "npm run prepublish && NODE_PATH=./lib mocha --compilers js:babel-register --recursive tests/src",
"test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done",
"prepublish": "npm run build",
Expand Down Expand Up @@ -68,6 +69,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
3 changes: 2 additions & 1 deletion resolvers/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
],
"scripts": {
"prepublishOnly": "cp ../../{LICENSE,.npmrc} ./",
"test": "nyc mocha",
"tests-only": "nyc mocha",
"test": "npm run tests-only",
"coveralls": "nyc report --reporter lcovonly && cd ../.. && coveralls < ./resolvers/node/coverage/lcov.info"
},
"repository": {
Expand Down
3 changes: 2 additions & 1 deletion resolvers/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "index.js",
"scripts": {
"prepublishOnly": "cp ../../{LICENSE,.npmrc} ./",
"test": "nyc mocha -t 5s",
"tests-only": "nyc mocha -t 5s",
"test": "npm run tests-only",
"report": "nyc report --reporter=html",
"coveralls": "nyc report --reporter lcovonly && cd ../.. && coveralls < ./resolvers/webpack/coverage/lcov.info"
},
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
15 changes: 15 additions & 0 deletions src/rules/no-nodejs-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ module.exports = {
docs: {
url: docsUrl('no-nodejs-modules'),
},
schema: [
{
type: 'object',
properties: {
allow: {
type: 'array',
ljharb marked this conversation as resolved.
Show resolved Hide resolved
uniqueItems: true,
items: {
type: 'string',
},
},
},
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
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
2 changes: 0 additions & 2 deletions tests/src/rules/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ ruleTester.run('export', rule, {
test({ code: 'export var foo = "foo", bar = "bar";' }),
test({ code: 'export var { foo, bar } = object;' }),
test({ code: 'export var [ foo, bar ] = array;' }),
test({ code: 'export var { foo, bar } = object;' }),
test({ code: 'export var [ foo, bar ] = array;' }),
test({ code: 'let foo; export { foo, foo as bar }' }),
test({ code: 'let bar; export { bar }; export * from "./export-all"' }),
test({ code: 'export * from "./export-all"' }),
Expand Down
1 change: 0 additions & 1 deletion tests/src/rules/named.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ ruleTester.run('named', rule, {

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

Expand Down
10 changes: 0 additions & 10 deletions tests/src/rules/newline-after-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,6 @@ ruleTester.run('newline-after-import', require('rules/newline-after-import'), {
} ],
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
},
{
code: `var foo = require('foo-module');\nvar something = 123;`,
output: `var foo = require('foo-module');\n\nvar something = 123;`,
errors: [ {
line: 1,
column: 1,
message: REQUIRE_ERROR_MESSAGE,
} ],
parserOptions: { ecmaVersion: 2015, sourceType: 'module' },
},
{
code: `import foo from 'foo';\nvar a = 123;\n\nimport { bar } from './bar-lib';\nvar b=456;`,
output: `import foo from 'foo';\n\nvar a = 123;\n\nimport { bar } from './bar-lib';\n\nvar b=456;`,
Expand Down
3 changes: 1 addition & 2 deletions tests/src/rules/no-commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {
// imports
{ code: 'import "x";', parserOptions: { ecmaVersion: 2015, sourceType: 'module' } },
{ code: 'import x from "x"', parserOptions: { ecmaVersion: 2015, sourceType: 'module' } },
{ code: 'import x from "x"', parserOptions: { ecmaVersion: 2015, sourceType: 'module' } },
{ code: 'import { x } from "x"', parserOptions: { ecmaVersion: 2015, sourceType: 'module' } },

// exports
Expand Down Expand Up @@ -61,7 +60,7 @@ ruleTester.run('no-commonjs', require('rules/no-commonjs'), {
{ code: 'if (typeof window !== "undefined") require("x")', options: [{ allowRequire: false }] },
{ code: 'if (typeof window !== "undefined") { require("x") }', options: [{ allowRequire: true }] },
{ code: 'if (typeof window !== "undefined") { require("x") }', options: [{ allowRequire: false }] },

{ code: 'try { require("x") } catch (error) {}' },
],

Expand Down
9 changes: 0 additions & 9 deletions tests/src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
filename: path.join(process.cwd(), 'foo.spec.js'),
}),
test({
code: 'import chai from "chai"',
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
filename: path.join(process.cwd(), 'foo.spec.js'),
}),
test({ code: 'require(6)' }),
test({
code: 'import "doctrine"',
Expand Down Expand Up @@ -101,10 +96,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
code: 'import leftpad from "left-pad";',
options: [{packageDir: [packageDirMonoRepoRoot, packageDirMonoRepoWithNested]}],
}),
test({
code: 'import leftpad from "left-pad";',
options: [{packageDir: [packageDirMonoRepoWithNested, packageDirMonoRepoRoot]}],
}),
test({
code: 'import rightpad from "right-pad";',
options: [{packageDir: [packageDirMonoRepoRoot, packageDirMonoRepoWithNested]}],
Expand Down
1 change: 0 additions & 1 deletion tests/src/rules/no-unassigned-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ruleTester.run('no-unassigned-import', rule, {
test({ code: 'const {foo} = require("lodash")'}),
test({ code: 'const {foo: bar} = require("lodash")'}),
test({ code: 'const [a, b] = require("lodash")'}),
test({ code: 'const _ = require("lodash")'}),
test({ code: 'const _ = require("./")'}),
test({ code: 'foo(require("lodash"))'}),
test({ code: 'require("lodash").foo'}),
Expand Down