Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: Config File Improvements #13

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3063740
New: Config File Improvements
mysticatea Feb 24, 2019
3735681
rename
mysticatea Feb 24, 2019
a499902
rename
mysticatea Feb 25, 2019
efc66dd
update diagrams
mysticatea Feb 25, 2019
952cc4b
update a diagram
mysticatea Feb 25, 2019
b0d428f
fix typoa
mysticatea Feb 25, 2019
6f13be8
update about relatively loading for plugins
mysticatea Feb 25, 2019
80463d4
fix typo
not-an-aardvark Feb 25, 2019
6dd2d7b
correct English
not-an-aardvark Feb 25, 2019
6c1b4af
update summary
mysticatea Feb 25, 2019
2fa755e
small fix
mysticatea Feb 25, 2019
7103b2e
update diagrams
mysticatea Feb 26, 2019
1f807bf
add descriptions about user-facing changes
mysticatea Feb 26, 2019
77a50ad
update format about user-facing changes
mysticatea Feb 26, 2019
12b1e3d
remove p
mysticatea Feb 26, 2019
0e9dfc9
small fix
mysticatea Feb 26, 2019
fa248f6
add notes about Linter's change
mysticatea Feb 26, 2019
5a00446
fix format of notes
mysticatea Feb 26, 2019
08c8f43
add note for `--sdtin`
mysticatea Feb 26, 2019
4782e4a
update about plugin conflict
mysticatea Feb 26, 2019
cdf29fb
small fix
mysticatea Feb 26, 2019
f8f6724
remove about plugin resolution change in favor of #14.
mysticatea Feb 27, 2019
aefba74
update about plugin resolution change
mysticatea Mar 7, 2019
10f3b57
update Documentation section
mysticatea Mar 7, 2019
c385c43
update Documentation section
mysticatea Mar 7, 2019
c0d06aa
update examples
mysticatea Mar 7, 2019
cfca969
separate enhancements from the core proposal
mysticatea Mar 8, 2019
b8f10f1
add note
mysticatea Mar 8, 2019
3a42fdd
fix example
mysticatea Mar 8, 2019
bc611b8
fix example
mysticatea Mar 8, 2019
ec642f3
fix example
mysticatea Mar 8, 2019
dd6e563
add a link to PoC
mysticatea Mar 8, 2019
0e97f30
update `config.withConvert`
mysticatea Mar 10, 2019
ce52698
add notes for #10
mysticatea Mar 10, 2019
0cda5c8
fix a wrong link
mysticatea Mar 11, 2019
bb730d4
remove Plugin Resolution Change enhancement
mysticatea Mar 13, 2019
cde52c0
add deprecation of --rulesdir
mysticatea Mar 13, 2019
b9b97e3
small fix
mysticatea Mar 13, 2019
42cd563
fix copy-paste error
mysticatea Mar 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
359 changes: 359 additions & 0 deletions designs/2019-eslintrc-improvements/README.md

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions designs/2019-eslintrc-improvements/diagrams.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
@startuml current-deps
rectangle "depending on fs" {
object CLIEngine
object Config
object Plugins
object GlobUtils
}
object Linter
object ConfigCache
object Environments
object Rules
object "config object" as ConfigData
object "parser object" as Parser
object "plugin object" as Plugin
object "env object" as Environment
object "rule object" as Rule

CLIEngine *-->"1" Linter
CLIEngine *-->"1" Config
CLIEngine *-->"1" GlobUtils
Config -->"1" Linter
Config *-->"1" ConfigCache : "register"
Config *-->"1" Plugins : "use"
Config ..> ConfigData : "load"
Config ..> Environments : "use"
Plugins -->"1" Environments : "register"
Plugins -->"1" Linter
Plugins ..> Rules : "register"
Plugins *-->"0..*" Plugin : "load"
Linter *-->"*" Parser : "load"
Linter *-->"1" Rules
Linter *-->"1" Environments
Linter ..> ConfigData : "use"
Environments -->"0..*" Environment
Rules -->"0..*" Rule
Plugin *-->"0..*" Rule
Plugin *-->"0..*" Environment
@enduml

@startuml new-deps
rectangle "depending on fs" {
object CLIEngine
object FileEnumerator
object ConfigArrayFactory
}
object Linter
object ConfigArray
object ConfigArrayElement
object "parser object" as Parser
object "plugin object" as Plugin
object "env object" as Environment
object "rule object" as Rule

