Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range 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: a3e5f2388541a6a9f6dd68dcfadefcd6279d9919
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: d225176343d491db07a1c9e6e521ea90f169c928
Choose a head ref
Showing with 6,079 additions and 2,992 deletions.
  1. +1 −0 .editorconfig
  2. +1 −0 .eslintignore
  3. +21 −2 .eslintrc
  4. +155 −0 .github/workflows/native-wsl.yml
  5. +40 −3 .github/workflows/node-4+.yml
  6. +2 −2 .github/workflows/node-pretest.yml
  7. +6 −2 .github/workflows/packages.yml
  8. +2 −1 .nycrc
  9. +0 −40 .travis.yml
  10. +124 −14 CHANGELOG.md
  11. +141 −64 README.md
  12. +0 −165 appveyor.yml
  13. +14 −0 config/flat/errors.js
  14. +19 −0 config/flat/react.js
  15. +26 −0 config/flat/recommended.js
  16. +11 −0 config/flat/warnings.js
  17. +0 −2 config/react.js
  18. +1 −1 config/typescript.js
  19. +43 −1 docs/rules/dynamic-import-chunkname.md
  20. +8 −0 docs/rules/no-cycle.md
  21. +1 −1 docs/rules/no-empty-named-blocks.md
  22. +1 −1 docs/rules/no-extraneous-dependencies.md
  23. +1 −2 docs/rules/no-relative-packages.md
  24. +1 −1 docs/rules/no-restricted-paths.md
  25. +13 −2 docs/rules/no-unused-modules.md
  26. +93 −24 docs/rules/order.md
  27. +26 −0 examples/flat/eslint.config.mjs
  28. +17 −0 examples/flat/package.json
  29. +3 −0 examples/flat/src/depth-zero.js
  30. +3 −0 examples/flat/src/es6/depth-one-dynamic.js
  31. +12 −0 examples/flat/src/exports-unused.ts
  32. +12 −0 examples/flat/src/exports.ts
  33. +7 −0 examples/flat/src/imports.ts
  34. +3 −0 examples/flat/src/jsx.tsx
  35. +14 −0 examples/flat/tsconfig.json
  36. +25 −0 examples/legacy/.eslintrc.cjs
  37. +16 −0 examples/legacy/package.json
  38. +3 −0 examples/legacy/src/depth-zero.js
  39. +3 −0 examples/legacy/src/es6/depth-one-dynamic.js
  40. +12 −0 examples/legacy/src/exports-unused.ts
  41. +12 −0 examples/legacy/src/exports.ts
  42. +7 −0 examples/legacy/src/imports.ts
  43. +3 −0 examples/legacy/src/jsx.tsx
  44. +14 −0 examples/legacy/tsconfig.json
  45. +2 −1 memo-parser/package.json
  46. +23 −15 package.json
  47. +20 −20 resolvers/node/index.js
  48. +2 −1 resolvers/node/package.json
  49. +7 −1 resolvers/webpack/CHANGELOG.md
  50. +300 −293 resolvers/webpack/index.js
  51. +3 −3 resolvers/webpack/package.json
  52. +0 −826 src/ExportMap.js
  53. +48 −0 src/core/fsWalk.js
  54. +24 −25 src/core/importType.js
  55. +5 −4 src/core/packagePath.js
  56. +12 −0 src/core/sourceType.js
  57. +210 −0 src/exportMap/builder.js
  58. +60 −0 src/exportMap/captureDependency.js
  59. +56 −0 src/exportMap/childContext.js
  60. +90 −0 src/exportMap/doc.js
  61. +178 −0 src/exportMap/index.js
  62. +39 −0 src/exportMap/namespace.js
  63. +40 −0 src/exportMap/patternCapture.js
  64. +12 −0 src/exportMap/remotePath.js
  65. +32 −0 src/exportMap/specifier.js
  66. +43 −0 src/exportMap/typescript.js
  67. +171 −0 src/exportMap/visitor.js
  68. +4 −2 src/importDeclaration.js
  69. +31 −0 src/index.js
  70. +20 −3 src/rules/consistent-type-specifier-style.js
  71. +2 −2 src/rules/default.js
  72. +57 −5 src/rules/dynamic-import-chunkname.js
  73. +19 −34 src/rules/export.js
  74. +4 −2 src/rules/first.js
  75. +7 −5 src/rules/named.js
  76. +9 −8 src/rules/namespace.js
  77. +20 −8 src/rules/newline-after-import.js
  78. +3 −2 src/rules/no-absolute-path.js
  79. +3 −1 src/rules/no-amd.js
  80. +4 −2 src/rules/no-commonjs.js
  81. +33 −10 src/rules/no-cycle.js
  82. +6 −3 src/rules/no-default-export.js
  83. +6 −5 src/rules/no-deprecated.js
  84. +116 −91 src/rules/no-duplicates.js
  85. +3 −1 src/rules/no-empty-named-blocks.js
  86. +17 −9 src/rules/no-extraneous-dependencies.js
  87. +4 −3 src/rules/no-import-module-exports.js
  88. +32 −29 src/rules/no-mutable-exports.js
  89. +3 −3 src/rules/no-named-as-default-member.js
  90. +55 −12 src/rules/no-named-as-default.js
  91. +2 −1 src/rules/no-named-export.js
  92. +72 −74 src/rules/no-namespace.js
  93. +2 −1 src/rules/no-relative-packages.js
  94. +4 −3 src/rules/no-relative-parent-imports.js
  95. +13 −12 src/rules/no-restricted-paths.js
  96. +3 −1 src/rules/no-self-import.js
  97. +2 −1 src/rules/no-unassigned-import.js
  98. +204 −56 src/rules/no-unused-modules.js
  99. +2 −1 src/rules/no-useless-path-segments.js
  100. +391 −58 src/rules/order.js
  101. +2 −1 src/rules/unambiguous.js
  102. +92 −0 src/scc.js
  103. +3 −0 tests/files/issue210.config.flat.js
  104. +28 −0 tests/files/just-json-files/eslint.config.js
  105. +4 −0 tests/files/no-named-as-default/exports.js
  106. +2 −0 tests/files/no-named-as-default/misleading-re-exports.js
  107. +1 −0 tests/files/no-named-as-default/no-default-export.js
  108. +2 −0 tests/files/no-named-as-default/re-exports.js
  109. +1 −0 tests/files/no-named-as-default/something.js
  110. +36 −17 tests/src/cli.js
  111. +47 −35 tests/src/core/getExports.js
  112. +14 −0 tests/src/core/parse.js
  113. +121 −0 tests/src/exportMap/childContext.js
  114. +7 −7 tests/src/package.js
  115. +47 −0 tests/src/rule-tester.js
  116. +1 −1 tests/src/rules/consistent-type-specifier-style.js
  117. +1 −1 tests/src/rules/default.js
  118. +333 −389 tests/src/rules/dynamic-import-chunkname.js
  119. +25 −3 tests/src/rules/export.js
  120. +1 −1 tests/src/rules/exports-last.js
  121. +1 −1 tests/src/rules/extensions.js
  122. +1 −1 tests/src/rules/first.js
  123. +1 −1 tests/src/rules/group-exports.js
  124. +1 −1 tests/src/rules/max-dependencies.js
  125. +2 −2 tests/src/rules/named.js
  126. +8 −7 tests/src/rules/namespace.js
  127. +49 −37 tests/src/rules/newline-after-import.js
  128. +1 −1 tests/src/rules/no-absolute-path.js
  129. +1 −1 tests/src/rules/no-amd.js
  130. +1 −1 tests/src/rules/no-anonymous-default-export.js
  131. +21 −27 tests/src/rules/no-commonjs.js
  132. +33 −15 tests/src/rules/no-cycle.js
  133. +10 −1 tests/src/rules/no-default-export.js
  134. +1 −1 tests/src/rules/no-deprecated.js
  135. +127 −109 tests/src/rules/no-duplicates.js
  136. +1 −1 tests/src/rules/no-dynamic-require.js
  137. +2 −1 tests/src/rules/no-empty-named-blocks.js
  138. +22 −12 tests/src/rules/no-extraneous-dependencies.js
  139. +4 −4 tests/src/rules/no-import-module-exports.js
  140. +1 −1 tests/src/rules/no-internal-modules.js
  141. +1 −1 tests/src/rules/no-mutable-exports.js
  142. +1 −1 tests/src/rules/no-named-as-default-member.js
  143. +97 −15 tests/src/rules/no-named-as-default.js
  144. +1 −1 tests/src/rules/no-named-default.js
  145. +10 −1 tests/src/rules/no-named-export.js
  146. +7 −10 tests/src/rules/no-namespace.js
  147. +1 −1 tests/src/rules/no-nodejs-modules.js
  148. +1 −1 tests/src/rules/no-relative-packages.js
  149. +1 −1 tests/src/rules/no-relative-parent-imports.js
  150. +1 −1 tests/src/rules/no-restricted-paths.js
  151. +1 −1 tests/src/rules/no-self-import.js
  152. +1 −1 tests/src/rules/no-unassigned-import.js
  153. +1 −10 tests/src/rules/no-unresolved.js
  154. +90 −14 tests/src/rules/no-unused-modules.js
  155. +1 −1 tests/src/rules/no-useless-path-segments.js
  156. +1 −1 tests/src/rules/no-webpack-loader-syntax.js
  157. +485 −98 tests/src/rules/order.js
  158. +1 −1 tests/src/rules/prefer-default-export.js
  159. +3 −4 tests/src/rules/unambiguous.js
  160. +179 −0 tests/src/scc.js
  161. +4 −4 tests/src/utils.js
  162. +5 −0 utils/.attw.json
  163. +1 −0 utils/.npmignore
  164. +57 −0 utils/CHANGELOG.md
  165. +22 −0 utils/ModuleCache.d.ts
  166. +20 −18 utils/ModuleCache.js
  167. +38 −0 utils/contextCompat.d.ts
  168. +72 −0 utils/contextCompat.js
  169. +10 −0 utils/declaredScope.d.ts
  170. +6 −3 utils/declaredScope.js
  171. +14 −0 utils/hash.d.ts
  172. +8 −2 utils/hash.js
  173. +12 −0 utils/ignore.d.ts
  174. +30 −18 utils/ignore.js
  175. +3 −0 utils/module-require.d.ts
  176. +5 −0 utils/module-require.js
  177. +26 −0 utils/moduleVisitor.d.ts
  178. +31 −20 utils/moduleVisitor.js
  179. +49 −2 utils/package.json
  180. +11 −0 utils/parse.d.ts
  181. +81 −37 utils/parse.js
  182. +3 −0 utils/pkgDir.d.ts
  183. +1 −0 utils/pkgDir.js
  184. +3 −0 utils/pkgUp.d.ts
  185. +4 −0 utils/pkgUp.js
  186. +5 −0 utils/readPkgUp.d.ts
  187. +2 −0 utils/readPkgUp.js
  188. +30 −0 utils/resolve.d.ts
  189. +92 −72 utils/resolve.js
  190. +11 −0 utils/tsconfig.json
  191. +9 −0 utils/types.d.ts
  192. +7 −0 utils/unambiguous.d.ts
  193. +2 −3 utils/unambiguous.js
  194. +9 −0 utils/visit.d.ts
  195. +9 −4 utils/visit.js
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -7,3 +7,4 @@ insert_final_newline = true
indent_style = space
indent_size = 2
end_of_line = lf
quote_type = single
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ tests/files/with-syntax-error
tests/files/just-json-files/invalid.json
tests/files/typescript-d-ts/
resolvers/webpack/test/files
examples
# we want to ignore "tests/files" here, but unfortunately doing so would
# interfere with unit test and fail it for some reason.
# tests/files
23 changes: 21 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@
"no-multiple-empty-lines": [2, { "max": 1, "maxEOF": 1, "maxBOF": 0 }],
"no-return-assign": [2, "always"],
"no-trailing-spaces": 2,
"no-use-before-define": [2, { "functions": true, "classes": true, "variables": true }],
"no-var": 2,
"object-curly-spacing": [2, "always"],
"object-shorthand": ["error", "always", {
@@ -209,10 +210,10 @@
"exports": "always-multiline",
"functions": "never"
}],
"prefer-destructuring": "warn",
"prefer-destructuring": "off",
"prefer-object-spread": "off",
"prefer-rest-params": "off",
"prefer-spread": "warn",
"prefer-spread": "off",
"prefer-template": "off",
}
},
@@ -225,6 +226,24 @@
"no-console": 1,
},
},
{
"files": [
"utils/**", // TODO
],
"rules": {
"no-use-before-define": "off",
},
},
{
"files": [
"resolvers/webpack/index.js",
"resolvers/webpack/test/example.js",
"utils/parse.js",
],
"rules": {
"no-console": "off",
},
},
{
"files": [
"resolvers/*/test/**/*",
155 changes: 155 additions & 0 deletions .github/workflows/native-wsl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
name: Native and WSL

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: ${{ matrix.configuration == 'wsl' && 'wsl-bash {0}' || 'pwsh' }}
strategy:
fail-fast: false
matrix:
os: [windows-2019]
node-version: [18, 16, 14, 12, 10, 8, 6, 4]
configuration: [wsl, native]

steps:
- uses: actions/checkout@v4
- uses: Vampire/setup-wsl@v3
if: matrix.configuration == 'wsl'
with:
distribution: Ubuntu-22.04
- run: curl --version
- name: 'WSL: do all npm install steps'
if: matrix.configuration == 'wsl'
env:
ESLINT_VERSION: 7
TRAVIS_NODE_VERSION: ${{ matrix.node-version }}
run: |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm install --latest-npm ${{ matrix.node-version }}
if [ ${{ matrix.node-version }} -ge 4 ] && [ ${{ matrix.node-version }} -lt 6 ]; then
npm install eslint@4 --no-save --ignore-scripts
npm install
npm install eslint-import-resolver-typescript@1.0.2 --no-save
npm uninstall @angular-eslint/template-parser @typescript-eslint/parser --no-save
fi
if [ ${{ matrix.node-version }} -ge 6 ] && [ ${{ matrix.node-version }} -lt 7 ]; then
npm install eslint@5 --no-save --ignore-scripts
npm install
npm uninstall @angular-eslint/template-parser --no-save
npm install eslint-import-resolver-typescript@1.0.2 @typescript-eslint/parser@3 --no-save
fi
if [ ${{ matrix.node-version }} -ge 7 ] && [ ${{ matrix.node-version }} -lt 8 ]; then
npm install eslint@6 --no-save --ignore-scripts
npm install
npm install eslint-import-resolver-typescript@1.0.2 typescript-eslint-parser@20 --no-save
npm uninstall @angular-eslint/template-parser --no-save
fi
if [ ${{ matrix.node-version }} -eq 8 ]; then
npm install eslint@6 --no-save --ignore-scripts
npm install
npm uninstall @angular-eslint/template-parser --no-save
npm install @typescript-eslint/parser@3 --no-save
fi
if [ ${{ matrix.node-version }} -gt 8 ] && [ ${{ matrix.node-version }} -lt 10 ]; then
npm install eslint@7 --no-save --ignore-scripts
npm install
npm install @typescript-eslint/parser@3 --no-save
fi
if [ ${{ matrix.node-version }} -ge 10 ] && [ ${{ matrix.node-version }} -lt 12 ]; then
npm install
npm install @typescript-eslint/parser@4 --no-save
fi
if [ ${{ matrix.node-version }} -ge 12 ]; then
npm install
fi
npm run copy-metafiles
npm run pretest
npm run tests-only
- name: install dependencies for node <= 10
if: matrix.node-version <= '10' && matrix.configuration == 'native'
run: |
npm install --legacy-peer-deps
npm install eslint@7 --no-save
- name: Install dependencies for node > 10
if: matrix.node-version > '10' && matrix.configuration == 'native'
run: npm install

- name: install the latest version of nyc
if: matrix.configuration == 'native'
run: npm install nyc@latest --no-save

- name: copy metafiles for node <= 8
if: matrix.node-version <= 8 && matrix.configuration == 'native'
env:
ESLINT_VERSION: 6
TRAVIS_NODE_VERSION: ${{ matrix.node-version }}
run: |
npm run copy-metafiles
bash ./tests/dep-time-travel.sh 2>&1
- name: copy metafiles for Node > 8
if: matrix.node-version > 8 && matrix.configuration == 'native'
env:
ESLINT_VERSION: 7
TRAVIS_NODE_VERSION: ${{ matrix.node-version }}
run: |
npm run copy-metafiles
bash ./tests/dep-time-travel.sh 2>&1
- name: install ./resolver dependencies in Native
if: matrix.configuration == 'native'
shell: pwsh
run: |
npm config set package-lock false
$resolverDir = "./resolvers"
Get-ChildItem -Directory $resolverDir |
ForEach {
Write-output $(Resolve-Path $(Join-Path $resolverDir $_.Name))
Push-Location $(Resolve-Path $(Join-Path $resolverDir $_.Name))
npm install
npm ls nyc > $null;
if ($?) {
npm install nyc@latest --no-save
}
Pop-Location
}
- name: run tests in Native
if: matrix.configuration == 'native'
shell: pwsh
run: |
npm run pretest
npm run tests-only
$resolverDir = "./resolvers";
$resolvers = @();
Get-ChildItem -Directory $resolverDir |
ForEach {
$resolvers += "$(Resolve-Path $(Join-Path $resolverDir $_.Name))";
}
$env:RESOLVERS = [string]::Join(";", $resolvers);
foreach ($resolver in $resolvers) {
Set-Location -Path $resolver.Trim('"')
npm run tests-only
Set-Location -Path $PSScriptRoot
}
- name: codecov
uses: codecov/codecov-action@v3.1.5

windows:
runs-on: ubuntu-latest
needs: [build]
steps:
- run: true
43 changes: 40 additions & 3 deletions .github/workflows/node-4+.yml
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@ name: 'Tests: node.js'

on: [pull_request, push]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

@@ -22,13 +26,17 @@ jobs:
latest:
needs: [matrix]
name: 'majors'
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
node-version: ${{ fromJson(needs.matrix.outputs.latest) }}
eslint:
- 9
- 8
- 7
- 6
@@ -38,49 +46,76 @@ jobs:
- 2
include:
- node-version: 'lts/*'
os: ubuntu-latest
eslint: 7
ts-parser: 4
env:
TS_PARSER: 4
- node-version: 'lts/*'
os: ubuntu-latest
eslint: 7
ts-parser: 3
env:
TS_PARSER: 3
- node-version: 'lts/*'
os: ubuntu-latest
eslint: 7
ts-parser: 2
env:
TS_PARSER: 2
exclude:
- node-version: 16
eslint: 9
- node-version: 15
eslint: 9
- node-version: 15
eslint: 8
- node-version: 14
eslint: 9
- node-version: 13
eslint: 9
- node-version: 13
eslint: 8
- node-version: 12
eslint: 9
- node-version: 11
eslint: 9
- node-version: 11
eslint: 8
- node-version: 10
eslint: 9
- node-version: 10
eslint: 8
- node-version: 9
eslint: 9
- node-version: 9
eslint: 8
- node-version: 9
eslint: 7
- node-version: 8
eslint: 9
- node-version: 8
eslint: 8
- node-version: 8
eslint: 7
- node-version: 7
eslint: 9
- node-version: 7
eslint: 8
- node-version: 7
eslint: 7
- node-version: 7
eslint: 6
- node-version: 6
eslint: 9
- node-version: 6
eslint: 8
- node-version: 6
eslint: 7
- node-version: 6
eslint: 6
- node-version: 5
eslint: 9
- node-version: 5
eslint: 8
- node-version: 5
@@ -89,6 +124,8 @@ jobs:
eslint: 6
- node-version: 5
eslint: 5
- node-version: 4
eslint: 9
- node-version: 4
eslint: 8
- node-version: 4
@@ -99,7 +136,7 @@ jobs:
eslint: 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
continue-on-error: ${{ matrix.eslint == 4 && matrix.node-version == 4 }}
name: 'nvm install ${{ matrix.node-version }} && npm install, with eslint ${{ matrix.eslint }}'
@@ -113,7 +150,7 @@ jobs:
skip-ls-check: true
- run: npm run pretest
- run: npm run tests-only
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v3.1.5

node:
name: 'node 4+'
4 changes: 2 additions & 2 deletions .github/workflows/node-pretest.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ jobs:
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v3
# - uses: actions/checkout@v4
# - uses: ljharb/actions/node/install@main
# name: 'nvm install lts/* && npm install'
# with:
@@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
name: 'nvm install lts/* && npm install'
with:
8 changes: 6 additions & 2 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@ name: 'Tests: packages'

on: [pull_request, push]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

permissions:
contents: read

@@ -38,7 +42,7 @@ jobs:
# - utils

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
name: 'nvm install ${{ matrix.node-version }} && npm install'
env:
@@ -50,7 +54,7 @@ jobs:
after_install: npm run copy-metafiles && ./tests/dep-time-travel.sh && cd ${{ matrix.package }} && npm install
skip-ls-check: true
- run: cd ${{ matrix.package }} && npm run tests-only
- uses: codecov/codecov-action@v3
- uses: codecov/codecov-action@v3.1.5

packages:
name: 'packages: all tests'
Loading