Skip to content

Commit 242d416

Browse files
author
Adrian Kremer
committed
Added tslint-loader to webpack config, added tslint.json to typescript template since there is currently no way to set this by package.json alá eslintConfig for IDE support
1 parent 013c8f2 commit 242d416

File tree

3 files changed

+52
-21
lines changed

3 files changed

+52
-21
lines changed

packages/react-scripts/config/webpack.config.js

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -303,28 +303,45 @@ module.exports = function(webpackEnv) {
303303

304304
// First, run the linter.
305305
// It's important to do this before Babel processes the JS.
306-
{
307-
test: /\.(js|mjs|jsx)$/,
308-
enforce: 'pre',
309-
use: [
310-
{
311-
options: {
312-
formatter: require.resolve('react-dev-utils/eslintFormatter'),
313-
eslintPath: require.resolve('eslint'),
314-
// @remove-on-eject-begin
315-
baseConfig: {
316-
extends: [require.resolve('eslint-config-react-app')],
317-
settings: { react: { version: '999.999.999' } },
318-
},
319-
ignore: false,
320-
useEslintrc: false,
321-
// @remove-on-eject-end
306+
...(!useTypeScript
307+
? [
308+
{
309+
test: /\.(js|mjs|jsx)$/,
310+
enforce: 'pre',
311+
use: [
312+
{
313+
options: {
314+
formatter: require.resolve(
315+
'react-dev-utils/eslintFormatter'
316+
),
317+
eslintPath: require.resolve('eslint'),
318+
// @remove-on-eject-begin
319+
baseConfig: {
320+
extends: [require.resolve('eslint-config-react-app')],
321+
settings: { react: { version: '999.999.999' } },
322+
},
323+
ignore: false,
324+
useEslintrc: false,
325+
// @remove-on-eject-end
326+
},
327+
loader: require.resolve('eslint-loader'),
328+
},
329+
],
330+
include: paths.appSrc,
322331
},
323-
loader: require.resolve('eslint-loader'),
324-
},
325-
],
326-
include: paths.appSrc,
327-
},
332+
]
333+
: [
334+
{
335+
test: /\.(ts|tsx)$/,
336+
enforce: 'pre',
337+
use: [
338+
{
339+
loader: require.resolve('tslint-loader'),
340+
},
341+
],
342+
include: paths.appSrc,
343+
},
344+
]),
328345
{
329346
// "oneOf" will traverse all following loaders until one will
330347
// match the requirements. When no loader matches it will fall

packages/react-scripts/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
"sass-loader": "7.1.0",
6767
"style-loader": "0.23.0",
6868
"terser-webpack-plugin": "1.1.0",
69+
"tslint": "^5.11.0",
70+
"tslint-config-prettier": "^1.17.0",
71+
"tslint-loader": "^3.5.4",
72+
"tslint-react": "^3.6.0",
6973
"url-loader": "1.1.1",
7074
"webpack": "4.19.1",
7175
"webpack-dev-server": "3.1.9",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
3+
"linterOptions": {
4+
"exclude": [
5+
"config/**/*.js",
6+
"node_modules/**/*.ts",
7+
"coverage/lcov-report/*.js"
8+
]
9+
}
10+
}

0 commit comments

Comments
 (0)