@viclafouch/eslint-config-viclafouch 3.9.3-beta.2 → 3.9.3-beta.4

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/README.md CHANGED
@@ -9,12 +9,12 @@ These are the ESLint and Prettier settings for a Next.js project ⚡️
9
9
  - [Table of Contents](#table-of-contents)
10
10
  - [What it does](#what-it-does)
11
11
  - [Local / Per Project Install](#local--per-project-install)
12
- - [If you use JavaScript](#if-you-use-javascript)
13
12
  - [Scripts](#scripts)
14
13
  - [If you use TypeScript](#if-you-use-typescript)
15
14
  - [Extend your tsconfig](#extend-your-tsconfig)
16
15
  - [Better typing](#better-typing)
17
16
  - [Scripts](#scripts-1)
17
+ - [Better import sorting](#better-import-sorting)
18
18
  - [If you use Next.js](#if-you-use-nextjs)
19
19
  - [If you use React.js](#if-you-use-reactjs)
20
20
  - [If you want to use Prettier](#if-you-want-to-use-prettier)
@@ -32,17 +32,15 @@ These are the ESLint and Prettier settings for a Next.js project ⚡️
32
32
 
33
33
  1. If you don't already have a `package.json` file, create one with `npm init`.
34
34
 
35
- 2. Then we need to install everything needed by the config:
35
+ 2. Then we need to install the config:
36
36
 
37
37
  ```
38
- npx install-peerdeps --dev @viclafouch/eslint-config-viclafouch
38
+ npm i -D @viclafouch/eslint-config-viclafouch
39
39
  ```
40
40
 
41
- 3. You can see in your package.json there are now a big list of devDependencies.
41
+ 1. 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:
42
42
 
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:
44
-
45
- 5. Extends your config with the minimal base of Frichti config :
43
+ 2. Extends your config with the minimal base of @viclafouch config :
46
44
 
47
45
  ```json
48
46
  {
@@ -52,17 +50,16 @@ npx install-peerdeps --dev @viclafouch/eslint-config-viclafouch
52
50
  }
53
51
  ```
54
52
 
55
- ## If you use JavaScript
56
-
57
- You can remove these unnecessary packages (you don't need the TypeScript support)
53
+ or js version for `.eslintrc.js` file:
58
54
 
59
- ```diff
60
- {
61
- "devDependencies": {
62
- - "@typescript-eslint/eslint-plugin": "xxx",
63
- - "@typescript-eslint/parser": "xxx",
64
- - "typescript": "xxx"
65
- }
55
+ ```js
56
+ /**
57
+ * @type {import("eslint").Linter.Config}
58
+ */
59
+ module.exports = {
60
+ extends: [
61
+ "@viclafouch/eslint-config-viclafouch"
62
+ ]
66
63
  }
67
64
  ```
68
65
 
@@ -107,22 +104,28 @@ Then, add the TypeScript Eslint rules to your `.eslintrc` file:
107
104
  }
108
105
  ```
109
106
 
110
- Then, you can remove these following unnecessary packages (you don't the Babel parser, we use `@typescript-eslint/parser`) instead.
107
+ or js version for `.eslintrc.js` file:
111
108
 
112
-
113
- ```diff
114
- {
115
- "devDependencies": {
116
- - "@babel/core": "xxx",
117
- - "@babel/eslint-parser": "xxx"
118
- ...
119
- }
109
+ ```js
110
+ /**
111
+ * @type {import("eslint").Linter.Config}
112
+ */
113
+ module.exports = {
114
+ extends: [
115
+ '@viclafouch/eslint-config-viclafouch',
116
+ '@viclafouch/eslint-config-viclafouch/typescript'
117
+ ],
118
+ parserOptions: {
119
+ project: true,
120
+ tsconfigRootDir: __dirname
121
+ },
122
+ root: true
120
123
  }
121
124
  ```
122
125
 
123
126
  ### Better typing
124
127
 
125
- TypeScript's built-in typings are not perfect. frichti-reset makes them better.
128
+ TypeScript's built-in typings are not perfect. viclafouch-reset makes them better.
126
129
 
127
130
  1. Create a `reset.d.ts` file in your project with these contents:
128
131
 
@@ -146,6 +149,24 @@ You can add two scripts to your package.json to lint and/or fix your code:
146
149
  }
147
150
  ```
148
151
 
152
+ ### Better import sorting
153
+
154
+ If you want to sort your imports using your alias at the same time from your `jsonfig.json` or `tsconfig.json` file.
155
+
156
+ 1. Import the `sortImports` function from the config in your `.eslintrc.js` file:
157
+
158
+ ```js
159
+ const { sortImports } = require('@viclafouch/eslint-config-viclafouch/rules/sort-imports')
160
+ ```
161
+
162
+ 2. Include the function in your `overrides` array like this:
163
+
164
+ ```js
165
+ {
166
+ overrides: [sortImports(__dirname)]
167
+ }
168
+ ```
169
+
149
170
  ## If you use Next.js
150
171
 
151
172
  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.
@@ -155,7 +176,7 @@ You can also add additional rules for Next.js. It includes the following configu
155
176
  extends: [
156
177
  '@viclafouch/eslint-config-viclafouch',
157
178
  '@viclafouch/eslint-config-viclafouch/next'
158
- ],
179
+ ]
159
180
  }
160
181
  ```
161
182
 
@@ -169,7 +190,7 @@ You can also add additional rules for only React.js ecosystem (without Next.js).
169
190
  '@viclafouch/eslint-config-viclafouch',
170
191
  '@viclafouch/eslint-config-viclafouch/react',
171
192
  '@viclafouch/eslint-config-viclafouch/hooks'
172
- ],
193
+ ]
173
194
  }
174
195
  ```
175
196
 
@@ -196,7 +217,7 @@ Once you have done. You probably want your editor to lint and fix for you.
196
217
  1. Install the [ESLint package](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
197
218
  2. Now we need to setup some VS Code settings. Create a `.vscode` folder at your root project, and create a `settings.json` file in this folder. Then, add this little config:
198
219
 
199
- ```js
220
+ ```json
200
221
  {
201
222
  "editor.codeActionsOnSave": {
202
223
  "source.fixAll.eslint": true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viclafouch/eslint-config-viclafouch",
3
- "version": "3.9.3-beta.2",
3
+ "version": "3.9.3-beta.4",
4
4
  "description": "ESLint and Prettier Config from Victor de la Fouchardiere",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -28,13 +28,15 @@
28
28
  "prettier": "^2.8.8",
29
29
  "typescript": "^5.1.6"
30
30
  },
31
- "devDependencies": {
32
- "@babel/core": "^7.22.5",
33
- "@babel/eslint-parser": "^7.22.5",
34
- "@next/eslint-plugin-next": "^13.4.7",
31
+ "dependencies": {
32
+ "@total-typescript/ts-reset": "^0.4.2",
33
+ "get-tsconfig": "^4.6.2",
34
+ "@babel/core": "^7.22.6",
35
+ "@babel/eslint-parser": "^7.22.6",
36
+ "@next/eslint-plugin-next": "^13.4.8",
35
37
  "@rushstack/eslint-patch": "^1.3.2",
36
- "@typescript-eslint/eslint-plugin": "^5.60.1",
37
- "@typescript-eslint/parser": "^5.60.1",
38
+ "@typescript-eslint/eslint-plugin": "^5.61.0",
39
+ "@typescript-eslint/parser": "^5.61.0",
38
40
  "babel-loader": "^9.1.2",
39
41
  "eslint": "^8.44.0",
40
42
  "eslint-config-prettier": "^8.8.0",
@@ -47,11 +49,7 @@
47
49
  "eslint-plugin-simple-import-sort": "^10.0.0",
48
50
  "eslint-plugin-testing-library": "^5.11.0",
49
51
  "prettier": "^2.8.8",
50
- "typescript": "^5.1.6"
51
- },
52
- "dependencies": {
53
- "@total-typescript/ts-reset": "^0.4.2",
54
- "get-tsconfig": "^4.6.2"
52
+ "typescript": "^5.x.x"
55
53
  },
56
54
  "scripts": {
57
55
  "lint": "eslint .",
package/reset.d.ts CHANGED
@@ -1 +1,7 @@
1
1
  export * from '@total-typescript/ts-reset'
2
+
3
+ declare global {
4
+ // https://twitter.com/erikras/status/1673694889974833152
5
+ // eslint-disable-next-line @typescript-eslint/ban-types
6
+ type StrictOmit<T, K extends keyof T> = Omit<T, K>
7
+ }
@@ -112,6 +112,21 @@ module.exports = {
112
112
  selector: 'typeLike',
113
113
  format: ['PascalCase']
114
114
  }
115
+ ],
116
+
117
+ '@typescript-eslint/ban-types': [
118
+ 'error',
119
+ {
120
+ types: {
121
+ // Omit is not strict enought
122
+ Omit: {
123
+ // https://twitter.com/erikras/status/1673694889974833152
124
+ message:
125
+ 'Use StrictOmit instead by using reset.d.ts from @viclafouch/eslint-config-viclafouch/reset.d. See https://github.com/viclafouch/eslint-config-viclafouch#better-typing',
126
+ fixWith: 'StrictOmit'
127
+ }
128
+ }
129
+ }
115
130
  ]
116
131
  },
117
132
  overrides: [