Skip to content

Commit

Permalink
Merge branch 'main' into pr/extensions-checkTypeImports
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas authored Nov 14, 2023
2 parents 6ac3d03 + 6d34c88 commit a3e5f23
Show file tree
Hide file tree
Showing 100 changed files with 1,410 additions and 856 deletions.
51 changes: 26 additions & 25 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"ecmaVersion": 2020,
},
"rules": {
"array-bracket-spacing": [2, "never"],
"arrow-body-style": [2, "as-needed"],
"arrow-parens": [2, "always"],
"arrow-spacing": [2, { "before": true, "after": true }],
Expand Down Expand Up @@ -188,37 +189,17 @@
"no-console": "off",
},
},
{
"files": "resolvers/**",
"env": {
"es6": false,
},
},
{
"files": "resolvers/webpack/**",
"rules": {
"no-console": 1,
"prefer-template": 0,
"prefer-object-spread": 0,
"prefer-rest-params": 0,
},
"env": {
"es6": true,
},
},
{
"files": [
"resolvers/*/test/**/*",
"resolvers/**",
"utils/**",
],
"env": {
"mocha": true,
"es6": false
"es6": false,
},
},
{
"files": "utils/**",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaVersion": 2016,
},
"rules": {
"comma-dangle": ["error", {
Expand All @@ -228,11 +209,31 @@
"exports": "always-multiline",
"functions": "never"
}],
"prefer-destructuring": "warn",
"prefer-object-spread": "off",
"prefer-rest-params": "off",
"prefer-spread": "warn",
"prefer-template": "off",
}
},
{
"files": [
"resolvers/webpack/**",
"utils/**",
],
"rules": {
"no-console": 1,
},
},
{
"files": [
"resolvers/*/test/**/*",
],
"env": {
"mocha": true,
"es6": false
},
},
{
"files": "tests/**",
"env": {
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ resolvers/node/LICENSE
resolvers/webpack/LICENSE
utils/LICENSE
memo-parser/.npmrc
memo-parser/.nycrc
resolvers/node/.npmrc
resolvers/node/.nycrc
resolvers/webpack/.npmrc
resolvers/webpack/.nycrc
utils/.npmrc
utils/.nycrc

# Dependency directory
# Commenting this out is preferred by some people, see
Expand Down
10 changes: 10 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"line-length": false,
"ul-indent": {
"start_indent": 1,
"start_indented": true
},
"ul-style": {
"style": "dash"
}
}
2 changes: 2 additions & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CHANGELOG.md
node_modules
44 changes: 42 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,34 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange

## [Unreleased]

## [2.29.0] - 2023-10-22

### Added
- TypeScript config: add .cts and .mts extensions ([#2851], thanks [@Zamiell])
- [`newline-after-import`]: new option `exactCount` and docs update ([#1933], thanks [@anikethsaha] and [@reosarevok])
- [`newline-after-import`]: fix `exactCount` with `considerComments` false positive, when there is a leading comment ([#2884], thanks [@kinland])

## [2.28.1] - 2023-08-18

### Fixed
- [`order`]: revert breaking change to single nested group ([#2854], thanks [@yndajas])

### Changed
- [Docs] remove duplicate fixable notices in docs ([#2850], thanks [@bmish])

## [2.28.0] - 2023-07-27

### Fixed
- [`no-duplicates`]: remove duplicate identifiers in duplicate imports ([#2577], thanks [@joe-matsec])
- [`consistent-type-specifier-style`]: fix accidental removal of comma in certain cases ([#2754], thanks [@bradzacher])
- [Perf] `ExportMap`: Improve `ExportMap.for` performance on larger codebases ([#2756], thanks [@leipert])
- [`no-extraneous-dependencies`]/TypeScript: do not error when importing inline type from dev dependencies ([#1820], thanks [@andyogo])
* [`order`]: partial fix for [#2687] (thanks [@ljharb])
- [`newline-after-import`]/TypeScript: do not error when re-exporting a namespaced import ([#2832], thanks [@laurens-dg])
- [`order`]: partial fix for [#2687] (thanks [@ljharb])
- [`no-duplicates`]: Detect across type and regular imports ([#2835], thanks [@benkrejci])
- [`extensions`]: handle `.` and `..` properly ([#2778], thanks [@benasher44])
- [`no-unused-modules`]: improve schema (thanks [@ljharb])
- [`no-unused-modules`]: report error on binding instead of parent export ([#2842], thanks [@Chamion])

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

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

[#2884]: https://github.com/import-js/eslint-plugin-import/pull/2884
[#2854]: https://github.com/import-js/eslint-plugin-import/pull/2854
[#2851]: https://github.com/import-js/eslint-plugin-import/pull/2851
[#2850]: https://github.com/import-js/eslint-plugin-import/pull/2850
[#2842]: https://github.com/import-js/eslint-plugin-import/pull/2842
[#2835]: https://github.com/import-js/eslint-plugin-import/pull/2835
[#2832]: https://github.com/import-js/eslint-plugin-import/pull/2832
[#2778]: https://github.com/import-js/eslint-plugin-import/pull/2778
[#2756]: https://github.com/import-js/eslint-plugin-import/pull/2756
[#2754]: https://github.com/import-js/eslint-plugin-import/pull/2754
[#2748]: https://github.com/import-js/eslint-plugin-import/pull/2748
Expand Down Expand Up @@ -1526,7 +1556,10 @@ for info on changes for earlier releases.
[#119]: https://github.com/import-js/eslint-plugin-import/issues/119
[#89]: https://github.com/import-js/eslint-plugin-import/issues/89

[Unreleased]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.5...HEAD
[Unreleased]: https://github.com/import-js/eslint-plugin-import/compare/v2.29.0...HEAD
[2.29.0]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.1...v2.29.0
[2.28.1]: https://github.com/import-js/eslint-plugin-import/compare/v2.28.0...v2.28.1
[2.28.0]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.5...v2.28.0
[2.27.5]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.4...v2.27.5
[2.27.4]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.3...v2.27.4
[2.27.3]: https://github.com/import-js/eslint-plugin-import/compare/v2.27.2...v2.27.3
Expand Down Expand Up @@ -1645,6 +1678,8 @@ for info on changes for earlier releases.
[@BarryThePenguin]: https://github.com/BarryThePenguin
[@be5invis]: https://github.com/be5invis
[@beatrizrezener]: https://github.com/beatrizrezener
[@benasher44]: https://github.com/benasher44
[@benkrejci]: https://github.com/benkrejci
[@benmosher]: https://github.com/benmosher
[@benmunro]: https://github.com/benmunro
[@BenoitZugmeyer]: https://github.com/BenoitZugmeyer
Expand All @@ -1657,6 +1692,7 @@ for info on changes for earlier releases.
[@bradzacher]: https://github.com/bradzacher
[@brendo]: https://github.com/brendo
[@brettz9]: https://github.com/brettz9
[@Chamion]: https://github.com/Chamion
[@charlessuh]: https://github.com/charlessuh
[@charpeni]: https://github.com/charpeni
[@cherryblossom000]: https://github.com/cherryblossom000
Expand Down Expand Up @@ -1738,13 +1774,15 @@ for info on changes for earlier releases.
[@kentcdodds]: https://github.com/kentcdodds
[@kevin940726]: https://github.com/kevin940726
[@kgregory]: https://github.com/kgregory
[@kinland]: https://github.com/kinland
[@kirill-konshin]: https://github.com/kirill-konshin
[@kiwka]: https://github.com/kiwka
[@klimashkin]: https://github.com/klimashkin
[@kmui2]: https://github.com/kmui2
[@knpwrs]: https://github.com/knpwrs
[@KostyaZgara]: https://github.com/KostyaZgara
[@kylemh]: https://github.com/kylemh
[@laurens-dg]: https://github.com/laurens-dg
[@laysent]: https://github.com/laysent
[@le0nik]: https://github.com/le0nik
[@leipert]: https://github.com/leipert
Expand Down Expand Up @@ -1867,5 +1905,7 @@ for info on changes for earlier releases.
[@wtgtybhertgeghgtwtg]: https://github.com/wtgtybhertgeghgtwtg
[@xM8WVqaG]: https://github.com/xM8WVqaG
[@xpl]: https://github.com/xpl
[@yndajas]: https://github.com/yndajas
[@yordis]: https://github.com/yordis
[@Zamiell]: https://github.com/Zamiell
[@zloirock]: https://github.com/zloirock
20 changes: 10 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ Thanks for your interest in helping out! Here are a **few** _weird_ tricks to ~~

When opening an [issue](#issues):

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

[PR](#prs) time:

- [ ] write tests
- [ ] implement feature/fix bug
- [ ] update docs
- [ ] make a note in change log
- [ ] write tests
- [ ] implement feature/fix bug
- [ ] update docs
- [ ] make a note in change log

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

## How to get started

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

- 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.
- 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.
- 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).
- Read the official `eslint` [developer guide](https://eslint.org/docs/latest/developer-guide/architecture/).
- 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.
- 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.
- 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).
- Read the official `eslint` [developer guide](https://eslint.org/docs/latest/developer-guide/architecture/).

## Issues

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ rules:
# etc...
```

# TypeScript
## TypeScript

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

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

# Resolvers
## Resolvers

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

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

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

```yaml
# .eslintrc.yml
Expand All @@ -195,7 +195,7 @@ module.exports = {
}
```

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

```yaml
# .eslintrc.yml
Expand All @@ -214,7 +214,7 @@ module.exports = {
}
```

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

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

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

- `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`.
- `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`.

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

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

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`).

Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ matrix:

allow_failures:
- nodejs_version: "4" # for eslint 5
- configuration: WSL

platform:
- x86
Expand Down
11 changes: 7 additions & 4 deletions config/typescript.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/**
* Adds `.jsx`, `.ts` and `.tsx` as an extension, and enables JSX/TSX parsing.
* This config:
* 1) adds `.jsx`, `.ts`, `.cts`, `.mts`, and `.tsx` as an extension
* 2) enables JSX/TSX parsing
*/

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

module.exports = {
const allExtensions = [...typeScriptExtensions, '.js', '.jsx'];

module.exports = {
settings: {
'import/extensions': allExtensions,
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx'],
'@typescript-eslint/parser': typeScriptExtensions,
},
'import/resolver': {
node: {
Expand Down
4 changes: 2 additions & 2 deletions docs/rules/consistent-type-specifier-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ This rule includes a fixer that will automatically convert your specifiers to th

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

- `'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.
- `'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.
- `'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.
- `'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.

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

Expand Down
9 changes: 3 additions & 6 deletions docs/rules/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ A module path that is [ignored] or not [unambiguously an ES module] will not be
[ignored]: ../README.md#importignore
[unambiguously an ES module]: https://github.com/bmeck/UnambiguousJavaScriptGrammar


## Rule Details

Given:
Expand Down Expand Up @@ -54,7 +53,6 @@ import bar from './bar' // no default export found in ./bar
import baz from './baz' // no default export found in ./baz
```


## When Not To Use It

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

## Further Reading

- Lee Byron's [ES7] export proposal
- [`import/ignore`] setting
- [`jsnext:main`] (Rollup)

- Lee Byron's [ES7] export proposal
- [`import/ignore`] setting
- [`jsnext:main`] (Rollup)

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

0 comments on commit a3e5f23

Please sign in to comment.