Skip to content

Commit c174c2b

Browse files
committed
chore: Add ESLint, Prettier and EditorConfig
1 parent 8466bfc commit c174c2b

File tree

10 files changed

+1340
-228
lines changed

10 files changed

+1340
-228
lines changed

.babelrc

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
{
77
"root": ["./src"],
88
"alias": {
9-
"@components": "./src/components"
10-
}
9+
"@": "./src"
10+
},
11+
"extensions": [".js", ".ts", ".jsx", ".tsx"]
1112
}
1213
]
1314
]

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
charset = utf-8
7+
end_of_line = lf
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.eslintrc

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es6": true
5+
},
6+
"parserOptions": {
7+
"ecmaFeatures": {
8+
"jsx": true
9+
},
10+
"ecmaVersion": 2019,
11+
"sourceType": "module"
12+
},
13+
"globals": {
14+
"Atomics": "readonly",
15+
"SharedArrayBuffer": "readonly"
16+
},
17+
"extends": ["plugin:react/recommended", "airbnb", "prettier/react"],
18+
"plugins": ["react", "react-hooks", "jsx-a11y", "prettier"],
19+
"rules": {
20+
"prettier/prettier": "error",
21+
"import/prefer-default-export": "off",
22+
"react/prop-types": "off",
23+
"react/jsx-filename-extension": "off",
24+
"react/jsx-props-no-spreading": "off",
25+
"import/extensions": [
26+
"error",
27+
"ignorePackages",
28+
{
29+
"ts": "never",
30+
"tsx": "never",
31+
"js": "never",
32+
"jsx": "never"
33+
}
34+
]
35+
},
36+
"overrides": [
37+
{
38+
"files": "**/*.+(ts|tsx)",
39+
"parser": "@typescript-eslint/parser",
40+
"parserOptions": {
41+
"project": "./tsconfig.json"
42+
},
43+
"plugins": ["@typescript-eslint/eslint-plugin"],
44+
"extends": [
45+
"plugin:@typescript-eslint/eslint-recommended",
46+
"plugin:@typescript-eslint/recommended",
47+
"eslint-config-prettier/@typescript-eslint"
48+
],
49+
"rules": {
50+
"@typescript-eslint/explicit-function-return-type": [
51+
"warn",
52+
{
53+
"allowExpressions": true
54+
}
55+
],
56+
"@typescript-eslint/no-explicit-any": "off",
57+
"@typescript-eslint/no-var-requires": "off",
58+
"@typescript-eslint/quotes": [
59+
2,
60+
"backtick",
61+
{
62+
"avoidEscape": true
63+
}
64+
]
65+
}
66+
}
67+
],
68+
"settings": {
69+
"import/resolver": {
70+
"node": {
71+
"paths": ["./src"]
72+
},
73+
"babel-module": {}
74+
}
75+
}
76+
}

.prettierrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"trailingComma": "all",
3+
"singleQuote": true,
4+
"printWidth": 80,
5+
"tabWidth": 2
6+
}

package.json

+16-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
"dev": "next",
77
"build": "next build",
88
"start": "next start",
9-
"type-check": "tsc"
9+
"type-check": "tsc",
10+
"lint": "eslint --ignore-path .gitignore \"src/**/*.+(ts|js|tsx)\"",
11+
"lint:fix": "yarn lint --fix",
12+
"format": "prettier --ignore-path .gitignore \"src/**/*.+(ts|js|tsx)\" --write"
1013
},
1114
"dependencies": {
1215
"next": "9.3.1",
@@ -17,7 +20,19 @@
1720
"@types/node": "^13.9.2",
1821
"@types/react": "^16.9.23",
1922
"@types/react-dom": "^16.9.5",
23+
"@typescript-eslint/eslint-plugin": "^2.24.0",
24+
"@typescript-eslint/parser": "^2.24.0",
2025
"babel-plugin-module-resolver": "^4.0.0",
26+
"eslint": "^6.8.0",
27+
"eslint-config-airbnb": "^18.1.0",
28+
"eslint-config-prettier": "^6.10.0",
29+
"eslint-import-resolver-babel-module": "^5.1.2",
30+
"eslint-plugin-import": "^2.20.1",
31+
"eslint-plugin-jsx-a11y": "^6.2.3",
32+
"eslint-plugin-prettier": "^3.1.2",
33+
"eslint-plugin-react": "^7.19.0",
34+
"eslint-plugin-react-hooks": "^2.5.0",
35+
"prettier": "^1.19.1",
2136
"typescript": "^3.8.3"
2237
}
2338
}

src/components/Title.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React from 'react';
22

33
const Title: React.FC<{}> = () => (
44
<h1 className="title">

src/pages/index.js

-203
This file was deleted.

0 commit comments

Comments
 (0)