Skip to content

Add eslint 7 to CI #1715

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

Merged
merged 4 commits into from
Apr 4, 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
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ node_js:
os: linux

env:
- ESLINT_VERSION=^7.0.0-0
- ESLINT_VERSION=6
- ESLINT_VERSION=5
- ESLINT_VERSION=4
Expand Down Expand Up @@ -65,8 +66,14 @@ matrix:
env: ESLINT_VERSION=5
- node_js: '4'
env: ESLINT_VERSION=6
- node_js: '4'
env: ESLINT_VERSION=^7.0.0-0
- node_js: '6'
env: ESLINT_VERSION=6
- node_js: '6'
env: ESLINT_VERSION=^7.0.0-0
- node_js: '8'
env: ESLINT_VERSION=^7.0.0-0

fast_finish: true
allow_failures:
Expand Down
4 changes: 3 additions & 1 deletion src/rules/dynamic-import-chunkname.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ module.exports = {

const sourceCode = context.getSourceCode()
const arg = node.arguments[0]
const leadingComments = sourceCode.getComments(arg).leading
const leadingComments = sourceCode.getCommentsBefore
? sourceCode.getCommentsBefore(arg) // This method is available in ESLint >= 4.
: sourceCode.getComments(arg).leading // This method is deprecated in ESLint 7.

if (!leadingComments || leadingComments.length === 0) {
context.report({
Expand Down
1 change: 0 additions & 1 deletion tests/src/rules/exports-last.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import rule from 'rules/exports-last'
const ruleTester = new RuleTester()

const error = type => ({
ruleId: 'exports-last',
message: 'Export statements should appear at the end of the file',
type,
})
Expand Down
1 change: 0 additions & 1 deletion tests/src/rules/no-absolute-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const ruleTester = new RuleTester()
, rule = require('rules/no-absolute-path')

const error = {
ruleId: 'no-absolute-path',
message: 'Do not import modules using an absolute path',
}

Expand Down
2 changes: 1 addition & 1 deletion tests/src/rules/no-cycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { RuleTester } from 'eslint'
const ruleTester = new RuleTester()
, rule = require('rules/no-cycle')

const error = message => ({ ruleId: 'no-cycle', message })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this then be test: 'no-cycle'?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh sorry, type. You changed a bunch of ruleID: foo to be type: foo - should they all be changed, rather than just deleting them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed some ruleId: ... to type: ... because these types are already correct, like ruleId: "ExportNameSpecifier" to type: "ExportNameSpecifier". In other places they are totally wrong , like ruleId: "no-cycle". Filling out the correct type for these cases is too much work for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these additions made in another PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's fine.

const error = message => ({ message })

const test = def => _test(Object.assign(def, {
filename: testFilePath('./cycles/depth-zero.js'),
Expand Down
8 changes: 4 additions & 4 deletions tests/src/rules/no-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ruleTester.run('no-default-export', rule, {
test({
code: 'export default function bar() {};',
errors: [{
ruleId: 'ExportDefaultDeclaration',
type: 'ExportDefaultDeclaration',
message: 'Prefer named exports.',
}],
}),
Expand All @@ -98,14 +98,14 @@ ruleTester.run('no-default-export', rule, {
export const foo = 'foo';
export default bar;`,
errors: [{
ruleId: 'ExportDefaultDeclaration',
type: 'ExportDefaultDeclaration',
message: 'Prefer named exports.',
}],
}),
test({
code: 'let foo; export { foo as default }',
errors: [{
ruleId: 'ExportNamedDeclaration',
type: 'ExportNamedDeclaration',
message: 'Do not alias `foo` as `default`. Just export `foo` itself ' +
'instead.',
}],
Expand All @@ -114,7 +114,7 @@ ruleTester.run('no-default-export', rule, {
code: 'export default from "foo.js"',
parser: require.resolve('babel-eslint'),
errors: [{
ruleId: 'ExportNamedDeclaration',
type: 'ExportNamedDeclaration',
message: 'Prefer named exports.',
}],
}),
Expand Down
1 change: 0 additions & 1 deletion tests/src/rules/no-dynamic-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const ruleTester = new RuleTester()
, rule = require('rules/no-dynamic-require')

const error = {
ruleId: 'no-dynamic-require',
message: 'Calls to require() should use string literals',
}

Expand Down
24 changes: 0 additions & 24 deletions tests/src/rules/no-extraneous-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
filename: path.join(packageDirMonoRepoRoot, 'foo.js'),
options: [{packageDir: packageDirMonoRepoRoot }],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
Expand All @@ -135,67 +134,58 @@ ruleTester.run('no-extraneous-dependencies', rule, {
filename: path.join(packageDirMonoRepoWithNested, 'foo.js'),
options: [{packageDir: packageDirMonoRepoRoot}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
test({
code: 'import "not-a-dependency"',
options: [{packageDir: packageDirMonoRepoRoot}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
test({
code: 'import "not-a-dependency"',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
test({
code: 'var donthaveit = require("@org/not-a-dependency")',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'@org/not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S @org/not-a-dependency\' to add it',
}],
}),
test({
code: 'var donthaveit = require("@org/not-a-dependency/foo")',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'@org/not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S @org/not-a-dependency\' to add it',
}],
}),
test({
code: 'import "eslint"',
options: [{devDependencies: false, peerDependencies: false}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'eslint\' should be listed in the project\'s dependencies, not devDependencies.',
}],
}),
test({
code: 'import "lodash.isarray"',
options: [{optionalDependencies: false}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'lodash.isarray\' should be listed in the project\'s dependencies, not optionalDependencies.',
}],
}),
test({
code: 'var foo = require("not-a-dependency")',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
test({
code: 'var glob = require("glob")',
options: [{devDependencies: false}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'glob\' should be listed in the project\'s dependencies, not devDependencies.',
}],
}),
Expand All @@ -204,7 +194,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
options: [{devDependencies: ['*.test.js']}],
filename: 'foo.tes.js',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'chai\' should be listed in the project\'s dependencies, not devDependencies.',
}],
}),
Expand All @@ -213,7 +202,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
options: [{devDependencies: ['*.test.js']}],
filename: path.join(process.cwd(), 'foo.tes.js'),
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'chai\' should be listed in the project\'s dependencies, not devDependencies.',
}],
}),
Expand All @@ -222,7 +210,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
filename: 'foo.tes.js',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'chai\' should be listed in the project\'s dependencies, not devDependencies.',
}],
}),
Expand All @@ -231,39 +218,34 @@ ruleTester.run('no-extraneous-dependencies', rule, {
options: [{devDependencies: ['*.test.js', '*.spec.js']}],
filename: path.join(process.cwd(), 'foo.tes.js'),
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'chai\' should be listed in the project\'s dependencies, not devDependencies.',
}],
}),
test({
code: 'var eslint = require("lodash.isarray")',
options: [{optionalDependencies: false}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'lodash.isarray\' should be listed in the project\'s dependencies, not optionalDependencies.',
}],
}),
test({
code: 'import "not-a-dependency"',
options: [{packageDir: path.join(__dirname, '../../../')}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
test({
code: 'import "bar"',
options: [{packageDir: path.join(__dirname, './doesn-exist/')}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: 'The package.json file could not be found.',
}],
}),
test({
code: 'import foo from "foo"',
options: [{packageDir: packageDirWithSyntaxError}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: 'The package.json file could not be parsed: ' + packageFileWithSyntaxErrorMessage,
}],
}),
Expand All @@ -272,15 +254,13 @@ ruleTester.run('no-extraneous-dependencies', rule, {
filename: path.join(packageDirMonoRepoWithNested, 'foo.js'),
options: [{packageDir: packageDirMonoRepoWithNested}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: "'left-pad' should be listed in the project's dependencies. Run 'npm i -S left-pad' to add it",
}],
}),
test({
code: 'import react from "react";',
filename: path.join(packageDirMonoRepoRoot, 'foo.js'),
errors: [{
ruleId: 'no-extraneous-dependencies',
message: "'react' should be listed in the project's dependencies. Run 'npm i -S react' to add it",
}],
}),
Expand All @@ -289,7 +269,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
filename: path.join(packageDirMonoRepoWithNested, 'foo.js'),
options: [{packageDir: packageDirMonoRepoRoot}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: "'react' should be listed in the project's dependencies. Run 'npm i -S react' to add it",
}],
}),
Expand All @@ -298,7 +277,6 @@ ruleTester.run('no-extraneous-dependencies', rule, {
filename: path.join(packageDirWithEmpty, 'index.js'),
options: [{packageDir: packageDirWithEmpty}],
errors: [{
ruleId: 'no-extraneous-dependencies',
message: "'react' should be listed in the project's dependencies. Run 'npm i -S react' to add it",
}],
}),
Expand All @@ -319,14 +297,12 @@ ruleTester.run('no-extraneous-dependencies', rule, {
test({
code: 'export { foo } from "not-a-dependency";',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
test({
code: 'export * from "not-a-dependency";',
errors: [{
ruleId: 'no-extraneous-dependencies',
message: '\'not-a-dependency\' should be listed in the project\'s dependencies. Run \'npm i -S not-a-dependency\' to add it',
}],
}),
Expand Down
Loading