Skip to content

Added tslint-loader to webpack config, added tslint.json to typescrip… #5969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 38 additions & 21 deletions packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,28 +303,45 @@ module.exports = function(webpackEnv) {

// First, run the linter.
// It's important to do this before Babel processes the JS.
{
test: /\.(js|mjs|jsx)$/,
enforce: 'pre',
use: [
{
options: {
formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'),
// @remove-on-eject-begin
baseConfig: {
extends: [require.resolve('eslint-config-react-app')],
settings: { react: { version: '999.999.999' } },
},
ignore: false,
useEslintrc: false,
// @remove-on-eject-end
...(!useTypeScript
? [
{
test: /\.(js|mjs|jsx)$/,
enforce: 'pre',
use: [
{
options: {
formatter: require.resolve(
'react-dev-utils/eslintFormatter'
),
eslintPath: require.resolve('eslint'),
// @remove-on-eject-begin
baseConfig: {
extends: [require.resolve('eslint-config-react-app')],
settings: { react: { version: '999.999.999' } },
},
ignore: false,
useEslintrc: false,
// @remove-on-eject-end
},
loader: require.resolve('eslint-loader'),
},
],
include: paths.appSrc,
},
loader: require.resolve('eslint-loader'),
},
],
include: paths.appSrc,
},
]
: [
{
test: /\.(ts|tsx)$/,
enforce: 'pre',
use: [
{
loader: require.resolve('tslint-loader'),
},
],
include: paths.appSrc,
},
]),
{
// "oneOf" will traverse all following loaders until one will
// match the requirements. When no loader matches it will fall
Expand Down
4 changes: 4 additions & 0 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
"sass-loader": "7.1.0",
"style-loader": "0.23.0",
"terser-webpack-plugin": "1.1.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.17.0",
"tslint-loader": "^3.5.4",
"tslint-react": "^3.6.0",
"url-loader": "1.1.1",
"webpack": "4.19.1",
"webpack-dev-server": "3.1.9",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/template-typescript/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import logo from './logo.svg';
import './App.css';

class App extends Component {
render() {
public render() {
return (
<div className="App">
<header className="App-header">
Expand Down
14 changes: 14 additions & 0 deletions packages/react-scripts/template-typescript/tslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
"linterOptions": {
"exclude": [
"config/**/*.js",
"node_modules/**/*.ts",
"coverage/lcov-report/*.js",
"src/serviceWorker.ts"
]
},
"rules": {
"ordered-imports": false
}
}