Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: import-js/eslint-plugin-import
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.17.3
Choose a base ref
...
head repository: import-js/eslint-plugin-import
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.18.0
Choose a head ref

Commits on May 28, 2019

  1. Update no-cycle.md

    Alex Page authored May 28, 2019
    Copy the full SHA
    d27aeaf View commit details
  2. Merge pull request #1370 from alex-page/master

    Docs: no cycle, split code examples so file separation is obvious
    ljharb authored May 28, 2019
    Copy the full SHA
    ca4bf95 View commit details

Commits on May 29, 2019

  1. Copy the full SHA
    8b55e8f View commit details
  2. Copy the full SHA
    15e5c61 View commit details

Commits on May 30, 2019

  1. Merge pull request #1371 from golopot/no-unused-modules-handles-class

    [fix] `no-unused-modules`: handle ClassDeclaration
    ljharb authored May 30, 2019
    Copy the full SHA
    0e719c3 View commit details

Commits on Jun 3, 2019

  1. add TS def extensions + defer to TS over JS

    closes #1366, thanks @davidNHK for bringing this up
    benmosher authored Jun 3, 2019
    4
    Copy the full SHA
    e4334e3 View commit details
  2. Copy the full SHA
    9a0455e View commit details

Commits on Jun 6, 2019

  1. Copy the full SHA
    e1c5054 View commit details
  2. Added changelog entry

    swernerx committed Jun 6, 2019
    Copy the full SHA
    4827e72 View commit details

Commits on Jun 11, 2019

  1. Copy the full SHA
    d81a5c8 View commit details
  2. Merge pull request #1375 from swernerx/fix/order-unknown-types

    [New] Added support for correctly ordering `unknown` types e.g. custom aliases
    ljharb authored Jun 11, 2019
    Copy the full SHA
    45bfe47 View commit details

Commits on Jun 17, 2019

  1. [Build] make node 12 pass CI

    golopot committed Jun 17, 2019
    Copy the full SHA
    8974346 View commit details
  2. Merge pull request #1383 from golopot/node-12

    [Build] make node 12 pass CI
    ljharb authored Jun 17, 2019
    Copy the full SHA
    58b41c2 View commit details

Commits on Jun 21, 2019

  1. Copy the full SHA
    4140870 View commit details

Commits on Jun 22, 2019

  1. Merge pull request #1389 from fooloomanzoo/patch-1

    Update no-named-as-default-member.md
    ljharb authored Jun 22, 2019
    Copy the full SHA
    fc65509 View commit details

Commits on Jun 23, 2019

  1. Copy the full SHA
    b5ff64e View commit details
  2. Copy the full SHA
    1029b4f View commit details
  3. Copy the full SHA
    e6ea127 View commit details
  4. Allow ESLint@6

    sheepsteak committed Jun 23, 2019
    Copy the full SHA
    2f1f4da View commit details
  5. Update to @typescript-eslint/parser canary

    Includes fixes for the use of `eslint/lib/util/traverser` that is now removed in ESLint 6
    
    Co-Authored-By: golopot <golopot@gmail.com>
    sheepsteak and golopot committed Jun 23, 2019
    Copy the full SHA
    c2b19d0 View commit details
  6. Copy the full SHA
    d9b7258 View commit details
  7. Copy the full SHA
    3bee716 View commit details
  8. Remove ESLint 6 from allowed failures in Travis

    It's now supported
    sheepsteak committed Jun 23, 2019
    Copy the full SHA
    d7023f6 View commit details
  9. Copy the full SHA
    7e41d29 View commit details

Commits on Jun 24, 2019

  1. Merge pull request #1393 from sheepsteak/eslint-6

    Support ESLint v6
    ljharb authored Jun 24, 2019
    Copy the full SHA
    c8132f2 View commit details
  2. Bump to v2.18.0

    ljharb committed Jun 24, 2019
    Copy the full SHA
    c924f5d View commit details