CLIEngine *-->"1" Linter
CLIEngine *-->"1" FileEnumerator
Linter ..> ConfigArray
FileEnumerator *-->"1" ConfigArrayFactory
ConfigArrayFactory ..> ConfigArray : "load"
ConfigArrayFactory ..> Parser : "load"
ConfigArrayFactory ..> Plugin : "load"
ConfigArray *-->"0..*" ConfigArrayElement
ConfigArrayElement o-->"0..1" Parser
ConfigArrayElement o-->"0..*" Plugin
Plugin *-->"0..*" Rule
Plugin *-->"0..*" Environment
@enduml
51 changes: 51 additions & 0 deletions designs/2019-eslintrc-improvements/diagrams/current-deps.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions designs/2019-eslintrc-improvements/diagrams/new-deps.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions designs/2019-eslintrc-improvements/major-01-additional-lint-targets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Config File Improvements: Additional Lint Targets

## Summary

This proposal adds the ability to specify additional target files in configuration files. This enhancement will solve the pain that people have to use `--ext` option with wanted file extensions even if they use plugins.

## Motivation

People have to use `--ext` option or glob patterns to check wanted files even if they use plugins to support additional file types.

```yml
plugins:
- markdown
- html
- "@typescript-eslint"
- react
- vue
```

```bash
# ESLint checks only `*.js`.
eslint src docs

# Needs `--ext` option
eslint src docs --ext .js,.md,.html,.ts,.jsx,.tsx,.vue
```

## Detailed Design

> Proof of Concept (implementation): https://github.com/eslint/eslint/tree/proof-of-concept/config-array-in-eslintrc

This proposal enhances [there](README.md#additional-lint-targets).

When `FileEnumerator` checks if a file is matched by the given extensions, additionally, it checks the file is matched by any of `files` property of configs (except `files` patterns which end with `*` to avoid unlimited).

> [lib/lookup/file-enumerator.js#L338](https://github.com/eslint/eslint/blob/153640180a8944af3a1c488462ed30d0c215f5ed/lib/_lookup/file-enumerator.js#L338) in PoC.

<table><td>
💡 <b>Example</b>:
<pre lang="yml">
overrides:
- files: "*.ts"
extends: "plugin:@typescript-eslint/recommended"
</pre>

With the above config, `eslint .` command will check `*.ts` files additionally.
</td></table>

If a plugin has file extension processors, [it yields config array elements which have `overrides` property](README.md#yield-file-extension-processor-element), so this enhancement affects file extension processors.

<table><td>
💡 <b>Example</b>:
<pre lang="yml">
plugins:
- vue # has `.vue` processor
</pre>

With the above config, `eslint .` command will check `*.vue` files additionally.
</td></table>

The ignoring configuration (`.eslintignore`) is prior to this enhancement. If `.eslintignore` contains the additional target files, ESLint just ignores those as same as currently.

## Documentation

This enhancement needs migration guide because of a breaking change.

- If your config contains `overrides` property or plugins which have file extension processors, `eslint` command with directory paths lints the files which are matched automatically. This may increase errors of your command.<br>
If you don't want to add file types to check, please use glob patterns instead of directory paths.

This enhancement, so it needs to update some documents.

- In the description of `--ext` CLI option, it should say that your config file may add file types automatically.
- In the description of `overrides` property, it should say that the `overrides[].files` property adds target files automatically.
- In the description of `plugins` property, it should say that plugins which have file extension processors add target files automatically.
- In the "working with plugins" page, it should say that file extension processors add target files automatically.

## Drawbacks

- This is a breaking change.
- Implicit behavior may make people confused.

## Backwards Compatibility Analysis

In the following situation, `eslint` command increases errors.

- Their configuration has `overrides` property (with `files` property which doesn't end with `*`) or plugins which have file extension processors.
- Their `eslint` command is using directory paths without `--ext` option.

I guess that the impact is limited because people use `--ext` option or glob patterns if they use configuration which affects files other than `*.js`.

## Alternatives

- To add `extensions` property that behaves as same as `--est` option. Explicit reduces confusion. However, plugins and shareable configs cannot add the `extensions` property without the breaking change that drops old ESLint support.

## Open Questions

-

## Frequently Asked Questions

-

## Related Discussions

- [eslint/eslint#11223](https://github.com/eslint/eslint/issues/11223)
Loading