Skip to content

Commit

Permalink
feat: remove eslint support (#607)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: 🧨 ESLint no longer supported by the plugin
  • Loading branch information
piotr-oles committed May 12, 2021
1 parent 438a139 commit 98e4f39
Show file tree
Hide file tree
Showing 43 changed files with 58 additions and 28,059 deletions.
82 changes: 9 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@

## Features

* Speeds up [TypeScript](https://github.com/Microsoft/TypeScript) type checking and [ESLint](https://eslint.org/) linting (by moving each to a separate process) 🏎
* Speeds up [TypeScript](https://github.com/Microsoft/TypeScript) type checking (by moving it to a separate process) 🏎
* Supports modern TypeScript features like [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) and [incremental mode](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#faster-subsequent-builds-with-the---incremental-flag)
* Supports [Vue Single File Component](https://vuejs.org/v2/guide/single-file-components.html) ✅ 
* Displays nice error messages with the [code frame](https://babeljs.io/docs/en/next/babel-code-frame.html) formatter 🌈

## Installation

This plugin requires minimum **Node.js 10**, **Webpack 4**, **TypeScript 2.7** and optionally **ESLint 6**
This plugin requires minimum **Node.js 12**, **Webpack 5**, **TypeScript 3.6**

* If you depend on **TypeScript 2.1 - 2.6.2**, please use [version 4](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v4.1.4) of the plugin.
* If you depend on **Webpack 4**, **TypeScript 2.7 - 3.5.3** or **ESLint** feature, please use [version 6](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v6.2.6) of the plugin.

* If you depend on **Webpack 2**, **Webpack 3**, or **TSLint 4**, please use [version 3](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v3.1.1) of the plugin.
* If you depend on **TypeScript >= 2.1** and **< 2.7** or you can't update to **Node 10**, please use [version 4](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/tree/v4.1.4) of the plugin.
```sh
# with npm
npm install --save-dev fork-ts-checker-webpack-plugin
Expand Down Expand Up @@ -62,9 +63,8 @@ module.exports = {
};
```

> Examples how to configure it with [babel-loader](https://github.com/babel/babel-loader), [ts-loader](https://github.com/TypeStrong/ts-loader),
> [eslint](https://github.com/eslint/eslint) and [Visual Studio Code](https://code.visualstudio.com/) are in the
> [**examples**](./examples) directory.
> Examples how to configure it with [babel-loader](https://github.com/babel/babel-loader), [ts-loader](https://github.com/TypeStrong/ts-loader)
> and [Visual Studio Code](https://code.visualstudio.com/) are in the [**examples**](./examples) directory.
## Modules resolution

Expand All @@ -75,57 +75,6 @@ It's very important to be aware that **this plugin uses [TypeScript](https://git
>
> To debug TypeScript's modules resolution, you can use `tsc --traceResolution` command.
## ESLint

If you'd like to use ESLint with the plugin, ensure you have the relevant dependencies installed:

```sh
# with npm
npm install --save-dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin

# with yarn
yarn add --dev eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
```

Then set up ESLint in the plugin. This is the minimal configuration:
```js
// webpack.config.js
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
// ...the webpack configuration
plugins: [
new ForkTsCheckerWebpackPlugin({
eslint: {
files: './src/**/*.{ts,tsx,js,jsx}' // required - same as command `eslint ./src/**/*.{ts,tsx,js,jsx} --ext .ts,.tsx,.js,.jsx`
}
})
]
};
```

You should also have an ESLint configuration file in your root project directory.
Here is a sample `.eslintrc.js` configuration for a TypeScript project:

```js
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
extends: [
'plugin:@typescript-eslint/recommended'
],
rules: {
// place to specify ESLint rules - can be used to overwrite rules specified from the extended configs
// e.g. "@typescript-eslint/explicit-function-return-type": "off",
}
};
```

There's a [good explanation on setting up TypeScript ESLint support by Robert Cooper](https://dev.to/robertcoopercode/using-eslint-and-prettier-in-a-typescript-project-53jb).

## Options

This plugin uses [`cosmiconfig`](https://github.com/davidtheclark/cosmiconfig). This means that besides the plugin constructor,
Expand All @@ -140,7 +89,6 @@ Options passed to the plugin constructor will overwrite options from the cosmico
| ----------------- | ---------------------------------- | ------------------------------------------------------------------ | ----------- |
| `async` | `boolean` | `compiler.options.mode === 'development'` | If `true`, reports issues **after** webpack's compilation is done. Thanks to that it doesn't block the compilation. Used only in the `watch` mode. |
| `typescript` | `object` or `boolean` | `true` | If a `boolean`, it enables/disables TypeScript checker. If an `object`, see [TypeScript options](#typescript-options). |
| `eslint` | `object` | `undefined` | If `undefined`, it disables ESLint linter. If an `object`, see [ESLint options](#eslint-options). |
| `issue` | `object` | `{}` | See [Issues options](#issues-options). |
| `formatter` | `string` or `object` or `function` | `codeframe` | Available formatters are `basic`, `codeframe` and a custom `function`. To [configure](https://babeljs.io/docs/en/babel-code-frame#options) `codeframe` formatter, pass object: `{ type: 'codeframe', options: { <coderame options> } }`. |
| `logger` | `object` | `{ infrastructure: 'silent', issues: 'console', devServer: true }` | Available loggers are `silent`, `console`, and `webpack-infrastructure`. Infrastructure logger prints additional information, issue logger prints `issues` in the `async` mode. If `devServer` is set to `false`, errors will not be reported to Webpack Dev Server. |
Expand Down Expand Up @@ -173,25 +121,13 @@ Options for the TypeScript checker extensions (`typescript.extensions` option ob
| `vue.enabled` | `boolean` | `false` | Same as the `vue` option |
| `vue.compiler` | `string` | `'vue-template-compiler'` | The package name of the compiler that will be used to parse `.vue` files. You can use `'nativescript-vue-template-compiler'` if you use [nativescript-vue](https://github.com/nativescript-vue/nativescript-vue) |

### ESLint options

Options for the ESLint linter (`eslint` option object).

| Name | Type | Default value | Description |
| -------------------- | ---------------------- | ------------------------- | ----------- |
| `enabled` | `boolean` | `false` | If `true`, it enables ESLint linter. If you set the `files` option, it will be `true` by default. |
| `files` | `string` or `string[]` | This value is required | One or more [glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)) to the files that should be linted. Works the same as the `eslint` command. |
| `memoryLimit` | `number` | `2048` | Memory limit for the linter process in MB. If the process exits with the allocation failed error, try to increase this number. |
| `options` | `object` | `{}` | [Options](https://eslint.org/docs/developer-guide/nodejs-api#cliengine) that can be used to initialize ESLint. |

### Issues options

Options for the issues filtering (`issue` option object).
I could write some plain text explanation of these options but I think code will explain it better:

```typescript
interface Issue {
origin: 'typescript' | 'eslint';
severity: 'error' | 'warning';
code: string;
file?: string;
Expand All @@ -210,7 +146,7 @@ type IssueFilter = IssueMatch | IssuePredicate | (IssueMatch | IssuePredicate)[]
<details>
<summary>Expand example</summary>

Include issues from the `src` directory, exclude eslint issues from `.spec.ts` files:
Include issues from the `src` directory, exclude issues from `.spec.ts` files:

```js
module.exports = {
Expand All @@ -222,7 +158,7 @@ module.exports = {
{ file: '**/src/**/*' }
],
exclude: [
{ origin: 'eslint', file: '**/*.spec.ts' }
{ file: '**/*.spec.ts' }
]
}
})
Expand Down
8 changes: 0 additions & 8 deletions examples/eslint/.eslintrc.js

This file was deleted.

3 changes: 0 additions & 3 deletions examples/eslint/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions examples/eslint/package.json

This file was deleted.

1 change: 0 additions & 1 deletion examples/eslint/src/index.ts

This file was deleted.

18 changes: 0 additions & 18 deletions examples/eslint/tsconfig.json

This file was deleted.

29 changes: 0 additions & 29 deletions examples/eslint/webpack.config.js

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
"@semantic-release/release-notes-generator": "^9.0.1",
"@types/babel__code-frame": "^7.0.2",
"@types/cross-spawn": "^6.0.2",
"@types/eslint": "^7.2.4",
"@types/fs-extra": "^9.0.2",
"@types/jest": "^26.0.14",
"@types/minimatch": "^3.0.1",
Expand Down
7 changes: 0 additions & 7 deletions src/ForkTsCheckerWebpackPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { createForkTsCheckerWebpackPluginState } from './ForkTsCheckerWebpackPlu
import { composeReporterRpcClients, createAggregatedReporter, ReporterRpcClient } from './reporter';
import { assertTypeScriptSupport } from './typescript-reporter/TypeScriptSupport';
import { createTypeScriptReporterRpcClient } from './typescript-reporter/reporter/TypeScriptReporterRpcClient';
import { assertEsLintSupport } from './eslint-reporter/assertEsLintSupport';
import { createEsLintReporterRpcClient } from './eslint-reporter/reporter/EsLintReporterRpcClient';
import { tapStartToConnectAndRunReporter } from './hooks/tapStartToConnectAndRunReporter';
import { tapStopToDisconnectReporter } from './hooks/tapStopToDisconnectReporter';
import { tapAfterCompileToAddDependencies } from './hooks/tapAfterCompileToAddDependencies';
Expand Down Expand Up @@ -63,11 +61,6 @@ class ForkTsCheckerWebpackPlugin implements webpack.Plugin {
reporters.push(createTypeScriptReporterRpcClient(configuration.typescript));
}

if (configuration.eslint.enabled) {
assertEsLintSupport(configuration.eslint);
reporters.push(createEsLintReporterRpcClient(configuration.eslint));
}

if (reporters.length) {
const reporter = createAggregatedReporter(composeReporterRpcClients(reporters));

Expand Down
6 changes: 0 additions & 6 deletions src/ForkTsCheckerWebpackPluginConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ import {
createTypeScriptReporterConfiguration,
TypeScriptReporterConfiguration,
} from './typescript-reporter/TypeScriptReporterConfiguration';
import {
createEsLintReporterConfiguration,
EsLintReporterConfiguration,
} from './eslint-reporter/EsLintReporterConfiguration';
import { createLoggerConfiguration, LoggerConfiguration } from './logger/LoggerConfiguration';

interface ForkTsCheckerWebpackPluginConfiguration {
async: boolean;
typescript: TypeScriptReporterConfiguration;
eslint: EsLintReporterConfiguration;
issue: IssueConfiguration;
formatter: FormatterConfiguration;
logger: LoggerConfiguration;
Expand All @@ -28,7 +23,6 @@ function createForkTsCheckerWebpackPluginConfiguration(
return {
async: options.async === undefined ? compiler.options.mode === 'development' : options.async,
typescript: createTypeScriptReporterConfiguration(compiler, options.typescript),
eslint: createEsLintReporterConfiguration(compiler, options.eslint),
issue: createIssueConfiguration(compiler, options.issue),
formatter: createFormatterConfiguration(options.formatter),
logger: createLoggerConfiguration(compiler, options.logger),
Expand Down
42 changes: 0 additions & 42 deletions src/ForkTsCheckerWebpackPluginOptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"typescript": {
"$ref": "#/definitions/TypeScriptReporterOptions"
},
"eslint": {
"$ref": "#/definitions/EsLintReporterOptions"
},
"formatter": {
"$ref": "#/definitions/FormatterOptions"
},
Expand Down Expand Up @@ -47,10 +44,6 @@
"IssueMatch": {
"type": "object",
"properties": {
"origin": {
"type": "string",
"enum": ["typescript", "eslint"]
},
"severity": {
"type": "string",
"enum": ["error", "warning"]
Expand Down Expand Up @@ -205,41 +198,6 @@
}
]
},
"EsLintReporterOptions": {
"type": "object",
"properties": {
"files": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
},
{
"type": "string"
}
],
"description": "List of glob patterns or files to be linted."
},
"enabled": {
"type": "boolean",
"description": "Enable EsLint reporter."
},
"memoryLimit": {
"type": "number",
"description": "Memory limit for EsLint reporter process."
},
"options": {
"type": "object",
"description": "Custom options to be passed to the EsLint engine.",
"additionalProperties": true
}
},
"required": ["files"]
},
"FormatterOptions": {
"oneOf": [
{
Expand Down
2 changes: 0 additions & 2 deletions src/ForkTsCheckerWebpackPluginOptions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { TypeScriptReporterOptions } from './typescript-reporter/TypeScriptReporterOptions';
import { EsLintReporterOptions } from './eslint-reporter/EsLintReporterOptions';
import { IssueOptions } from './issue/IssueOptions';
import { FormatterOptions } from './formatter';
import LoggerOptions from './logger/LoggerOptions';

interface ForkTsCheckerWebpackPluginOptions {
async?: boolean;
typescript?: TypeScriptReporterOptions;
eslint?: EsLintReporterOptions;
formatter?: FormatterOptions;
issue?: IssueOptions;
logger?: LoggerOptions;
Expand Down

0 comments on commit 98e4f39

Please sign in to comment.