@whoj/eslint-config 1.4.2 → 2.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Jonson
3
+ Copyright (c) 2019-PRESENT Anthony Fu<https://github.com/antfu>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md ADDED
@@ -0,0 +1,210 @@
1
+ # @whoj/eslint-config
2
+
3
+ [![npm](https://img.shields.io/npm/v/@whoj/eslint-config?color=444&label=)](https://npmjs.com/package/@whoj/eslint-config)
4
+
5
+ ## Usage
6
+
7
+ ### Starter Wizard
8
+
9
+ We provided a CLI tool to help you set up your project, or migrate from the legacy config to the new flat config with one command.
10
+
11
+ ```bash
12
+ pnpm dlx @whoj/eslint-config@latest
13
+ ```
14
+
15
+ ### Manual Install
16
+
17
+ If you prefer to set up manually:
18
+
19
+ ```bash
20
+ pnpm i -D eslint @whoj/eslint-config
21
+ ```
22
+
23
+ And create `eslint.config.mjs` in your project root:
24
+
25
+ ```js
26
+ // eslint.config.mjs
27
+ import whoj from '@whoj/eslint-config'
28
+
29
+ export default whoj()
30
+ ```
31
+
32
+ <details>
33
+ <summary>
34
+ Combined with legacy config:
35
+ </summary>
36
+
37
+ If you still use some configs from the legacy eslintrc format, you can use the [`@eslint/eslintrc`](https://www.npmjs.com/package/@eslint/eslintrc) package to convert them to the flat config.
38
+
39
+ ```js
40
+ import { FlatCompat } from '@eslint/eslintrc'
41
+ // eslint.config.mjs
42
+ import whoj from '@whoj/eslint-config'
43
+
44
+ const compat = new FlatCompat()
45
+
46
+ export default whoj(
47
+ {
48
+ ignores: [],
49
+ },
50
+
51
+ // Legacy config
52
+ ...compat.config({
53
+ extends: [
54
+ 'eslint:recommended',
55
+ // Other extends...
56
+ ],
57
+ })
58
+
59
+ // Other flat configs...
60
+ )
61
+ ```
62
+
63
+ > Note that `.eslintignore` no longer works in Flat config, see [customization](#customization) for more details.
64
+
65
+ </details>
66
+
67
+ ### Add script for package.json
68
+
69
+ For example:
70
+
71
+ ```json
72
+ {
73
+ "scripts": {
74
+ "lint": "eslint .",
75
+ "lint:fix": "eslint . --fix"
76
+ }
77
+ }
78
+ ```
79
+
80
+ ## IDE Support (auto fix on save)
81
+
82
+ <details>
83
+ <summary>🟦 VS Code support</summary>
84
+
85
+ <br>
86
+
87
+ Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
88
+
89
+ Add the following settings to your `.vscode/settings.json`:
90
+
91
+ ```jsonc
92
+ {
93
+ // Disable the default formatter, use eslint instead
94
+ "prettier.enable": false,
95
+ "editor.formatOnSave": false,
96
+
97
+ // Auto fix
98
+ "editor.codeActionsOnSave": {
99
+ "source.fixAll.eslint": "explicit",
100
+ "source.organizeImports": "never"
101
+ },
102
+
103
+ // Silent the stylistic rules in you IDE, but still auto fix them
104
+ "eslint.rules.customizations": [
105
+ { "rule": "style/*", "severity": "off", "fixable": true },
106
+ { "rule": "format/*", "severity": "off", "fixable": true },
107
+ { "rule": "*-indent", "severity": "off", "fixable": true },
108
+ { "rule": "*-spacing", "severity": "off", "fixable": true },
109
+ { "rule": "*-spaces", "severity": "off", "fixable": true },
110
+ { "rule": "*-order", "severity": "off", "fixable": true },
111
+ { "rule": "*-dangle", "severity": "off", "fixable": true },
112
+ { "rule": "*-newline", "severity": "off", "fixable": true },
113
+ { "rule": "*quotes", "severity": "off", "fixable": true },
114
+ { "rule": "*semi", "severity": "off", "fixable": true }
115
+ ],
116
+
117
+ // Enable eslint for all supported languages
118
+ "eslint.validate": [
119
+ "javascript",
120
+ "javascriptreact",
121
+ "typescript",
122
+ "typescriptreact",
123
+ "vue",
124
+ "html",
125
+ "markdown",
126
+ "json",
127
+ "jsonc",
128
+ "yaml",
129
+ "toml",
130
+ "xml",
131
+ "gql",
132
+ "graphql",
133
+ "astro",
134
+ "svelte",
135
+ "css",
136
+ "less",
137
+ "scss",
138
+ "pcss",
139
+ "postcss"
140
+ ]
141
+ }
142
+ ```
143
+
144
+ </details>
145
+
146
+ ## Customization
147
+
148
+ You can configure each integration individually, for example:
149
+
150
+ ```js
151
+ // eslint.config.js
152
+ import whoj from '@whoj/eslint-config'
153
+
154
+ export default whoj({
155
+ // Type of the project. 'lib' for libraries, the default is 'app'
156
+ type: 'lib',
157
+
158
+ // Enable stylistic formatting rules
159
+ // stylistic: true,
160
+
161
+ // Or customize the stylistic rules
162
+ stylistic: {
163
+ indent: 2, // 4, or 'tab'
164
+ quotes: 'single', // or 'double'
165
+ },
166
+
167
+ // TypeScript and Vue are autodetected, you can also explicitly enable them:
168
+ typescript: true,
169
+ vue: true,
170
+
171
+ // Disable jsonc and yaml support
172
+ jsonc: false,
173
+ yaml: false,
174
+
175
+ // `.eslintignore` is no longer supported in Flat config, use `ignores` instead
176
+ ignores: [
177
+ '**/fixtures',
178
+ // ...globs
179
+ ]
180
+ })
181
+ ```
182
+
183
+ The `whoj` factory function also accepts any number of arbitrary custom config overrides:
184
+
185
+ ```js
186
+ // eslint.config.js
187
+ import whoj from '@whoj/eslint-config'
188
+
189
+ export default whoj(
190
+ {
191
+ // Configures for whoj's config
192
+ },
193
+
194
+ // From the second arguments they are ESLint Flat Configs
195
+ // you can have multiple configs
196
+ {
197
+ files: ['**/*.ts'],
198
+ rules: {},
199
+ },
200
+ {
201
+ rules: {},
202
+ },
203
+ )
204
+ ```
205
+
206
+ Going more advanced, Check out [configs](https://github.com/antfu/eslint-config)
207
+
208
+ ## License
209
+
210
+ [MIT](./LICENSE) License &copy; 2025-PRESENT [B. Jonson](https://github.com/who-jonson)
package/bin/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/cli.js'