@viclafouch/eslint-config-viclafouch 3.9.2 → 3.9.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": ["./index.js", "./prettier"],
3
+ "root": true,
4
+ "rules": {
5
+ // disable requiring trailing commas because it might be nice to revert to
6
+ // being JSON at some point, and I don't want to make big changes now.
7
+ "comma-dangle": 0,
8
+ "max-len": 0
9
+ }
10
+ }
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
- [![npm version](https://badge.fury.io/js/%40viclafouch%2Feslint-config-viclafouch.svg)](https://badge.fury.io/js/%40viclafouch%2Feslint-config-viclafouch)
2
-
3
1
  # Eslint / Prettier Setup of @viclafouch 📦
4
2
 
5
- These are my ESLint and Prettier settings for a React.js project ⚡️
3
+ These are the ESLint and Prettier settings for a Next.js project ⚡️
6
4
 
7
5
 
8
6
  # Table of Contents
@@ -14,13 +12,19 @@ These are my ESLint and Prettier settings for a React.js project ⚡️
14
12
  - [If you use JavaScript](#if-you-use-javascript)
15
13
  - [Scripts](#scripts)
16
14
  - [If you use TypeScript](#if-you-use-typescript)
15
+ - [Extend your tsconfig](#extend-your-tsconfig)
16
+ - [Better typing](#better-typing)
17
17
  - [Scripts](#scripts-1)
18
- - [With VS Code](#with-vs-code)
19
- - [With Create React App](#with-create-react-app)
18
+ - [If you use Next.js](#if-you-use-nextjs)
19
+ - [If you use React.js](#if-you-use-reactjs)
20
+ - [If you want to use Prettier](#if-you-want-to-use-prettier)
21
+ - [If you use VS Code](#if-you-use-vs-code)
20
22
 
21
23
  ## What it does
22
24
 
23
- * Lints JavaScript based on the latest standards
25
+ * Lints JavaScript / TypeScript based on the latest standards
26
+ * Multiple configs `react` `hooks` `next`..
27
+ * Shared `tsconfig.json`
24
28
  * Fixes issues and formatting errors with Prettier
25
29
  * Check for accessibility rules on JSX elements.
26
30
 
@@ -38,7 +42,7 @@ npx install-peerdeps --dev @viclafouch/eslint-config-viclafouch
38
42
 
39
43
  4. Create a `.eslintrc` file in the root of your project's directory (it should live where package.json does). Your `.eslintrc` file should look like this:
40
44
 
41
- ## If you use JavaScript
45
+ 5. Extends your config with the minimal base of Frichti config :
42
46
 
43
47
  ```json
44
48
  {
@@ -48,14 +52,18 @@ npx install-peerdeps --dev @viclafouch/eslint-config-viclafouch
48
52
  }
49
53
  ```
50
54
 
51
- Then, you can remove these unnecessary packages (you don't need the TypeScript support)
55
+ ## If you use JavaScript
56
+
57
+ You can remove these unnecessary packages (you don't need the TypeScript support)
52
58
 
53
59
  ```diff
54
- "devDependencies": {
55
- - "@typescript-eslint/eslint-plugin": "5.4.0",
56
- - "@typescript-eslint/parser": "5.4.0",
57
- - "typescript": "4.5.2"
58
- },
60
+ {
61
+ "devDependencies": {
62
+ - "@typescript-eslint/eslint-plugin": "xxx",
63
+ - "@typescript-eslint/parser": "xxx",
64
+ - "typescript": "xxx"
65
+ }
66
+ }
59
67
  ```
60
68
 
61
69
  ### Scripts
@@ -63,47 +71,125 @@ Then, you can remove these unnecessary packages (you don't need the TypeScript s
63
71
  You can add two scripts to your package.json to lint and/or fix your code:
64
72
 
65
73
  ```json
66
- "scripts": {
67
- "lint": "eslint .",
68
- "lint:fix": "npm run lint -- --fix",
69
- },
74
+ {
75
+ "scripts": {
76
+ "lint": "eslint .",
77
+ "lint:fix": "npm run lint -- --fix",
78
+ }
79
+ }
70
80
  ```
71
81
  ## If you use TypeScript
72
82
 
83
+ ### Extend your tsconfig
84
+
85
+ First, extend your current config file `tsconfig.json` with this following snippet:
86
+
73
87
  ```json
74
88
  {
75
- "extends": [
76
- "@viclafouch/eslint-config-viclafouch/typescript"
89
+ "extends": "@viclafouch/eslint-config-viclafouch/tsconfig.json",
90
+ ...
91
+ }
92
+ ```
93
+
94
+ Then, add the TypeScript Eslint rules to your `.eslintrc` file:
95
+
96
+ ```js
97
+ {
98
+ extends: [
99
+ '@viclafouch/eslint-config-viclafouch',
100
+ '@viclafouch/eslint-config-viclafouch/typescript'
77
101
  ],
78
- "parserOptions": {
79
- "project": ["./tsconfig.json"]
80
- }
102
+ parserOptions: {
103
+ project: true,
104
+ tsconfigRootDir: __dirname
105
+ },
106
+ root: true
81
107
  }
82
108
  ```
83
109
 
84
- Then, you can remove these unnecessary packages (you don't the Babel parser, we use `@typescript-eslint/parser`).
110
+ Then, you can remove these following unnecessary packages (you don't the Babel parser, we use `@typescript-eslint/parser`) instead.
85
111
 
86
112
 
87
113
  ```diff
88
- "devDependencies": {
89
- - "@babel/core": "7.16.0",
90
- - "@babel/eslint-parser": "7.16.3"
91
- ...
92
- },
114
+ {
115
+ "devDependencies": {
116
+ - "@babel/core": "xxx",
117
+ - "@babel/eslint-parser": "xxx"
118
+ ...
119
+ }
120
+ }
93
121
  ```
94
122
 
123
+ ### Better typing
124
+
125
+ TypeScript's built-in typings are not perfect. frichti-reset makes them better.
126
+
127
+ 1. Create a `reset.d.ts` file in your project with these contents:
128
+
129
+ ```ts
130
+ // Do not add any other lines of code to this file!
131
+ import '@viclafouch/eslint-config-viclafouch/reset.d'
132
+ ```
133
+
134
+ 2. Enjoy improved typings across your entire project.
135
+
95
136
  ### Scripts
96
137
 
97
138
  You can add two scripts to your package.json to lint and/or fix your code:
98
139
 
99
140
  ```json
100
- "scripts": {
101
- "lint": "tsc --noEmit && eslint . --ext .js,.jsx,.ts,.tsx",
102
- "lint:fix": "npm run lint -- --fix",
103
- },
141
+ {
142
+ "scripts": {
143
+ "lint": "tsc --noEmit && eslint . --ext .js,.jsx,.ts,.tsx",
144
+ "lint:fix": "npm run lint -- --fix",
145
+ },
146
+ }
104
147
  ```
105
148
 
106
- ## With VS Code
149
+ ## If you use Next.js
150
+
151
+ You can also add additional rules for Next.js. It includes the following configurations : `@viclafouch/eslint-config-viclafouch/react`, `@viclafouch/eslint-config-viclafouch/hooks` and Next.js specific rules.
152
+
153
+ ```js
154
+ {
155
+ extends: [
156
+ '@viclafouch/eslint-config-viclafouch',
157
+ '@viclafouch/eslint-config-viclafouch/next'
158
+ ],
159
+ }
160
+ ```
161
+
162
+ ## If you use React.js
163
+
164
+ You can also add additional rules for only React.js ecosystem (without Next.js).
165
+
166
+ ```js
167
+ {
168
+ extends: [
169
+ '@viclafouch/eslint-config-viclafouch',
170
+ '@viclafouch/eslint-config-viclafouch/react',
171
+ '@viclafouch/eslint-config-viclafouch/hooks'
172
+ ],
173
+ }
174
+ ```
175
+
176
+
177
+ ## If you want to use Prettier
178
+
179
+ Be sure to add the prettier config at the end of your `extends` array.
180
+
181
+ ```js
182
+ {
183
+ extends: [
184
+ '@viclafouch/eslint-config-viclafouch',
185
+ '@viclafouch/eslint-config-viclafouch/react',
186
+ '@viclafouch/eslint-config-viclafouch/hooks',
187
+ '@viclafouch/eslint-config-viclafouch/prettier' // be sure to be the last
188
+ ],
189
+ }
190
+ ```
191
+
192
+ ## If you use VS Code
107
193
 
108
194
  Once you have done. You probably want your editor to lint and fix for you.
109
195
 
@@ -116,10 +202,4 @@ Once you have done. You probably want your editor to lint and fix for you.
116
202
  "source.fixAll.eslint": true
117
203
  }
118
204
  }
119
- ```
120
-
121
- ## With Create React App
122
-
123
- 1. You gotta eject first `npm run eject` or `yarn eject`
124
- 1. Run `npx install-peerdeps --dev @viclafouch/eslint-config-viclafouch`
125
- 1. Crack open your `package.json` and replace `"extends": "react-app"` with `"extends": ["@viclafouch/eslint-config-viclafouch"]`
205
+ ```
package/hooks.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @type {import("eslint").Linter.Config}
3
+ */
4
+ module.exports = {
5
+ extends: ['./rules/react-hooks.js'].map(require.resolve),
6
+ rules: {}
7
+ }
package/index.js CHANGED
@@ -1,3 +1,19 @@
1
- const eslintrc = require('./.eslintrc')
2
-
3
- module.exports = eslintrc
1
+ /**
2
+ * @type {import("eslint").Linter.Config}
3
+ */
4
+ module.exports = {
5
+ extends: [
6
+ './rules/best-practices',
7
+ './rules/node',
8
+ './rules/errors',
9
+ './rules/imports',
10
+ './rules/style',
11
+ './rules/variables',
12
+ './rules/es6'
13
+ ].map(require.resolve),
14
+ parserOptions: {
15
+ ecmaVersion: 2022,
16
+ sourceType: 'module'
17
+ },
18
+ rules: {}
19
+ }
package/next.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @type {import("eslint").Linter.Config}
3
+ */
4
+ module.exports = {
5
+ extends: ['./react.js', './hooks.js']
6
+ .map(require.resolve)
7
+ .concat(['plugin:@next/next/recommended']),
8
+ rules: {
9
+ // No error for anchor inside a Next Link
10
+ 'jsx-a11y/anchor-is-valid': [
11
+ 'error',
12
+ {
13
+ components: ['Link'],
14
+ specialLink: ['hrefLeft', 'hrefRight'],
15
+ aspects: ['invalidHref', 'preferButton']
16
+ }
17
+ ]
18
+ }
19
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viclafouch/eslint-config-viclafouch",
3
- "version": "3.9.2",
3
+ "version": "3.9.3-beta.1",
4
4
  "description": "ESLint and Prettier Config from Victor de la Fouchardiere",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -24,33 +24,18 @@
24
24
  "license": "MIT",
25
25
  "homepage": "https://github.com/viclafouch/eslint-config-viclafouch#readme",
26
26
  "peerDependencies": {
27
- "@babel/core": "^7.21.5",
28
- "@babel/eslint-parser": "^7.21.3",
29
- "@typescript-eslint/eslint-plugin": "^5.59.1",
30
- "@typescript-eslint/parser": "^5.59.1",
31
27
  "eslint": "^8.39.0",
32
- "eslint-config-airbnb": "^19.0.4",
33
- "eslint-config-airbnb-typescript": "^17.0.0",
34
- "eslint-config-prettier": "^8.8.0",
35
- "eslint-plugin-import": "^2.27.5",
36
- "eslint-plugin-jsx-a11y": "^6.7.1",
37
- "eslint-plugin-prettier": "^4.2.1",
38
- "eslint-plugin-promise": "^6.1.1",
39
- "eslint-plugin-react": "^7.32.2",
40
- "eslint-plugin-react-hooks": "^4.6.0",
41
- "eslint-plugin-simple-import-sort": "^10.0.0",
42
28
  "prettier": "^2.8.8",
43
- "standard-version": "9.5.0",
44
- "typescript": "^5.0.4"
29
+ "typescript": "^5.1.6"
45
30
  },
46
31
  "devDependencies": {
47
- "@babel/core": "^7.21.5",
48
- "@babel/eslint-parser": "^7.21.3",
49
- "@typescript-eslint/eslint-plugin": "^5.59.1",
50
- "@typescript-eslint/parser": "^5.59.1",
51
- "eslint": "^8.39.0",
52
- "eslint-config-airbnb": "^19.0.4",
53
- "eslint-config-airbnb-typescript": "^17.0.0",
32
+ "@babel/core": "^7.22.5",
33
+ "@babel/eslint-parser": "^7.22.5",
34
+ "@next/eslint-plugin-next": "^13.4.7",
35
+ "@typescript-eslint/eslint-plugin": "^5.60.1",
36
+ "@typescript-eslint/parser": "^5.60.1",
37
+ "babel-loader": "^9.1.2",
38
+ "eslint": "^8.44.0",
54
39
  "eslint-config-prettier": "^8.8.0",
55
40
  "eslint-plugin-import": "^2.27.5",
56
41
  "eslint-plugin-jsx-a11y": "^6.7.1",
@@ -59,13 +44,18 @@
59
44
  "eslint-plugin-react": "^7.32.2",
60
45
  "eslint-plugin-react-hooks": "^4.6.0",
61
46
  "eslint-plugin-simple-import-sort": "^10.0.0",
47
+ "eslint-plugin-testing-library": "^5.11.0",
62
48
  "prettier": "^2.8.8",
63
- "standard-version": "9.5.0",
64
- "typescript": "^5.0.4"
49
+ "typescript": "^5.1.6"
50
+ },
51
+ "dependencies": {
52
+ "@total-typescript/ts-reset": "^0.4.2",
53
+ "get-tsconfig": "^4.6.2"
65
54
  },
66
55
  "scripts": {
67
56
  "lint": "eslint .",
68
57
  "lint:fix": "eslint --fix",
69
- "release": "standard-version"
58
+ "bump:beta": "npm version prerelease --preid beta",
59
+ "publish:beta": "npm publish --tag beta"
70
60
  }
71
61
  }
package/prettier.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @type {import("eslint").Linter.Config}
3
+ */
4
+ module.exports = {
5
+ extends: ['prettier'],
6
+ plugins: ['prettier'],
7
+ rules: {
8
+ 'prettier/prettier': [
9
+ 'error',
10
+ {
11
+ semi: false,
12
+ singleQuote: true,
13
+ printWidth: 80,
14
+ tabWidth: 2,
15
+ jsxSingleQuote: false,
16
+ trailingComma: 'none',
17
+ endOfLine: 'auto',
18
+ bracketSameLine: false,
19
+ arrowParens: 'always'
20
+ }
21
+ ]
22
+ }
23
+ }
package/react.js ADDED
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @type {import("eslint").Linter.Config}
3
+ */
4
+ module.exports = {
5
+ extends: ['./rules/react.js'].map(require.resolve),
6
+ rules: {}
7
+ }
package/reset.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@total-typescript/ts-reset'