Showing with 401 additions and 221 deletions.
  1. +11 −4 .travis.yml
  2. +32 −1 CHANGELOG.md
  3. +1 −0 appveyor.yml
  4. +3 −4 config/typescript.js
  5. +6 −0 docs/rules/no-cycle.md
  6. +1 −1 docs/rules/no-named-as-default-member.md
  7. +1 −1 docs/rules/order.md
  8. +0 −18 gulpfile.js
  9. +11 −9 package.json
  10. +13 −3 src/rules/no-unused-modules.js
  11. +3 −2 src/rules/order.js
  12. +1 −0 tests/files/no-unused-modules/file-0.js
  13. +3 −0 tests/files/no-unused-modules/file-q.js
  14. +11 −4 tests/src/core/getExports.js
  15. +1 −1 tests/src/core/parse.js
  16. +13 −13 tests/src/rules/default.js
  17. +1 −1 tests/src/rules/dynamic-import-chunkname.js
  18. +6 −2 tests/src/rules/export.js
  19. +1 −1 tests/src/rules/max-dependencies.js
  20. +22 −18 tests/src/rules/named.js
  21. +10 −9 tests/src/rules/namespace.js
  22. +35 −35 tests/src/rules/newline-after-import.js
  23. +2 −2 tests/src/rules/no-amd.js
  24. +7 −7 tests/src/rules/no-commonjs.js
  25. +6 −6 tests/src/rules/no-cycle.js
  26. +5 −5 tests/src/rules/no-default-export.js
  27. +2 −2 tests/src/rules/no-duplicates.js
  28. +2 −2 tests/src/rules/no-extraneous-dependencies.js
  29. +2 −2 tests/src/rules/no-mutable-exports.js
  30. +5 −5 tests/src/rules/no-named-as-default.js
  31. +1 −1 tests/src/rules/no-named-default.js
  32. +5 −5 tests/src/rules/no-named-export.js
  33. +14 −14 tests/src/rules/no-namespace.js
  34. +7 −7 tests/src/rules/no-relative-parent-imports.js
  35. +6 −6 tests/src/rules/no-unresolved.js
  36. +9 −0 tests/src/rules/no-unused-modules.js
  37. +6 −6 tests/src/rules/no-useless-path-segments.js
  38. +118 −6 tests/src/rules/order.js
  39. +4 −4 tests/src/rules/prefer-default-export.js
  40. +11 −11 tests/src/rules/unambiguous.js
  41. +3 −3 tests/src/utils.js
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: node_js
node_js:
- '12'
- '10'
- '8'
- '6'
@@ -8,7 +9,7 @@ node_js:
os: linux

env:
- ESLINT_VERSION=^6.0.0-alpha
- ESLINT_VERSION=6
- ESLINT_VERSION=5
- ESLINT_VERSION=4
- ESLINT_VERSION=3
@@ -17,6 +18,8 @@ env:
# osx backlog is often deep, so to be polite we can just hit these highlights
matrix:
include:
- env: PACKAGE=resolvers/node
node_js: 12
- env: PACKAGE=resolvers/node
node_js: 10
- env: PACKAGE=resolvers/node
@@ -25,6 +28,8 @@ matrix:
node_js: 6
- env: PACKAGE=resolvers/node
node_js: 4
- env: PACKAGE=resolvers/webpack
node_js: 12
- env: PACKAGE=resolvers/webpack
node_js: 10
- env: PACKAGE=resolvers/webpack
@@ -34,6 +39,9 @@ matrix:
- env: PACKAGE=resolvers/webpack
node_js: 4

- os: osx
env: ESLINT_VERSION=5
node_js: 12
- os: osx
env: ESLINT_VERSION=5
node_js: 10
@@ -51,16 +59,15 @@ matrix:
- node_js: '4'
env: ESLINT_VERSION=5
- node_js: '4'
env: ESLINT_VERSION=^6.0.0-alpha
env: ESLINT_VERSION=6
- node_js: '6'
env: ESLINT_VERSION=^6.0.0-alpha
env: ESLINT_VERSION=6

fast_finish: true
allow_failures:
# issues with typescript deps in this version intersection
- node_js: '4'
env: ESLINT_VERSION=4
- env: ESLINT_VERSION=^6.0.0-alpha

