Skip to content

Commit

Permalink
refactor!: webpack v4 and nodejs v10 dropped (#105)
Browse files Browse the repository at this point in the history
* refactor!: webpack v4 and nodejs v10 dropped

* style: empty line

* ci: update

* chore: peerDependencies webpack 5.0.0
  • Loading branch information
ricardogobbosouza authored Jul 17, 2021
1 parent 7e96c87 commit 594d84c
Show file tree
Hide file tree
Showing 20 changed files with 9,157 additions and 11,033 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -55,8 +55,8 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10.x, 12.x, 14.x]
webpack-version: [4, latest]
node-version: [12.x, 14.x, 16.x]
webpack-version: [latest]

runs-on: ${{ matrix.os }}

Expand All @@ -68,7 +68,7 @@ jobs:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

Expand Down
56 changes: 4 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,57 +13,11 @@

# eslint-webpack-plugin

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

| | 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
To begin, you'll need to install `eslint-webpack-plugin`:

```bash
npm install eslint-webpack-plugin --save-dev
Expand All @@ -75,9 +29,7 @@ npm install eslint-webpack-plugin --save-dev
npm install eslint --save-dev
```

## Usage

In your webpack configuration:
Then add the plugin to your webpack config. For example:

```js
const ESLintPlugin = require('eslint-webpack-plugin');
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = (api) => {
'@babel/preset-env',
{
targets: {
node: '10.13.0',
node: '12.13.0',
},
},
],
Expand Down
7 changes: 1 addition & 6 deletions declarations/ESLintError.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
export default ESLintError;
declare class ESLintError extends Error {
/**
* @param {string=} messages
*/
constructor(messages?: string | undefined);
}
declare class ESLintError extends Error {}
2 changes: 1 addition & 1 deletion declarations/cjs.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
declare const _exports: typeof plugin.default;
export = _exports;
import plugin = require('.');
import plugin = require('./');
5 changes: 2 additions & 3 deletions declarations/getESLint.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export default function getESLint(
): Linter;
export type ESLint = import('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>;
export type LintTask = (files: string | string[]) => Promise<LintResult[]>;
export type Worker = JestWorker & {
Expand All @@ -46,4 +45,4 @@ export type Linter = {
lintFiles: LintTask;
cleanup: AsyncTask;
};
import JestWorker from 'jest-worker';
import { Worker as JestWorker } from 'jest-worker';
3 changes: 1 addition & 2 deletions declarations/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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 {
/**
* @param {Options} options
Expand Down
15 changes: 5 additions & 10 deletions declarations/linter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@ export type Formatter = import('eslint').ESLint.Formatter;
export type LintResult = import('eslint').ESLint.LintResult;
export type Compiler = import('webpack').Compiler;
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;
};
export type Reporter = () => Promise<Report>;
export type Linter = (files: string | string[]) => void;
Expand Down
2 changes: 1 addition & 1 deletion declarations/options.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ export type PluginOptions = {
outputReport?: OutputReport | undefined;
threads?: (number | boolean) | undefined;
};
export type Options = PluginOptions & import('eslint').ESLint.Options;
export type Options = PluginOptions & ESLintOptions;
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
collectCoverage: true,
testEnvironment: 'node',
testTimeout: 60000,
transformIgnorePatterns: ['node_modules/(?!(arrify)/)'],
};
Loading

0 comments on commit 594d84c

Please sign in to comment.