Skip to content

Commit

Permalink
Merge pull request import-js#1 from benmosher/master
Browse files Browse the repository at this point in the history
sync with origin master
  • Loading branch information
paztis authored Apr 6, 2020
2 parents 587a1e4 + 6a110dd commit 41c35f9
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 150 deletions.
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This change log adheres to standards from [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]

## [2.20.2] - 2020-03-28
### Fixed
- [`order`]: fix `isExternalModule` detect on windows ([#1651], thanks [@fisker])
- [`order`]: recognize ".." as a "parent" path ([#1658], thanks [@golopot])
Expand Down Expand Up @@ -919,7 +921,8 @@ for info on changes for earlier releases.
[#119]: https://github.com/benmosher/eslint-plugin-import/issues/119
[#89]: https://github.com/benmosher/eslint-plugin-import/issues/89

[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.20.1...HEAD
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.20.2...HEAD
[2.20.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.20.1...v2.20.2
[2.20.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.20.0...v2.20.1
[2.19.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.19.1...v2.20.0
[2.19.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.19.0...v2.19.1
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-import",
"version": "2.20.1",
"version": "2.20.2",
"description": "Import with sanity.",
"engines": {
"node": ">=4"
Expand Down Expand Up @@ -67,14 +67,15 @@
"chai": "^4.2.0",
"coveralls": "^3.0.6",
"cross-env": "^4.0.0",
"eslint": "2.x - 6.x",
"eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.0.0-0",
"eslint-import-resolver-node": "file:./resolvers/node",
"eslint-import-resolver-typescript": "^1.0.2",
"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",
"esquery": "~1.1.0",
"in-publish": "^2.0.0",
"linklocal": "^2.8.2",
"mocha": "^3.5.3",
Expand All @@ -87,7 +88,7 @@
"typescript-eslint-parser": "^22.0.0"
},
"peerDependencies": {
"eslint": "2.x - 6.x"
"eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.0.0-0"
},
"dependencies": {
"array-includes": "^3.0.3",
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 })
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

0 comments on commit 41c35f9

Please sign in to comment.