before_install:
- 'nvm install-latest-npm'
33 changes: 32 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,22 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel

## [Unreleased]


## [2.18.0] - 2019-06-24

### Added
- Support eslint v6 ([#1393], thanks [@sheepsteak])
- [`order`]: Adds support for correctly sorting unknown types into a single group ([#1375], thanks [@swernerx])
- [`order`]: add fixer for destructuring commonjs import ([#1372], thanks [@golopot])
- typescript config: add TS def extensions + defer to TS over JS ([#1366], thanks [@benmosher])

### Fixes
- [`no-unused-modules`]: handle ClassDeclaration ([#1371], thanks [@golopot])

### Docs
- [`no-cycle`]: split code examples so file separation is obvious ([#1370], thanks [@alex-page])
- [`no-named-as-default-member`]: update broken link ([#1389], thanks [@fooloomanzoo])

## [2.17.3] - 2019-05-23

### Fixed
@@ -570,6 +586,12 @@ for info on changes for earlier releases.

[`memo-parser`]: ./memo-parser/README.md

[#1393]: https://github.com/benmosher/eslint-plugin-import/pull/1393
[#1389]: https://github.com/benmosher/eslint-plugin-import/pull/1389
[#1375]: https://github.com/benmosher/eslint-plugin-import/pull/1375
[#1372]: https://github.com/benmosher/eslint-plugin-import/pull/1372
[#1371]: https://github.com/benmosher/eslint-plugin-import/pull/1371
[#1370]: https://github.com/benmosher/eslint-plugin-import/pull/1370
[#1363]: https://github.com/benmosher/eslint-plugin-import/pull/1363
[#1358]: https://github.com/benmosher/eslint-plugin-import/pull/1358
[#1356]: https://github.com/benmosher/eslint-plugin-import/pull/1356
@@ -688,6 +710,7 @@ for info on changes for earlier releases.
[#164]: https://github.com/benmosher/eslint-plugin-import/pull/164
[#157]: https://github.com/benmosher/eslint-plugin-import/pull/157

[#1366]: https://github.com/benmosher/eslint-plugin-import/issues/1366
[#1334]: https://github.com/benmosher/eslint-plugin-import/issues/1334
[#1323]: https://github.com/benmosher/eslint-plugin-import/issues/1323
[#1322]: https://github.com/benmosher/eslint-plugin-import/issues/1322
@@ -770,7 +793,11 @@ 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.17.0...HEAD
[Unreleased]: https://github.com/benmosher/eslint-plugin-import/compare/v2.18.0...HEAD
[2.18.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.17.3...v2.18.0
[2.17.3]: https://github.com/benmosher/eslint-plugin-import/compare/v2.17.2...v2.17.3
[2.17.2]: https://github.com/benmosher/eslint-plugin-import/compare/v2.17.1...v2.17.2
[2.17.1]: https://github.com/benmosher/eslint-plugin-import/compare/v2.17.0...v2.17.1
[2.17.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.16.0...v2.17.0
[2.16.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.15.0...v2.16.0
[2.15.0]: https://github.com/benmosher/eslint-plugin-import/compare/v2.14.0...v2.15.0
@@ -919,3 +946,7 @@ for info on changes for earlier releases.
[@charlessuh]: https://github.com/charlessuh
[@kgregory]: https://github.com/kgregory
[@christophercurrie]: https://github.com/christophercurrie
[@alex-page]: https://github.com/alex-page
[@benmosher]: https://github.com/benmosher
[@fooloomanzoo]: https://github.com/fooloomanzoo
[@sheepsteak]: https://github.com/sheepsteak
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Test against this version of Node.js
environment:
matrix:
- nodejs_version: "12"
- nodejs_version: "10"
- nodejs_version: "8"
# - nodejs_version: "6"
7 changes: 3 additions & 4 deletions config/typescript.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
/**
* Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing.
*/
var jsExtensions = ['.js', '.jsx'];
var tsExtensions = ['.ts', '.tsx'];
var allExtensions = jsExtensions.concat(tsExtensions);

var allExtensions = ['.ts', '.tsx', '.d.ts', '.js', '.jsx'];

module.exports = {

settings: {
'import/extensions': allExtensions,
'import/parsers': {
'@typescript-eslint/parser': tsExtensions
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts']
},
'import/resolver': {
'node': {
6 changes: 6 additions & 0 deletions docs/rules/no-cycle.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,9 @@ This includes cycles of depth 1 (imported module imports me) to `Infinity`, if t
import './dep-a.js'

export function b() { /* ... */ }
```

```js
// dep-a.js
import { b } from './dep-b.js' // reported: Dependency cycle detected.
```
@@ -36,12 +38,16 @@ There is a `maxDepth` option available to prevent full expansion of very deep de

// dep-c.js
import './dep-a.js'
```

```js
// dep-b.js
import './dep-c.js'

export function b() { /* ... */ }
```

```js
// dep-a.js
import { b } from './dep-b.js' // not reported as the cycle is at depth 2
```
2 changes: 1 addition & 1 deletion docs/rules/no-named-as-default-member.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ fixed in Babel 6. Before upgrading an existing codebase to Babel 6, it can be
useful to run this lint rule.


[blog]: https://medium.com/@kentcdodds/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution-ad2d5ab93ce0
[blog]: https://kentcdodds.com/blog/misunderstanding-es6-modules-upgrading-babel-tears-and-a-solution


## Rule Details
2 changes: 1 addition & 1 deletion docs/rules/order.md
Original file line number Diff line number Diff line change
@@ -77,7 +77,7 @@ This rule supports the following options:

### `groups: [array]`:

How groups are defined, and the order to respect. `groups` must be an array of `string` or [`string`]. The only allowed `string`s are: `"builtin"`, `"external"`, `"internal"`, `"parent"`, `"sibling"`, `"index"`. The enforced order is the same as the order of each element in a group. Omitted types are implicitly grouped together as the last element. Example:
How groups are defined, and the order to respect. `groups` must be an array of `string` or [`string`]. The only allowed `string`s are: `"builtin"`, `"external"`, `"internal"`, `"unknown"`, `"parent"`, `"sibling"`, `"index"`. The enforced order is the same as the order of each element in a group. Omitted types are implicitly grouped together as the last element. Example:
```js
[
'builtin', // Built-in types are first
18 changes: 0 additions & 18 deletions gulpfile.js

This file was deleted.

20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-import",
"version": "2.17.3",
"version": "2.18.0",
"description": "Import with sanity.",
"engines": {
"node": ">=4"
@@ -15,14 +15,16 @@
"memo-parser"
],
"scripts": {
"build": "babel --quiet --out-dir lib src",
"prebuild": "rimraf lib",
"watch": "npm run mocha -- --watch tests/src",
"pretest": "linklocal",
"posttest": "eslint ./src",
"mocha": "cross-env BABEL_ENV=test NODE_PATH=./src nyc -s mocha -R dot --recursive -t 5s",
"test": "npm run mocha tests/src",
"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": "gulp prepublish",
"prepublish": "npm run build",
"coveralls": "nyc report --reporter lcovonly && cat ./coverage/lcov.info | coveralls"
},
"repository": {
@@ -45,7 +47,10 @@
},
"homepage": "https://github.com/benmosher/eslint-plugin-import",
"devDependencies": {
"@typescript-eslint/parser": "^1.5.0",
"@eslint/import-test-order-redirect-scoped": "file:./tests/files/order-redirect-scoped",
"@typescript-eslint/parser": "1.10.3-alpha.13",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-plugin-istanbul": "^4.1.6",
"babel-preset-es2015-argon": "latest",
@@ -54,16 +59,13 @@
"chai": "^4.2.0",
"coveralls": "^3.0.2",
"cross-env": "^4.0.0",
"eslint": "2.x - 5.x",
"eslint": "2.x - 6.x",
"eslint-import-resolver-node": "file:./resolvers/node",
"eslint-import-resolver-typescript": "^1.0.2",
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
"eslint-module-utils": "file:./utils",
"eslint-import-test-order-redirect": "file:./tests/files/order-redirect",
"@eslint/import-test-order-redirect-scoped": "file:./tests/files/order-redirect-scoped",
"eslint-module-utils": "file:./utils",
"eslint-plugin-import": "2.x",
"gulp": "^3.9.1",
"gulp-babel": "6.1.2",
"linklocal": "^2.8.2",
"mocha": "^3.5.3",
"nyc": "^11.9.0",
@@ -75,7 +77,7 @@
"typescript-eslint-parser": "^22.0.0"
},
"peerDependencies": {
"eslint": "2.x - 5.x"
"eslint": "2.x - 6.x"
},
"dependencies": {
"array-includes": "^3.0.3",
16 changes: 13 additions & 3 deletions src/rules/no-unused-modules.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,10 @@ try {
var FileEnumerator = require('eslint/lib/cli-engine/file-enumerator').FileEnumerator
listFilesToProcess = function (src) {
var e = new FileEnumerator()
return Array.from(e.iterateFiles(src))
return Array.from(e.iterateFiles(src), ({ filePath, ignored }) => ({
ignored,
filename: filePath,
}))
}
} catch (e1) {
try {
@@ -33,6 +36,7 @@ const IMPORT_NAMESPACE_SPECIFIER = 'ImportNamespaceSpecifier'
const IMPORT_DEFAULT_SPECIFIER = 'ImportDefaultSpecifier'
const VARIABLE_DECLARATION = 'VariableDeclaration'
const FUNCTION_DECLARATION = 'FunctionDeclaration'
const CLASS_DECLARATION = 'ClassDeclaration'
const DEFAULT = 'default'

let preparationDone = false
@@ -390,7 +394,10 @@ module.exports = {
})
}
if (declaration) {
if (declaration.type === FUNCTION_DECLARATION) {
if (
declaration.type === FUNCTION_DECLARATION ||
declaration.type === CLASS_DECLARATION
) {
newExportIdentifiers.add(declaration.id.name)
}
if (declaration.type === VARIABLE_DECLARATION) {
@@ -712,7 +719,10 @@ module.exports = {
checkUsage(node, specifier.exported.name)
})
if (node.declaration) {
if (node.declaration.type === FUNCTION_DECLARATION) {
if (
node.declaration.type === FUNCTION_DECLARATION ||
node.declaration.type === CLASS_DECLARATION
) {
checkUsage(node, node.declaration.id.name)
}
if (node.declaration.type === VARIABLE_DECLARATION) {
5 changes: 3 additions & 2 deletions src/rules/order.js
Original file line number Diff line number Diff line change
@@ -140,7 +140,8 @@ function isPlainRequireModule(node) {
return false
}
const decl = node.declarations[0]
const result = (decl.id != null && decl.id.type === 'Identifier') &&
const result = decl.id &&
(decl.id.type === 'Identifier' || decl.id.type === 'ObjectPattern') &&
decl.init != null &&
decl.init.type === 'CallExpression' &&
decl.init.callee != null &&
@@ -258,7 +259,7 @@ function isInVariableDeclarator(node) {
(node.type === 'VariableDeclarator' || isInVariableDeclarator(node.parent))
}

const types = ['builtin', 'external', 'internal', 'parent', 'sibling', 'index']
const types = ['builtin', 'external', 'internal', 'unknown', 'parent', 'sibling', 'index']

// Creates an object with type-rank pairs.
// Example: { index: 0, sibling: 1, parent: 1, external: 1, builtin: 2, internal: 2 }
1 change: 1 addition & 0 deletions tests/files/no-unused-modules/file-0.js
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import { e } from './file-e'
import { e2 } from './file-e'
import { h2 } from './file-h'
import * as l from './file-l'
import {q} from './file-q'
export * from './file-n'
export { default, o0, o3 } from './file-o'
export { p } from './file-p'
3 changes: 3 additions & 0 deletions tests/files/no-unused-modules/file-q.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export class q {
q0() {}
}
Loading