eslint-webpack-plugin
Advanced tools
Comparing version 2.5.4 to 2.6.0
declare const _exports: typeof plugin.default; | ||
export = _exports; | ||
import plugin = require('.'); | ||
import plugin = require('./'); |
export default ESLintError; | ||
declare class ESLintError extends Error { | ||
/** | ||
* @param {string=} messages | ||
*/ | ||
constructor(messages?: string | undefined); | ||
} | ||
declare class ESLintError extends Error {} |
@@ -35,4 +35,3 @@ /** @typedef {import('eslint').ESLint} ESLint */ | ||
export type LintResult = import('eslint').ESLint.LintResult; | ||
export type Options = import('./options').PluginOptions & | ||
import('eslint').ESLint.Options; | ||
export type Options = import('./options').Options; | ||
export type AsyncTask = () => Promise<void>; | ||
@@ -50,2 +49,2 @@ export type LintTask = (files: string | string[]) => Promise<LintResult[]>; | ||
}; | ||
import JestWorker from 'jest-worker'; | ||
import { Worker as JestWorker } from 'jest-worker'; |
export default ESLintWebpackPlugin; | ||
export type Compiler = import('webpack').Compiler; | ||
export type Options = import('./options').PluginOptions & | ||
import('eslint').ESLint.Options; | ||
export type Options = import('./options').Options; | ||
declare class ESLintWebpackPlugin { | ||
@@ -14,4 +13,12 @@ /** | ||
* @param {Compiler} compiler | ||
* @param {Options} options | ||
* @param {string[]} wanted | ||
* @param {string[]} exclude | ||
*/ | ||
run(compiler: Compiler): Promise<void>; | ||
run( | ||
compiler: Compiler, | ||
options: Options, | ||
wanted: string[], | ||
exclude: string[] | ||
): Promise<void>; | ||
/** | ||
@@ -18,0 +25,0 @@ * @param {Compiler} compiler |
@@ -21,14 +21,9 @@ /** | ||
export type Compilation = import('webpack').Compilation; | ||
export type Source = import('webpack-sources/lib/Source'); | ||
export type Options = import('./options').PluginOptions & | ||
import('eslint').ESLint.Options; | ||
export type FormatterFunction = ( | ||
results: import('eslint').ESLint.LintResult[], | ||
data?: import('eslint').ESLint.LintResultData | undefined | ||
) => string; | ||
export type Options = import('./options').Options; | ||
export type FormatterFunction = import('./options').FormatterFunction; | ||
export type GenerateReport = (compilation: Compilation) => Promise<void>; | ||
export type Report = { | ||
errors?: ESLintError | undefined; | ||
warnings?: ESLintError | undefined; | ||
generateReportAsset?: GenerateReport | undefined; | ||
errors?: ESLintError; | ||
warnings?: ESLintError; | ||
generateReportAsset?: GenerateReport; | ||
}; | ||
@@ -35,0 +30,0 @@ export type Reporter = () => Promise<Report>; |
@@ -72,2 +72,2 @@ /** @typedef {import("eslint").ESLint.Options} ESLintOptions */ | ||
}; | ||
export type Options = PluginOptions & import('eslint').ESLint.Options; | ||
export type Options = PluginOptions & ESLintOptions; |
@@ -6,9 +6,9 @@ "use strict"; | ||
}); | ||
exports.default = getESLint; | ||
exports.loadESLint = loadESLint; | ||
exports.loadESLintThreaded = loadESLintThreaded; | ||
exports.default = getESLint; | ||
var _os = require("os"); | ||
var _jestWorker = _interopRequireDefault(require("jest-worker")); | ||
var _jestWorker = require("jest-worker"); | ||
@@ -19,4 +19,2 @@ var _options = require("./options"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
/** @type {{[key: string]: any}} */ | ||
@@ -101,3 +99,3 @@ const cache = {}; | ||
/** @type {Worker} */ | ||
new _jestWorker.default(source, workerOptions); | ||
new _jestWorker.Worker(source, workerOptions); | ||
/** @type {Linter} */ | ||
@@ -107,3 +105,3 @@ | ||
threads: poolSize, | ||
lintFiles: async (files) => worker && (await worker.lintFiles(files)) || | ||
lintFiles: async files => worker && (await worker.lintFiles(files)) || | ||
/* istanbul ignore next */ | ||
@@ -110,0 +108,0 @@ [], |
@@ -48,13 +48,16 @@ "use strict"; | ||
// this differentiates one from the other when being cached. | ||
this.key = compiler.name || `${this.key}_${counter += 1}`; // If `lintDirtyModulesOnly` is disabled, | ||
this.key = compiler.name || `${this.key}_${counter += 1}`; | ||
const options = { ...this.options, | ||
exclude: (0, _utils.parseFiles)(this.options.exclude || [], this.getContext(compiler)), | ||
extensions: (0, _arrify.default)(this.options.extensions), | ||
files: (0, _utils.parseFiles)(this.options.files || '', this.getContext(compiler)) | ||
}; | ||
const wanted = (0, _utils.parseFoldersToGlobs)(options.files, options.extensions); | ||
const exclude = (0, _utils.parseFoldersToGlobs)(this.options.exclude ? options.exclude : '**/node_modules/**', []); // If `lintDirtyModulesOnly` is disabled, | ||
// execute the linter on the build | ||
if (!this.options.lintDirtyModulesOnly) { | ||
compiler.hooks.run.tapPromise(this.key, this.run); | ||
} // TODO: Figure out want `compiler.watching` is and how to use it in Webpack5. | ||
// From my testing of compiler.watch() ... compiler.watching is always | ||
// undefined (webpack 4 doesn't define it either) I'm leaving it out | ||
// for now. | ||
compiler.hooks.run.tapPromise(this.key, c => this.run(c, options, wanted, exclude)); | ||
} | ||
let isFirstRun = this.options.lintDirtyModulesOnly; | ||
@@ -67,3 +70,3 @@ compiler.hooks.watchRun.tapPromise(this.key, c => { | ||
return this.run(c); | ||
return this.run(c, options, wanted, exclude); | ||
}); | ||
@@ -73,6 +76,9 @@ } | ||
* @param {Compiler} compiler | ||
* @param {Options} options | ||
* @param {string[]} wanted | ||
* @param {string[]} exclude | ||
*/ | ||
async run(compiler) { | ||
async run(compiler, options, wanted, exclude) { | ||
// Do not re-hook | ||
@@ -86,9 +92,2 @@ if ( // @ts-ignore | ||
const options = { ...this.options, | ||
exclude: (0, _utils.parseFiles)(this.options.exclude || [], this.getContext(compiler)), | ||
extensions: (0, _arrify.default)(this.options.extensions), | ||
files: (0, _utils.parseFiles)(this.options.files || '', this.getContext(compiler)) | ||
}; | ||
const wanted = (0, _utils.parseFoldersToGlobs)(options.files, options.extensions); | ||
const exclude = (0, _utils.parseFoldersToGlobs)(this.options.exclude ? options.exclude : '**/node_modules/**', []); | ||
compiler.hooks.thisCompilation.tap(this.key, compilation => { | ||
@@ -95,0 +94,0 @@ /** @type {import('./linter').Linter} */ |
@@ -26,4 +26,2 @@ "use strict"; | ||
/** @typedef {import('webpack-sources').Source} Source */ | ||
/** @typedef {import('./options').Options} Options */ | ||
@@ -30,0 +28,0 @@ |
@@ -6,4 +6,4 @@ "use strict"; | ||
}); | ||
exports.getESLintOptions = getESLintOptions; | ||
exports.getOptions = getOptions; | ||
exports.getESLintOptions = getESLintOptions; | ||
@@ -10,0 +10,0 @@ var _schemaUtils = require("schema-utils"); |
@@ -6,5 +6,5 @@ "use strict"; | ||
}); | ||
exports.jsonStringifyReplacerSortKeys = void 0; | ||
exports.parseFiles = parseFiles; | ||
exports.parseFoldersToGlobs = parseFoldersToGlobs; | ||
exports.jsonStringifyReplacerSortKeys = void 0; | ||
@@ -30,5 +30,5 @@ var _path = require("path"); | ||
function parseFiles(files, context) { | ||
return (0, _arrify.default)(files).map( | ||
return (0, _arrify.default)(files).map(( | ||
/** @type {string} */ | ||
file => (0, _normalizePath.default)((0, _path.resolve)(context, file))); | ||
file) => (0, _normalizePath.default)((0, _path.resolve)(context, file))); | ||
} | ||
@@ -45,8 +45,8 @@ /** | ||
const [prefix, postfix] = extensionsList.length > 1 ? ['{', '}'] : ['', '']; | ||
const extensionsGlob = extensionsList.map( | ||
const extensionsGlob = extensionsList.map(( | ||
/** @type {string} */ | ||
extension => extension.replace(/^\./u, '')).join(','); | ||
return (0, _arrify.default)(patterns).map( | ||
extension) => extension.replace(/^\./u, '')).join(','); | ||
return (0, _arrify.default)(patterns).map(( | ||
/** @type {string} */ | ||
pattern => { | ||
pattern) => { | ||
try { | ||
@@ -53,0 +53,0 @@ // The patterns are absolute because they are prepended with the context. |
{ | ||
"name": "eslint-webpack-plugin", | ||
"version": "2.5.4", | ||
"version": "2.6.0", | ||
"description": "A ESLint plugin for webpack", | ||
@@ -45,42 +45,42 @@ "license": "MIT", | ||
"peerDependencies": { | ||
"eslint": "^7.0.0", | ||
"eslint": "^7.0.0 || ^8.0.0", | ||
"webpack": "^4.0.0 || ^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@types/eslint": "^7.2.6", | ||
"@types/eslint": "^7.28.2", | ||
"arrify": "^2.0.1", | ||
"jest-worker": "^26.6.2", | ||
"micromatch": "^4.0.2", | ||
"jest-worker": "^27.3.1", | ||
"micromatch": "^4.0.4", | ||
"normalize-path": "^3.0.0", | ||
"schema-utils": "^3.0.0" | ||
"schema-utils": "^3.1.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.12.10", | ||
"@babel/core": "^7.12.10", | ||
"@babel/preset-env": "^7.12.11", | ||
"@commitlint/cli": "^11.0.0", | ||
"@commitlint/config-conventional": "^11.0.0", | ||
"@types/fs-extra": "^9.0.6", | ||
"@types/micromatch": "^4.0.1", | ||
"@babel/cli": "^7.16.0", | ||
"@babel/core": "^7.16.0", | ||
"@babel/preset-env": "^7.16.0", | ||
"@commitlint/cli": "^12.1.4", | ||
"@commitlint/config-conventional": "^12.1.4", | ||
"@types/fs-extra": "^9.0.13", | ||
"@types/micromatch": "^4.0.2", | ||
"@types/normalize-path": "^3.0.0", | ||
"@types/webpack": "^4.41.26", | ||
"@types/webpack": "^5.28.0", | ||
"@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-jest": "^26.6.3", | ||
"chokidar": "^3.5.1", | ||
"babel-jest": "^27.3.1", | ||
"chokidar": "^3.5.2", | ||
"cross-env": "^7.0.3", | ||
"del": "^6.0.0", | ||
"del-cli": "^3.0.1", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint": "^8.2.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.25.3", | ||
"fs-extra": "^9.1.0", | ||
"husky": "^4.3.8", | ||
"jest": "^26.6.3", | ||
"lint-staged": "^10.5.3", | ||
"husky": "^6.0.0", | ||
"jest": "^27.3.1", | ||
"lint-staged": "^10.5.4", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.2.1", | ||
"standard-version": "^9.1.0", | ||
"typescript": "^4.1.3", | ||
"webpack": "^5.19.0" | ||
"prettier": "^2.4.1", | ||
"standard-version": "^9.3.2", | ||
"typescript": "^4.4.4", | ||
"webpack": "^5.64.0" | ||
}, | ||
@@ -87,0 +87,0 @@ "keywords": [ |
@@ -16,56 +16,10 @@ <div align="center"> | ||
> A ESLint plugin for webpack | ||
This plugin uses [`eslint`](https://eslint.org/) to find and fix problems in your JavaScript code | ||
## About plugin | ||
## Getting Started | ||
The plugin was born with the purpose of solving some problems of the [eslint-loader](https://github.com/webpack-contrib/eslint-loader). | ||
To begin, you'll need to install `eslint-webpack-plugin`: | ||
| | eslint-webpack-plugin | eslint-loader | | ||
| -------------------------------- | :-------------------: | :----------------------: | | ||
| Easy configuration | :heavy_check_mark: | :heavy_multiplication_x: | | ||
| Generate unique an output report | :heavy_check_mark: | :heavy_multiplication_x: | | ||
| Using cache directly from eslint | :heavy_check_mark: | :heavy_multiplication_x: | | ||
| Lint only changed files | :heavy_check_mark: | :heavy_multiplication_x: | | ||
## Migrate from `eslint-loader` | ||
The loader `eslint-loader` will be deprecated soon, please use this plugin instead. | ||
Before: | ||
```js | ||
module.exports = { | ||
// ... | ||
module: { | ||
rules: [ | ||
{ | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
loader: 'eslint-loader', | ||
options: { | ||
// eslint options (if necessary) | ||
}, | ||
}, | ||
], | ||
}, | ||
// ... | ||
}; | ||
``` | ||
After: | ||
```js | ||
const ESLintPlugin = require('eslint-webpack-plugin'); | ||
module.exports = { | ||
// ... | ||
plugins: [new ESLintPlugin(options)], | ||
// ... | ||
}; | ||
``` | ||
## Install | ||
```bash | ||
npm install eslint-webpack-plugin --save-dev | ||
npm install eslint-webpack-plugin@2 --save-dev | ||
``` | ||
@@ -79,6 +33,4 @@ | ||
## Usage | ||
Then add the plugin to your webpack config. For example: | ||
In your webpack configuration: | ||
```js | ||
@@ -96,7 +48,7 @@ const ESLintPlugin = require('eslint-webpack-plugin'); | ||
You can pass [eslint options](https://eslint.org/docs/developer-guide/nodejs-api#%E2%97%86-new-eslint-options). | ||
You can pass [eslint options](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions). | ||
Note that the config option you provide will be passed to the `ESLint` class. | ||
This is a different set of options than what you'd specify in `package.json` or `.eslintrc`. | ||
See the [eslint docs](https://eslint.org/docs/developer-guide/nodejs-api#%E2%97%86-new-eslint-options) for more details. | ||
See the [eslint docs](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions) for more details. | ||
@@ -117,3 +69,3 @@ **Warning**: In eslint-webpack-plugin version 1 the options were passed to the now deprecated [CLIEngine](https://eslint.org/docs/developer-guide/nodejs-api#cliengine). | ||
Path to `eslint` instance that will be used for linting. If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option. now you dont have to install `eslint`. | ||
Path to `eslint` instance that will be used for linting. If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option. now you don't have to install `eslint`. | ||
@@ -140,3 +92,3 @@ ### `extensions` | ||
Specify directories, files, or globs. Must be relative to `options.context`. | ||
Directories are traveresed recursively looking for files matching `options.extensions`. | ||
Directories are traversed recursively looking for files matching `options.extensions`. | ||
File and glob patterns ignore `options.extensions`. | ||
@@ -149,3 +101,3 @@ | ||
Will enable [ESLint autofix feature](https://eslint.org/docs/developer-guide/nodejs-api#%E2%97%86-eslint-outputfixes-results). | ||
Will enable [ESLint autofix feature](https://eslint.org/docs/developer-guide/nodejs-api#-eslintoutputfixesresults). | ||
@@ -234,12 +186,12 @@ **Be careful: this option will change source files.** | ||
[npm]: https://img.shields.io/npm/v/eslint-webpack-plugin.svg | ||
[npm-url]: https://npmjs.com/package/eslint-webpack-plugin | ||
[node]: https://img.shields.io/node/v/eslint-webpack-plugin.svg | ||
[npm]: https://img.shields.io/npm/v/eslint-webpack-plugin/2x.svg | ||
[npm-url]: https://npmjs.com/package/eslint-webpack-plugin/v/2x | ||
[node]: https://img.shields.io/node/v/eslint-webpack-plugin/2x.svg | ||
[node-url]: https://nodejs.org | ||
[deps]: https://david-dm.org/webpack-contrib/eslint-webpack-plugin.svg | ||
[deps-url]: https://david-dm.org/webpack-contrib/eslint-webpack-plugin | ||
[tests]: https://github.com/webpack-contrib/eslint-webpack-plugin/workflows/eslint-webpack-plugin/badge.svg | ||
[tests]: https://github.com/webpack-contrib/eslint-webpack-plugin/workflows/eslint-webpack-plugin/badge.svg?branch=2.x | ||
[tests-url]: https://github.com/webpack-contrib/eslint-webpack-plugin/actions | ||
[cover]: https://codecov.io/gh/webpack-contrib/eslint-webpack-plugin/branch/master/graph/badge.svg | ||
[cover-url]: https://codecov.io/gh/webpack-contrib/eslint-webpack-plugin | ||
[cover]: https://codecov.io/gh/webpack-contrib/eslint-webpack-plugin/branch/2.x/graph/badge.svg | ||
[cover-url]: https://codecov.io/gh/webpack-contrib/eslint-webpack-plugin/branch/2.x | ||
[chat]: https://badges.gitter.im/webpack/webpack.svg | ||
@@ -246,0 +198,0 @@ [chat-url]: https://gitter.im/webpack/webpack |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42836
20
1054
194
+ Added@eslint-community/eslint-utils@4.4.0(transitive)
+ Added@eslint-community/regexpp@4.11.0(transitive)
+ Added@eslint/eslintrc@2.1.4(transitive)
+ Added@eslint/js@8.57.0(transitive)
+ Added@humanwhocodes/config-array@0.11.14(transitive)
+ Added@humanwhocodes/module-importer@1.0.1(transitive)
+ Added@humanwhocodes/object-schema@2.0.3(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@ungap/structured-clone@1.2.0(transitive)
+ Addedargparse@2.0.1(transitive)
+ Addedeslint@8.57.0(transitive)
+ Addedeslint-scope@7.2.2(transitive)
+ Addedeslint-visitor-keys@3.4.3(transitive)
+ Addedespree@9.6.1(transitive)
+ Addedfastq@1.17.1(transitive)
+ Addedfind-up@5.0.0(transitive)
+ Addedglob-parent@6.0.2(transitive)
+ Addedgraphemer@1.4.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedjs-yaml@4.1.0(transitive)
+ Addedlocate-path@6.0.0(transitive)
+ Addedp-limit@3.1.0(transitive)
+ Addedp-locate@5.0.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removed@babel/code-frame@7.12.11(transitive)
- Removed@babel/helper-validator-identifier@7.24.7(transitive)
- Removed@babel/highlight@7.24.7(transitive)
- Removed@eslint/eslintrc@0.4.3(transitive)
- Removed@humanwhocodes/config-array@0.5.0(transitive)
- Removed@humanwhocodes/object-schema@1.2.1(transitive)
- Removedacorn@7.4.1(transitive)
- Removedajv@8.17.1(transitive)
- Removedansi-colors@4.1.3(transitive)
- Removedansi-styles@3.2.1(transitive)
- Removedargparse@1.0.10(transitive)
- Removedastral-regex@2.0.0(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedemoji-regex@8.0.0(transitive)
- Removedenquirer@2.4.1(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedeslint@7.32.0(transitive)
- Removedeslint-utils@2.1.0(transitive)
- Removedeslint-visitor-keys@1.3.02.1.0(transitive)
- Removedespree@7.3.1(transitive)
- Removedesprima@4.0.1(transitive)
- Removedfast-uri@3.0.1(transitive)
- Removedfunctional-red-black-tree@1.0.1(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedignore@4.0.6(transitive)
- Removedis-fullwidth-code-point@3.0.0(transitive)
- Removedjest-worker@26.6.2(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjs-yaml@3.14.1(transitive)
- Removedjson-schema-traverse@1.0.0(transitive)
- Removedlodash.truncate@4.4.2(transitive)
- Removedprogress@2.0.3(transitive)
- Removedregexpp@3.2.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedsemver@7.6.3(transitive)
- Removedslice-ansi@4.0.0(transitive)
- Removedsprintf-js@1.0.3(transitive)
- Removedstring-width@4.2.3(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedtable@6.8.2(transitive)
- Removedv8-compile-cache@2.4.0(transitive)
Updated@types/eslint@^7.28.2
Updatedjest-worker@^27.3.1
Updatedmicromatch@^4.0.4
Updatedschema-utils@^3.1.1