Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 260c2e1

Browse files
committed
Replace tslint with eslint+prettier.
1 parent 47cfef9 commit 260c2e1

File tree

7 files changed

+668
-69
lines changed

7 files changed

+668
-69
lines changed

.eslintrc.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module.exports = {
2+
extends: [
3+
"plugin:react/recommended", // Uses the recommended rules from @eslint-plugin-react
4+
"plugin:@typescript-eslint/recommended", // Uses the recommended rules from the @typescript-eslint/eslint-plugin
5+
"prettier/@typescript-eslint", // Uses eslint-config-prettier to disable ESLint rules from @typescript-eslint/eslint-plugin that would conflict with prettier
6+
"plugin:prettier/recommended" // Enables eslint-plugin-prettier and eslint-config-prettier. This will display prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
7+
],
8+
parser: "@typescript-eslint/parser",
9+
parserOptions: {
10+
project: "tsconfig.json",
11+
sourceType: "module",
12+
ecmaVersion: 2020,
13+
ecmaFeatures: {
14+
jsx: true // Allows for the parsing of JSX
15+
}
16+
},
17+
plugins: [
18+
"@typescript-eslint"
19+
],
20+
settings: {
21+
react: {
22+
version: "detect" // Tells eslint-plugin-react to automatically detect the version of React to use
23+
}
24+
},
25+
// Fine tune rules
26+
rules: {
27+
"@typescript-eslint/no-var-requires": 0
28+
},
29+
};

.prettierrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
semi: true,
3+
trailingComma: "all",
4+
};

README.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
* **[React](https://facebook.github.io/react/)** (16.x)
55
* **[Webpack](https://webpack.js.org/)** (4.x)
66
* **[Typescript](https://www.typescriptlang.org/)** (3.x)
7-
* **[Hot Module Replacement (HMR)](https://webpack.js.org/concepts/hot-module-replacement/)** using [React Hot Loader](https://github.com/gaearon/react-hot-loader) (4.x)
8-
* [Babel](http://babeljs.io/) (7.x)
9-
* [SASS](http://sass-lang.com/)
10-
* [Jest](https://facebook.github.io/jest/) - Testing framework for React applications
11-
* Production build script
12-
* Image loading/minification using [Image Webpack Loader](https://github.com/tcoopman/image-webpack-loader)
13-
* Typescript compiling using [Awesome Typescript Loader](https://github.com/s-panferov/awesome-typescript-loader) (5.x)
14-
* Code quality (linting) for Typescript.
7+
* **[Hot Module Replacement (HMR)](https://webpack.js.org/concepts/hot-module-replacement/)** ([React Hot Loader](https://github.com/gaearon/react-hot-loader))
8+
* Production build script (Webpack)
9+
* Image loading/minification ([Image Webpack Loader](https://github.com/tcoopman/image-webpack-loader))
10+
* [SASS](http://sass-lang.com/) support
11+
* Code linting ([ESLint](https://github.com/eslint/eslint)) and formatting ([Prettier](https://github.com/prettier/prettier))
12+
* Test framework ([Jest](https://facebook.github.io/jest/))
1513

1614
## Installation
1715
1. Clone/download repo
@@ -42,8 +40,8 @@ Command | Description
4240
`yarn run start-prod` | Build app once (HMR disabled) to `/dist/` and serve @ `http://localhost:3000`
4341
`yarn run build` | Build app to `/dist/`
4442
`yarn run test` | Run tests
45-
`yarn run lint` | Run Typescript linter
46-
`yarn run lint --fix` | Run Typescript linter and fix issues
43+
`yarn run lint` | Run linter
44+
`yarn run lint --fix` | Run linter and fix issues
4745
`yarn run start` | (alias of `yarn run start-dev`)
4846

4947
**Note**: replace `yarn` with `npm` in `package.json` if you use npm.

package.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"scripts": {
2626
"build": "yarn run clean-dist && webpack -p --config=configs/webpack/prod.js",
2727
"clean-dist": "rimraf dist/*",
28-
"lint": "tslint './src/**/*.ts*' --format stylish --project . --force",
28+
"lint": "eslint './src/**/*.{js,ts,tsx}' --quiet",
2929
"start": "yarn run start-dev",
3030
"start-dev": "webpack-dev-server --config=configs/webpack/dev.js",
3131
"start-prod": "yarn run build && node express.js",
@@ -40,22 +40,28 @@
4040
"@types/node": "^14.0.14",
4141
"@types/react": "^16.9.41",
4242
"@types/react-dom": "^16.9.8",
43+
"@typescript-eslint/eslint-plugin": "^3.6.1",
44+
"@typescript-eslint/parser": "^3.6.1",
4345
"awesome-typescript-loader": "^5.2.1",
4446
"babel-loader": "^8.1.0",
4547
"css-loader": "^3.6.0",
48+
"eslint": "^7.5.0",
49+
"eslint-config-prettier": "^6.11.0",
50+
"eslint-plugin-prettier": "^3.1.4",
51+
"eslint-plugin-react": "^7.20.3",
4652
"express": "^4.17.1",
4753
"file-loader": "^6.0.0",
4854
"html-webpack-plugin": "^4.3.0",
4955
"image-webpack-loader": "^6.0.0",
5056
"jest": "^26.1.0",
5157
"node-sass": "^4.14.1",
58+
"prettier": "^2.0.5",
5259
"react": "^16.13.1",
5360
"react-dom": "^16.13.1",
5461
"react-hot-loader": "^4.12.21",
5562
"rimraf": "^3.0.2",
5663
"sass-loader": "^9.0.1",
5764
"style-loader": "^1.2.1",
58-
"tslint": "^6.1.2",
5965
"typescript": "^3.9.6",
6066
"uglifyjs-webpack-plugin": "^2.2.0",
6167
"webpack": "^4.43.0",

src/components/App.tsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ import { hot } from "react-hot-loader";
44
const reactLogo = require("./../assets/img/react_logo.svg");
55
import "./../assets/scss/App.scss";
66

7-
class App extends React.Component<{}, undefined> {
8-
public render() {
9-
return (
10-
<div className="app">
11-
<h1>Hello World!</h1>
12-
<p>Foo to the barz</p>
13-
<img src={reactLogo.default} height="480"/>
14-
</div>
15-
);
16-
}
7+
class App extends React.Component<Record<string, unknown>, undefined> {
8+
public render() {
9+
return (
10+
<div className="app">
11+
<h1>Hello World!</h1>
12+
<p>Foo to the barz</p>
13+
<img src={reactLogo.default} height="480" />
14+
</div>
15+
);
16+
}
1717
}
1818

19-
declare let module: object;
19+
declare let module: Record<string, unknown>;
2020

2121
export default hot(module)(App);

src/index.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import * as React from "react";
2-
import {render} from "react-dom";
2+
import { render } from "react-dom";
33
import App from "./components/App";
44

55
const rootEl = document.getElementById("root");
66

7-
render(
8-
<App/>,
9-
rootEl,
10-
);
7+
render(<App />, rootEl);

0 commit comments

Comments
 (0)