Commit efd5e7d
authored
feat: ESLint class migration (#11)
* refactor: make linter asynchronous
Refactor the linter method to run asynchronously because many methods have
been changed to run asynchronously in the new ESLint class.
Preperation for migration to the ESLint class, see #10.
* refactor: make formatter loading asynchronous
Refactor to asynchronous formatter loading because the new ESLint class
loads formatters asynchronously.
Move formatter loading to the linter file for access to the ESLint instance
because the new ESLint loadFormatter method is not static.
Refactor formatter loading to use a CLIEngine instance.
Refactor the linting function to load the formatters.
Preperation for migration to the ESLint class, see #10.
* refactor: add loader option filtering
Refactor to filter out loader options before passing the options to ESLint
because the new ESLint class throws when unknown options are passed to it.
Add method for filtering out loader options and unit tests for it.
Rename the getOptions file options because it now contains option utilities.
It was possible to have getESLintOptions as a private function in
getCLIEngine, but having it exported helps testing.
There is no way to query the ESLint class for the options it received so
there is no way to test it through the getCLIEngine/ESLint method.
Part of the migration to the new ESLint class, see #10.
* refactor: simplify getCLIEngine
Refactor to simplify and remove unnecessary operations.
After the formatter loading refactor the getCLIEngine is no longer used
without starting a CLIEngine.
Remove no longer used options parameter reassignments.
Remove unused eslintPath property from the return object.
Preperation for migration to the ESLint class, see #10.
* refactor: add custom formatter mock
Refactor the custom formatter tests to use a mock.
Refactor to test the error output to make sure the selected formatter
is being used.
The test used to always pass because formatter loading fails silently and
returns the default formatter.
Add a mock formatter.
Remove eslint-friendly-formatter that was only used for the test.
This refactor helps decouple the tests from the results format.
Making the migration to the new ESLint class easier.
Preperation for migration to the ESLint class, see #10.
* chore: update ESLint development dependency
Update ESLint development dependency to version 7 to prepare for migration
to the new ESLint class that was introduced with it.
Part of the migration to the new ESLint class, see #10.
* refactor: migrate tests to the ESLint class
Refactor the ESLint mock to imitate the new ESLint class.
Refactor to simplify mock formatter loading.
Refactor ESLint options because the new API introduces a new options format.
The tests do not pass yet as the plugin has not been refactored.
Part of the migration to the new ESLint class, see #10.
* refactor: migrate to the new ESLint class
Refactor linter to the new ESLint class.
Refactor the getCLIEngine method to getESLint.
Refactor LintDirtyModulesPlugin to remove use of resolveFileGlobPatterns
which is not available in the new API. File paths should work fine as
globs and do not need to be converted.
Completing the migration to the new ESLint class, see #10.
* chore: update package and documentation
Update plugin ESLint peer dependency to remove version 6 support.
Update the readme to reflect the changes to the plugin.
Add warning that the plugin used to use CLIEngine in version 1.
Finishing details of the ESLint class migration.
Closes #10.
* refactor: remove callback from linter function
Refactor to remove an unnecessary callback from the linter function.
It is unnecessary because linter is an async function returning a promise so it
can be used directly with a promise tap.
Preparation for requested change in #11.
* refactor: simplify dirty file linting
Refactor LintDirtyModulesPlugin to only handle dirty file filtering.
The refactor allows for easier testing without the need for mocks.
Rename LintDirtyModulesPlugin to DirtyFileWatcher to make the name more
descriptive of the new functionality.
Refactor the tests for the simplified DirtyFileWatcher.
Refactor the tests to use absolute paths because Webpack passes absolute paths
in the compiler.fileTimestamps map.
Refactor to only test system specific paths. The functionality of the requested
change requires using real paths for some tests which causes issues with
testing both Windows and Unix paths on the same machine.
As the CI runs on Windows, Mac and Linux paths will be tested on all platforms.
Preparation for requested change in #11.
* test: add tests for dirty watch file patterns
Add failing tests that ensure dirty file watching is matching patterns
from the files options exactly like ESLint.
Add folder fixture because handling folder paths requires checking
existence of folders.
Preparation for requested change in #11.
* fix: folder pattern watch issue
Fix issue with folder patterns not working with the lintDirtyModulesOnly option.
The issue was caused by the removal of resolveFileGlobPatterns which resolved
folder patterns into globs matching the correct file extensions.
Resolve requested change in #11.
* refactor: replace remaining callbacks with async functions
Refactor remaining callbacks to async functions to make them consistent with the
rest of the taps that have been refactored.
* fix: use plugin object for linter hook identity
Refactor the linter function to register hooks with the same plugin object
that is used to register the run and watchRun hooks.
* perf: parse patterns to globs only on startup
Refactor to parse patterns only on startup instead of parsing them to
globs on each run.
In watch mode Webpack does not watch it's own configuration so the
plugin configuration does not change when Webpack is running.
Because the file patterns and extensions do not change there is no need
to process them into globs separately for each run.
* docs: add information about the files option
Add more information about the files option to the readme.1 parent e01341c commit efd5e7d
File tree
25 files changed
+767
-455
lines changed- src
- test
- fixtures/folder
- mock
- eslint
- lib
- cli-engine/formatters
- formatters
- formatter
25 files changed
+767
-455
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
| |||
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
82 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
| |||
0 commit comments