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

New: ESLint Class Replacing CLIEngine #40

Merged
merged 47 commits into from
Jan 6, 2020
Merged
Changes from 2 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b1840be
New: Moving to Asynchronous API
mysticatea Sep 28, 2019
6135383
add PR link
mysticatea Sep 28, 2019
0af99b0
fix to not change existing methods
mysticatea Sep 28, 2019
d9444ef
change getFormatter
mysticatea Oct 1, 2019
e5cc07c
fix getFormatter
mysticatea Oct 2, 2019
be5878c
update
mysticatea Oct 3, 2019
628e262
update Backwards Compatibility Analysis section
mysticatea Oct 3, 2019
cade0bd
add an example
mysticatea Oct 3, 2019
c99ae56
trivial fix
mysticatea Oct 3, 2019
730cb58
Add a note about streams
mysticatea Oct 3, 2019
2ab427f
trivial fix
mysticatea Oct 3, 2019
ed35022
update getErrorResults since it's sandwiched
mysticatea Oct 3, 2019
13354ce
add fail-fast note
mysticatea Oct 4, 2019
2aa4a5e
update
mysticatea Oct 8, 2019
8892dc7
refactor and add about usedDeprecatedRules
mysticatea Oct 13, 2019
7a94b03
fix typo
mysticatea Oct 13, 2019
7b5e401
fix typo
mysticatea Oct 14, 2019
2981228
add about aborting
mysticatea Oct 14, 2019
72e69af
add constructor and remove addPlugin
mysticatea Oct 14, 2019
86689ec
Update motivation section
mysticatea Oct 15, 2019
a76d6c0
Update motivation section
mysticatea Oct 15, 2019
face206
Update design overview
mysticatea Oct 15, 2019
65b67f5
Update constructor description
mysticatea Oct 15, 2019
cedb6e6
Update fail-fast on parallel calling section
mysticatea Oct 15, 2019
8f58df9
Update designs/2019-move-to-async-api/README.md
mysticatea Oct 15, 2019
227fe54
Update designs/2019-move-to-async-api/README.md
mysticatea Oct 15, 2019
4c5cdff
update RFC for more clarification and...
mysticatea Oct 17, 2019
00be95b
add a related discussion
mysticatea Oct 17, 2019
756e929
add about cache when abort
mysticatea Oct 21, 2019
975fa02
add TOC of methods
mysticatea Oct 21, 2019
f22894b
update about disallow execution in parallel
mysticatea Oct 21, 2019
d45e86e
rewrite "Alternatives" section
mysticatea Oct 21, 2019
c5bdf22
revert about errorsOnly and...
mysticatea Oct 21, 2019
6ecf034
small fix
mysticatea Oct 21, 2019
98243b8
remove collectResults method
mysticatea Nov 14, 2019
13650ff
remove getRules()
mysticatea Nov 14, 2019
a860d00
update the sentence about ES modules
mysticatea Nov 14, 2019
eeac990
rename for lintFiles() and lintText()
mysticatea Nov 14, 2019
6a36a14
replace pluginImplementations option
mysticatea Nov 14, 2019
ab978fa
update about cache handling
mysticatea Nov 14, 2019
920c881
rename the new class
mysticatea Nov 22, 2019
8547265
remove about to print progress
mysticatea Nov 30, 2019
c24f337
Update designs/2019-move-to-async-api/README.md
mysticatea Dec 5, 2019
9d4affc
Update designs/2019-move-to-async-api/README.md
mysticatea Dec 8, 2019
5032c3c
Update designs/2019-move-to-async-api/README.md
mysticatea Dec 8, 2019
671cf6a
remove about printing progress
mysticatea Dec 8, 2019
ef4d198
ESLint class again
mysticatea Dec 8, 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
74 changes: 74 additions & 0 deletions designs/2019-move-to-async-api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
- Start Date: 2019-09-28
- RFC PR: https://github.com/eslint/rfcs/pull/40
- Authors: Toru Nagashima ([@mysticatea](https://github.com/mysticatea))

# Moving to Asynchronous API
mysticatea marked this conversation as resolved.
Show resolved Hide resolved

## Summary

This RFC changes the methods of `CLIEngine` class returning `Promise` and adds `CLIEngineSync` class for soft-migration.

## Motivation

- Dynamic loading of ES modules requires asynchronous API. Migrating to asynchronous API opens up doors to write plugins/configs with ES modules.
- Linting in parallel requires asynchronous API. We can improve linting logic to run it in parallel. And we can improve config loading logic and file enumeration logic to run it in parallel. (E.g., load `extends` list, traverse child directories.)

## Detailed Design

### Change the methods of `CLIEngine` class

This RFC changes the following methods as returning `Promise`.

- `executeOnFiles()`
- `executeOnText()`
- `getConfigForFile()`
mysticatea marked this conversation as resolved.
Show resolved Hide resolved
- `getFormatter()`
- `isPathIgnored()`
- `outputFixes()`

The following methods are as-is because those don't touch both file system and module system.

- `addPlugin()`
- `getErrorResults()`
mysticatea marked this conversation as resolved.
Show resolved Hide resolved
- `getRules()`
- `resolveFileGlobPatterns()`

### Add `CLIEngineSync` class

This RFC adds a new public class `CLIEngineSync` for soft-migration. The `CLIEngineSync` class has the completely same interface as the current `CLIEngine`.

### Deprecate `CLIEngineSync` class

This RFC soft-deprecates the new public class `CLIEngineSync`.

Because it's tough to maintain two versions (sync and async) of implementation. The two are almost copy-pasted stuff, but hard to share the code. Therefore, this RFC deprecates the sync version to improve our code with the way which needs asynchronous behavior in the future. For example, `CLIEngineSync` cannot support parallel linting, plugins/configs as ES modules, etc...

### Out of scope

- Not change API for rules. This RFC doesn't change APIs that rule implementation uses. We may be able to support asynchronous stuff in rules in the future, but it's out of this RFC's scope.
- Not change internal logics. This RFC just changes the public interface. The internal logic is still synchronous.

## Documentation

- This change needs the entry in the migration guide because of a breaking change.
- The "[Node.js API](https://eslint.org/docs/developer-guide/nodejs-api)" page should describe the new public API.

## Drawbacks

People that use `CLIEngine` have to update their application with the new asynchronous API. This may be hard work.

## Backwards Compatibility Analysis

Yes, this is a drastic breaking change. New `CLIEngineSync` class is for soft-migration.

## Alternatives

- Adding `engine.executeAsyncOnFiles()`-like methods rather than changing existing methods.
- Adding new `CLIEngineAsync`-like class that has async API rather than we move the existing APIs to `CLIEngineSync`.

## Related Discussions

- https://github.com/eslint/eslint/issues/3565 - Lint multiple files in parallel
- https://github.com/eslint/eslint/issues/12319 - `ERR_REQUIRE_ESM` when requiring `.eslintrc.js`
- https://github.com/eslint/rfcs/pull/4 - New: added draft for async/parallel proposal
- https://github.com/eslint/rfcs/pull/11 - New: Lint files in parallel