@viclafouch/eslint-config-viclafouch 3.9.3-beta.3 → 4.0.0

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,13 @@ 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)
15
+ - [Add the typescript eslint config](#add-the-typescript-eslint-config)
16
16
  - [Better typing](#better-typing)
17
17
  - [Scripts](#scripts-1)
18
+ - [Better import sorting](#better-import-sorting)
18
19
  - [If you use Next.js](#if-you-use-nextjs)
19
20
  - [If you use React.js](#if-you-use-reactjs)
20
21
  - [If you want to use Prettier](#if-you-want-to-use-prettier)
@@ -32,17 +33,15 @@ These are the ESLint and Prettier settings for a Next.js project ⚡️
32
33
 
33
34
  1. If you don't already have a `package.json` file, create one with `npm init`.
34
35
 
35
- 2. Then we need to install everything needed by the config:
36
+ 2. Then we need to install the config:
36
37
 
37
38
  ```
38
- npx install-peerdeps --dev @viclafouch/eslint-config-viclafouch
39
+ npm i -D @viclafouch/eslint-config-viclafouch
39
40
  ```
40
41
 
41
- 3. You can see in your package.json there are now a big list of devDependencies.
42
+ 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
43
 
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 :
44
+ 2. Extends your config with the minimal base of @viclafouch config :
46
45
 
47
46
  ```json
48
47
  {
@@ -52,17 +51,16 @@ npx install-peerdeps --dev @viclafouch/eslint-config-viclafouch
52
51
  }
53
52
  ```
54
53
 
55
- ## If you use JavaScript
56
-
57
- You can remove these unnecessary packages (you don't need the TypeScript support)
54
+ or js version for `.eslintrc.js` file:
58
55
 
59
- ```diff
60
- {
61
- "devDependencies": {
62
- - "@typescript-eslint/eslint-plugin": "xxx",
63
- - "@typescript-eslint/parser": "xxx",
64
- - "typescript": "xxx"
65
- }
56
+ ```js
57
+ /**
58
+ * @type {import("eslint").Linter.Config}
59
+ */
60
+ module.exports = {
61
+ extends: [
62
+ "@viclafouch/eslint-config-viclafouch"
63
+ ]
66
64
  }
67
65
  ```
68
66
 
@@ -91,6 +89,8 @@ First, extend your current config file `tsconfig.json` with this following snipp
91
89
  }
92
90
  ```
93
91
 
92
+ ### Add the typescript eslint config
93
+
94
94
  Then, add the TypeScript Eslint rules to your `.eslintrc` file:
95
95
 
96
96
  ```js
@@ -107,22 +107,28 @@ Then, add the TypeScript Eslint rules to your `.eslintrc` file:
107
107
  }
108
108
  ```
109
109
 
110
- Then, you can remove these following unnecessary packages (you don't the Babel parser, we use `@typescript-eslint/parser`) instead.
110
+ or js version for `.eslintrc.js` file:
111
111
 
112
-
113
- ```diff
114
- {
115
- "devDependencies": {
116
- - "@babel/core": "xxx",
117
- - "@babel/eslint-parser": "xxx"
118
- ...
119
- }
112
+ ```js
113
+ /**
114
+ * @type {import("eslint").Linter.Config}
115
+ */
116
+ module.exports = {
117
+ extends: [
118
+ '@viclafouch/eslint-config-viclafouch',
119
+ '@viclafouch/eslint-config-viclafouch/typescript'
120
+ ],
121
+ parserOptions: {
122
+ project: true,
123
+ tsconfigRootDir: __dirname
124
+ },
125
+ root: true
120
126
  }
121
127
  ```
122
128
 
123
129
  ### Better typing
124
130
 
125
- TypeScript's built-in typings are not perfect. frichti-reset makes them better.
131
+ TypeScript's built-in typings are not perfect. viclafouch-reset makes them better.
126
132
 
127
133
  1. Create a `reset.d.ts` file in your project with these contents:
128
134
 
@@ -146,6 +152,27 @@ You can add two scripts to your package.json to lint and/or fix your code:
146
152
  }
147
153
  ```
148
154
 
155
+ ## Better import sorting
156
+
157
+ If you want to sort your imports using your alias at the same time from your `jsonfig.json` or `tsconfig.json` file.
158
+
159
+ 1. Import the `sortImports` function from the config in your `.eslintrc.js` file:
160
+
161
+ ```js
162
+ const {
163
+ sortImports
164
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
165
+ } = require('@viclafouch/eslint-config-viclafouch/rules/sort-imports')
166
+ ```
167
+
168
+ 2. Include the function in your `overrides` array like this:
169
+
170
+ ```js
171
+ {
172
+ overrides: [sortImports(__dirname)]
173
+ }
174
+ ```
175
+
149
176
  ## If you use Next.js
150
177
 
151
178
  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 +182,7 @@ You can also add additional rules for Next.js. It includes the following configu
155
182
  extends: [
156
183
  '@viclafouch/eslint-config-viclafouch',
157
184
  '@viclafouch/eslint-config-viclafouch/next'
158
- ],
185
+ ]
159
186
  }
160
187
  ```
161
188
 
@@ -169,7 +196,7 @@ You can also add additional rules for only React.js ecosystem (without Next.js).
169
196
  '@viclafouch/eslint-config-viclafouch',
170
197
  '@viclafouch/eslint-config-viclafouch/react',
171
198
  '@viclafouch/eslint-config-viclafouch/hooks'
172
- ],
199
+ ]
173
200
  }
174
201
  ```
175
202
 
@@ -196,7 +223,7 @@ Once you have done. You probably want your editor to lint and fix for you.
196
223
  1. Install the [ESLint package](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
197
224
  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
225
 
199
- ```js
226
+ ```json
200
227
  {
201
228
  "editor.codeActionsOnSave": {
202
229
  "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.3",
3
+ "version": "4.0.0",
4
4
  "description": "ESLint and Prettier Config from Victor de la Fouchardiere",
5
5
  "main": "index.js",
6
6
  "keywords": [
@@ -31,12 +31,12 @@
31
31
  "dependencies": {
32
32
  "@total-typescript/ts-reset": "^0.4.2",
33
33
  "get-tsconfig": "^4.6.2",
34
- "@babel/core": "^7.22.5",
35
- "@babel/eslint-parser": "^7.22.5",
36
- "@next/eslint-plugin-next": "^13.4.7",
34
+ "@babel/core": "^7.22.6",
35
+ "@babel/eslint-parser": "^7.22.6",
36
+ "@next/eslint-plugin-next": "^13.4.8",
37
37
  "@rushstack/eslint-patch": "^1.3.2",
38
- "@typescript-eslint/eslint-plugin": "^5.60.1",
39
- "@typescript-eslint/parser": "^5.60.1",
38
+ "@typescript-eslint/eslint-plugin": "^5.61.0",
39
+ "@typescript-eslint/parser": "^5.61.0",
40
40
  "babel-loader": "^9.1.2",
41
41
  "eslint": "^8.44.0",
42
42
  "eslint-config-prettier": "^8.8.0",
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: [