Skip to content

Commit 2ba396d

Browse files
committed
fix: respect eslint extensions in incremental check
1 parent 8a10ca9 commit 2ba396d

File tree

15 files changed

+135
-22
lines changed

15 files changed

+135
-22
lines changed

.DS_Store

-10 KB
Binary file not shown.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ node_modules
1515

1616
# Editor directories and files
1717
.idea
18+
19+
# Mac OS
20+
.DS_Store

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ module.exports = {
6565
If you are using **TypeScript >= 2.8.0**, it's recommended to set `"importsNotUsedAsValues": "preserve"` [compiler option](https://www.typescriptlang.org/docs/handbook/compiler-options.html)
6666
in the `tsconfig.json`. [Here is an explanation.](#type-only-modules-watching)
6767

68+
> You can find examples how to configure it with [babel-loader](https://github.com/babel/babel-loader), [ts-loader](https://github.com/TypeStrong/ts-loader),
69+
> [eslint](https://github.com/eslint/eslint) and [Visual Studio Code](https://code.visualstudio.com/) in the
70+
> [**examples**](./examples) directory.
71+
6872
## Modules resolution
6973

7074
It's very important to be aware that **this plugin uses [TypeScript](https://github.com/Microsoft/TypeScript)'s, not
@@ -97,7 +101,7 @@ module.exports = {
97101
plugins: [
98102
new ForkTsCheckerWebpackPlugin({
99103
eslint: {
100-
files: './src/**/*.ts' // required - same as command `eslint ./src/**/*.ts`
104+
files: './src/**/*' // required - same as command `eslint ./src/**/* --ext .ts,.tsx,.js,.jsx`
101105
}
102106
})
103107
]
@@ -108,19 +112,15 @@ You should also have an ESLint configuration file in your root project directory
108112
Here is a sample `.eslintrc.js` configuration for a TypeScript project:
109113

110114
```js
111-
const path = require('path');
112-
113115
module.exports = {
114-
parser: '@typescript-eslint/parser', // specifies the ESLint parser
115-
extends: [
116-
'plugin:@typescript-eslint/recommended' // uses the recommended rules from the @typescript-eslint/eslint-plugin
117-
],
116+
parser: '@typescript-eslint/parser',
118117
parserOptions: {
119-
project: path.resolve(__dirname, './tsconfig.json'),
120-
tsconfigRootDir: __dirname,
121-
ecmaVersion: 2018, // allows for the parsing of modern ECMAScript features
122-
sourceType: 'module', // allows for the use of imports
118+
ecmaVersion: 2018,
119+
sourceType: 'module',
123120
},
121+
extends: [
122+
'plugin:@typescript-eslint/recommended'
123+
],
124124
rules: {
125125
// place to specify ESLint rules - can be used to overwrite rules specified from the extended configs
126126
// e.g. "@typescript-eslint/explicit-function-return-type": "off",

examples/.DS_Store

-6 KB
Binary file not shown.

examples/eslint/.eslintrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
ecmaVersion: 2018,
5+
sourceType: 'module'
6+
},
7+
extends: ['plugin:@typescript-eslint/recommended']
8+
};

examples/eslint/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## eslint configuration example
2+
3+
It's a basic configuration of the plugin and [eslint](https://github.com/eslint/eslint).

examples/eslint/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "fork-ts-checker-webpack-plugin-ts-loader-example",
3+
"version": "0.0.0",
4+
"main": "dist/index.js",
5+
"license": "MIT",
6+
"scripts": {
7+
"dev": "webpack-dev-server",
8+
"build": "webpack -p"
9+
},
10+
"devDependencies": {
11+
"@types/eslint": "^6.8.0",
12+
"@typescript-eslint/eslint-plugin": "^2.27.0",
13+
"@typescript-eslint/parser": "^2.27.0",
14+
"eslint": "^6.8.0",
15+
"fork-ts-checker-webpack-plugin": "^5.0.0-alpha.9",
16+
"ts-loader": "^7.0.0",
17+
"typescript": "^3.8.0",
18+
"webpack": "^4.0.0",
19+
"webpack-cli": "^3.0.0",
20+
"webpack-dev-server": "^3.0.0"
21+
}
22+
}

examples/eslint/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('Hello world');

examples/eslint/tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES5",
4+
"module": "CommonJS",
5+
"lib": ["ES5", "ScriptHost"],
6+
"moduleResolution": "Node",
7+
"esModuleInterop": true,
8+
"skipLibCheck": true,
9+
"skipDefaultLibCheck": true,
10+
"strict": true,
11+
"baseUrl": "./src",
12+
"outDir": "./dist",
13+
"forceConsistentCasingInFileNames": true,
14+
"importsNotUsedAsValues": "preserve" // this is important for proper files watching
15+
},
16+
"include": ["./src"],
17+
"exclude": ["node_modules"]
18+
}

examples/eslint/webpack.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
2+
3+
module.exports = {
4+
context: __dirname,
5+
entry: './src/index.ts',
6+
resolve: {
7+
extensions: ['.ts', '.tsx', '.js'],
8+
},
9+
module: {
10+
rules: [
11+
{
12+
test: /\.tsx?$/,
13+
loader: 'ts-loader',
14+
exclude: /node_modules/,
15+
options: {
16+
transpileOnly: true,
17+
},
18+
},
19+
],
20+
},
21+
plugins: [
22+
new ForkTsCheckerWebpackPlugin({
23+
eslint: {
24+
enabled: true,
25+
files: './src/**/*',
26+
},
27+
}),
28+
],
29+
};

0 commit comments

Comments
 (0)