Skip to content

Commit a3e5f23

Browse files
authored
Merge branch 'main' into pr/extensions-checkTypeImports
2 parents 6ac3d03 + 6d34c88 commit a3e5f23

File tree

100 files changed

+1410
-856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1410
-856
lines changed

.eslintrc

+26-25
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"ecmaVersion": 2020,
2020
},
2121
"rules": {
22+
"array-bracket-spacing": [2, "never"],
2223
"arrow-body-style": [2, "as-needed"],
2324
"arrow-parens": [2, "always"],
2425
"arrow-spacing": [2, { "before": true, "after": true }],
@@ -188,37 +189,17 @@
188189
"no-console": "off",
189190
},
190191
},
191-
{
192-
"files": "resolvers/**",
193-
"env": {
194-
"es6": false,
195-
},
196-
},
197-
{
198-
"files": "resolvers/webpack/**",
199-
"rules": {
200-
"no-console": 1,
201-
"prefer-template": 0,
202-
"prefer-object-spread": 0,
203-
"prefer-rest-params": 0,
204-
},
205-
"env": {
206-
"es6": true,
207-
},
208-
},
209192
{
210193
"files": [
211-
"resolvers/*/test/**/*",
194+
"resolvers/**",
195+
"utils/**",
212196
],
213197
"env": {
214-
"mocha": true,
215-
"es6": false
198+
"es6": false,
216199
},
217-
},
218-
{
219-
"files": "utils/**",
220200
"parserOptions": {
221-
"ecmaVersion": 6,
201+
"sourceType": "module",
202+
"ecmaVersion": 2016,
222203
},
223204
"rules": {
224205
"comma-dangle": ["error", {
@@ -228,11 +209,31 @@
228209
"exports": "always-multiline",
229210
"functions": "never"
230211
}],
212+
"prefer-destructuring": "warn",
231213
"prefer-object-spread": "off",
214+
"prefer-rest-params": "off",
215+
"prefer-spread": "warn",
232216
"prefer-template": "off",
217+
}
218+
},
219+
{
220+
"files": [
221+
"resolvers/webpack/**",
222+
"utils/**",
223+
],
224+
"rules": {
233225
"no-console": 1,
234226
},
235227
},
228+
{
229+
"files": [
230+
"resolvers/*/test/**/*",
231+
],
232+
"env": {
233+
"mocha": true,
234+
"es6": false
235+
},
236+
},
236237
{
237238
"files": "tests/**",
238239
"env": {

.gitignore

-4
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ resolvers/node/LICENSE
2525
resolvers/webpack/LICENSE
2626
utils/LICENSE
2727
memo-parser/.npmrc
28-
memo-parser/.nycrc
2928
resolvers/node/.npmrc
30-
resolvers/node/.nycrc
3129
resolvers/webpack/.npmrc
32-
resolvers/webpack/.nycrc
3330
utils/.npmrc
34-
utils/.nycrc
3531

3632
# Dependency directory
3733
# Commenting this out is preferred by some people, see

.markdownlint.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"line-length": false,
3+
"ul-indent": {
4+
"start_indent": 1,
5+
"start_indented": true
6+
},
7+
"ul-style": {
8+
"style": "dash"
9+
}
10+
}

.markdownlintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CHANGELOG.md
2+
node_modules

CHANGELOG.md

+42-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,34 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
66

77
## [Unreleased]
88

9+
## [2.29.0] - 2023-10-22
10+
11+
### Added
12+
- TypeScript config: add .cts and .mts extensions ([#2851], thanks [@Zamiell])
13+
- [`newline-after-import`]: new option `exactCount` and docs update ([#1933], thanks [@anikethsaha] and [@reosarevok])
14+
- [`newline-after-import`]: fix `exactCount` with `considerComments` false positive, when there is a leading comment ([#2884], thanks [@kinland])
15+
16+
## [2.28.1] - 2023-08-18
17+
18+
### Fixed
19+
- [`order`]: revert breaking change to single nested group ([#2854], thanks [@yndajas])
20+
21+
### Changed
22+
- [Docs] remove duplicate fixable notices in docs ([#2850], thanks [@bmish])
23+
24+
## [2.28.0] - 2023-07-27
25+
926
### Fixed
1027
- [`no-duplicates`]: remove duplicate identifiers in duplicate imports ([#2577], thanks [@joe-matsec])
1128
- [`consistent-type-specifier-style`]: fix accidental removal of comma in certain cases ([#2754], thanks [@bradzacher])
1229
- [Perf] `ExportMap`: Improve `ExportMap.for` performance on larger codebases ([#2756], thanks [@leipert])
1330
- [`no-extraneous-dependencies`]/TypeScript: do not error when importing inline type from dev dependencies ([#1820], thanks [@andyogo])
14-
* [`order`]: partial fix for [#2687] (thanks [@ljharb])
31+
- [`newline-after-import`]/TypeScript: do not error when re-exporting a namespaced import ([#2832], thanks [@laurens-dg])
32+
- [`order`]: partial fix for [#2687] (thanks [@ljharb])
33+
- [`no-duplicates`]: Detect across type and regular imports ([#2835], thanks [@benkrejci])
34+
- [`extensions`]: handle `.` and `..` properly ([#2778], thanks [@benasher44])
35+
- [`no-unused-modules`]: improve schema (thanks [@ljharb])
36+
- [`no-unused-modules`]: report error on binding instead of parent export ([#2842], thanks [@Chamion])
1537

1638
### Changed
1739
- [Docs] [`no-duplicates`]: fix example schema ([#2684], thanks [@simmo])
@@ -1072,6 +1094,14 @@ for info on changes for earlier releases.
10721094

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

1097+
[#2884]: https://github.com/import-js/eslint-plugin-import/pull/2884
1098+
[#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854
1099+
[#2851]: https://github.com/import-js/eslint-plugin-import/pull/2851
1100+
[#2850]: https://github.com/import-js/eslint-plugin-import/pull/2850
1101+
[#2842]: https://github.com/import-js/eslint-plugin-import/pull/2842
1102+
[#2835]: https://github.com/import-js/eslint-plugin-import/pull/2835
1103+
[#2832]: https://github.com/import-js/eslint-plugin-import/pull/2832
1104+
[#2778]: https://github.com/import-js/eslint-plugin-import/pull/2778
10751105
[#2756]: https://github.com/import-js/eslint-plugin-import/pull/2756
10761106
[#2754]: https://github.com/import-js/eslint-plugin-import/pull/2754
10771107
[#2748]: https://github.com/import-js/eslint-plugin-import/pull/2748
@@ -1526,7 +1556,10 @@ for info on changes for earlier releases.
15261556
[#119]: https://github.com/import-js/eslint-plugin-import/issues/119
15271557
[#89]: https://github.com/import-js/eslint-plugin-import/issues/89
15281558

1529-
[Unreleased]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.5...HEAD
1559+
[Unreleased]: https://github.com/import-js/eslint-plugin-import/compare/v2.29.0...HEAD
1560+
[2.29.0]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.1...v2.29.0
1561+
[2.28.1]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.0...v2.28.1
1562+
[2.28.0]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.5...v2.28.0
15301563
[2.27.5]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.4...v2.27.5
15311564
[2.27.4]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.3...v2.27.4
15321565
[2.27.3]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.2...v2.27.3
@@ -1645,6 +1678,8 @@ for info on changes for earlier releases.
16451678
[@BarryThePenguin]: https://github.com/BarryThePenguin
16461679
[@be5invis]: https://github.com/be5invis
16471680
[@beatrizrezener]: https://github.com/beatrizrezener
1681+
[@benasher44]: https://github.com/benasher44
1682+
[@benkrejci]: https://github.com/benkrejci
16481683
[@benmosher]: https://github.com/benmosher
16491684
[@benmunro]: https://github.com/benmunro
16501685
[@BenoitZugmeyer]: https://github.com/BenoitZugmeyer
@@ -1657,6 +1692,7 @@ for info on changes for earlier releases.
16571692
[@bradzacher]: https://github.com/bradzacher
16581693
[@brendo]: https://github.com/brendo
16591694
[@brettz9]: https://github.com/brettz9
1695+
[@Chamion]: https://github.com/Chamion
16601696
[@charlessuh]: https://github.com/charlessuh
16611697
[@charpeni]: https://github.com/charpeni
16621698
[@cherryblossom000]: https://github.com/cherryblossom000
@@ -1738,13 +1774,15 @@ for info on changes for earlier releases.
17381774
[@kentcdodds]: https://github.com/kentcdodds
17391775
[@kevin940726]: https://github.com/kevin940726
17401776
[@kgregory]: https://github.com/kgregory
1777+
[@kinland]: https://github.com/kinland
17411778
[@kirill-konshin]: https://github.com/kirill-konshin
17421779
[@kiwka]: https://github.com/kiwka
17431780
[@klimashkin]: https://github.com/klimashkin
17441781
[@kmui2]: https://github.com/kmui2
17451782
[@knpwrs]: https://github.com/knpwrs
17461783
[@KostyaZgara]: https://github.com/KostyaZgara
17471784
[@kylemh]: https://github.com/kylemh
1785+
[@laurens-dg]: https://github.com/laurens-dg
17481786
[@laysent]: https://github.com/laysent
17491787
[@le0nik]: https://github.com/le0nik
17501788
[@leipert]: https://github.com/leipert
@@ -1867,5 +1905,7 @@ for info on changes for earlier releases.
18671905
[@wtgtybhertgeghgtwtg]: https://github.com/wtgtybhertgeghgtwtg
18681906
[@xM8WVqaG]: https://github.com/xM8WVqaG
18691907
[@xpl]: https://github.com/xpl
1908+
[@yndajas]: https://github.com/yndajas
18701909
[@yordis]: https://github.com/yordis
1910+
[@Zamiell]: https://github.com/Zamiell
18711911
[@zloirock]: https://github.com/zloirock

CONTRIBUTING.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ Thanks for your interest in helping out! Here are a **few** _weird_ tricks to ~~
66

77
When opening an [issue](#issues):
88

9-
- [ ] search open/closed issues
10-
- [ ] discuss bug/enhancement in new or old issue
9+
- [ ] search open/closed issues
10+
- [ ] discuss bug/enhancement in new or old issue
1111

1212
[PR](#prs) time:
1313

14-
- [ ] write tests
15-
- [ ] implement feature/fix bug
16-
- [ ] update docs
17-
- [ ] make a note in change log
14+
- [ ] write tests
15+
- [ ] implement feature/fix bug
16+
- [ ] update docs
17+
- [ ] make a note in change log
1818

1919
Remember, you don't need to do it all yourself; any of these are helpful! 😎
2020

2121
## How to get started
2222

2323
If you are new to `eslint`, below are a few resources that will help you to familiarize yourself with the project.
2424

25-
- Watch [this presentation](https://www.youtube.com/watch?v=2W9tUnALrLg) to learn the fundamental concept of Abstract Syntax Trees (AST) and the way `eslint` works under the hood.
26-
- Familiarize yourself with the [AST explorer](https://astexplorer.net/) tool. Look into rules in `docs/rules`, create patterns in the rules, then analyze its AST.
27-
- Explore the blog posts on how to create a custom rule. [One blog post](https://blog.yonatan.dev/writing-a-custom-eslint-rule-to-spot-undeclared-props/). [Second blog post](https://betterprogramming.pub/creating-custom-eslint-rules-cdc579694608).
28-
- Read the official `eslint` [developer guide](https://eslint.org/docs/latest/developer-guide/architecture/).
25+
- Watch [this presentation](https://www.youtube.com/watch?v=2W9tUnALrLg) to learn the fundamental concept of Abstract Syntax Trees (AST) and the way `eslint` works under the hood.
26+
- Familiarize yourself with the [AST explorer](https://astexplorer.net/) tool. Look into rules in `docs/rules`, create patterns in the rules, then analyze its AST.
27+
- Explore the blog posts on how to create a custom rule. [One blog post](https://blog.yonatan.dev/writing-a-custom-eslint-rule-to-spot-undeclared-props/). [Second blog post](https://betterprogramming.pub/creating-custom-eslint-rules-cdc579694608).
28+
- Read the official `eslint` [developer guide](https://eslint.org/docs/latest/developer-guide/architecture/).
2929

3030
## Issues
3131

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ rules:
131131
# etc...
132132
```
133133

134-
# TypeScript
134+
## TypeScript
135135

136136
You may use the following snippet or assemble your own config using the granular settings described below it.
137137

@@ -154,7 +154,7 @@ settings:
154154
[`@typescript-eslint/parser`]: https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser
155155
[`eslint-import-resolver-typescript`]: https://github.com/import-js/eslint-import-resolver-typescript
156156

157-
# Resolvers
157+
## Resolvers
158158

159159
With the advent of module bundlers and the current state of modules and module
160160
syntax specs, it's not always obvious where `import x from 'module'` should look
@@ -175,7 +175,7 @@ resolvers are just npm packages, so [third party packages are supported](https:/
175175

176176
You can reference resolvers in several ways (in order of precedence):
177177

178-
- as a conventional `eslint-import-resolver` name, like `eslint-import-resolver-foo`:
178+
- as a conventional `eslint-import-resolver` name, like `eslint-import-resolver-foo`:
179179

180180
```yaml
181181
# .eslintrc.yml
@@ -195,7 +195,7 @@ module.exports = {
195195
}
196196
```
197197

198-
- with a full npm module name, like `my-awesome-npm-module`:
198+
- with a full npm module name, like `my-awesome-npm-module`:
199199

200200
```yaml
201201
# .eslintrc.yml
@@ -214,7 +214,7 @@ module.exports = {
214214
}
215215
```
216216

217-
- with a filesystem path to resolver, defined in this example as a `computed property` name:
217+
- with a filesystem path to resolver, defined in this example as a `computed property` name:
218218

219219
```js
220220
// .eslintrc.js
@@ -336,11 +336,11 @@ If you are using `yarn` PnP as your package manager, add the `.yarn` folder and
336336

337337
Each item in this array is either a folder's name, its subpath, or its absolute prefix path:
338338

339-
- `jspm_modules` will match any file or folder named `jspm_modules` or which has a direct or non-direct parent named `jspm_modules`, e.g. `/home/me/project/jspm_modules` or `/home/me/project/jspm_modules/some-pkg/index.js`.
339+
- `jspm_modules` will match any file or folder named `jspm_modules` or which has a direct or non-direct parent named `jspm_modules`, e.g. `/home/me/project/jspm_modules` or `/home/me/project/jspm_modules/some-pkg/index.js`.
340340

341-
- `packages/core` will match any path that contains these two segments, for example `/home/me/project/packages/core/src/utils.js`.
341+
- `packages/core` will match any path that contains these two segments, for example `/home/me/project/packages/core/src/utils.js`.
342342

343-
- `/home/me/project/packages` will only match files and directories inside this directory, and the directory itself.
343+
- `/home/me/project/packages` will only match files and directories inside this directory, and the directory itself.
344344

345345
Please note that incomplete names are not allowed here so `components` won't match `bower_components` and `packages/ui` won't match `packages/ui-utils` (but will match `packages/ui/utils`).
346346

appveyor.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ matrix:
2626

2727
allow_failures:
2828
- nodejs_version: "4" # for eslint 5
29+
- configuration: WSL
2930

3031
platform:
3132
- x86

config/typescript.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
/**
2-
* Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing.
2+
* This config:
3+
* 1) adds `.jsx`, `.ts`, `.cts`, `.mts`, and `.tsx` as an extension
4+
* 2) enables JSX/TSX parsing
35
*/
46

57
// Omit `.d.ts` because 1) TypeScript compilation already confirms that
68
// types are resolved, and 2) it would mask an unresolved
79
// `.ts`/`.tsx`/`.js`/`.jsx` implementation.
8-
const allExtensions = ['.ts', '.tsx', '.js', '.jsx'];
10+
const typeScriptExtensions = ['.ts', '.cts', '.mts', '.tsx'];
911

10-
module.exports = {
12+
const allExtensions = [...typeScriptExtensions, '.js', '.jsx'];
1113

14+
module.exports = {
1215
settings: {
1316
'import/extensions': allExtensions,
1417
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
1518
'import/parsers': {
16-
'@typescript-eslint/parser': ['.ts', '.tsx'],
19+
'@typescript-eslint/parser': typeScriptExtensions,
1720
},
1821
'import/resolver': {
1922
node: {

docs/rules/consistent-type-specifier-style.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ This rule includes a fixer that will automatically convert your specifiers to th
3737

3838
The rule accepts a single string option which may be one of:
3939

40-
- `'prefer-inline'` - enforces that named type-only specifiers are only ever written with an inline marker; and never as part of a top-level, type-only import.
41-
- `'prefer-top-level'` - enforces that named type-only specifiers only ever written as part of a top-level, type-only import; and never with an inline marker.
40+
- `'prefer-inline'` - enforces that named type-only specifiers are only ever written with an inline marker; and never as part of a top-level, type-only import.
41+
- `'prefer-top-level'` - enforces that named type-only specifiers only ever written as part of a top-level, type-only import; and never with an inline marker.
4242

4343
By default the rule will use the `prefer-inline` option.
4444

docs/rules/default.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ A module path that is [ignored] or not [unambiguously an ES module] will not be
1919
[ignored]: ../README.md#importignore
2020
[unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar
2121

22-
2322
## Rule Details
2423

2524
Given:
@@ -54,7 +53,6 @@ import bar from './bar' // no default export found in ./bar
5453
import baz from './baz' // no default export found in ./baz
5554
```
5655

57-
5856
## When Not To Use It
5957

6058
If you are using CommonJS and/or modifying the exported namespace of any module at
@@ -65,10 +63,9 @@ either, so such a situation will be reported in the importing module.
6563

6664
## Further Reading
6765

68-
- Lee Byron's [ES7] export proposal
69-
- [`import/ignore`] setting
70-
- [`jsnext:main`] (Rollup)
71-
66+
- Lee Byron's [ES7] export proposal
67+
- [`import/ignore`] setting
68+
- [`jsnext:main`] (Rollup)
7269

7370
[ES7]: https://github.com/leebyron/ecmascript-more-export-from
7471
[`import/ignore`]: ../../README.md#importignore

0 commit comments

Comments
 (0)