@jiakun-zhao/eslint-config 4.0.1 → 4.0.3
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 +21 -0
- package/README.md +44 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +20 -16
- package/package.json +4 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright © 2025 Jiakun Zhao
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
1
1
|
## @jiakun-zhao/eslint-config
|
|
2
|
-
|
|
3
|
-

|
|
4
|
+

|
|
5
|
+
|
|
6
|
+
Personal style eslint configuration.
|
|
7
|
+
|
|
8
|
+
<details>
|
|
9
|
+
|
|
10
|
+
<summary>Usage</summary>
|
|
11
|
+
|
|
12
|
+
#### Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm i -D @jiakun-zhao/eslint-config
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
#### Config
|
|
19
|
+
|
|
20
|
+
Create `eslint.config.mjs` file in your project root directory, and add the following content:
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import defineConfig from '@jiakun-zhao/eslint-config'
|
|
24
|
+
|
|
25
|
+
export default defineConfig()
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### VS Code
|
|
29
|
+
|
|
30
|
+
Install VS Code `ESLint` extension and create `.vscode/settings.json`
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"editor.codeActionsOnSave": {
|
|
35
|
+
"source.fixAll.eslint": true
|
|
36
|
+
},
|
|
37
|
+
"editor.formatOnSave": false
|
|
38
|
+
// "prettier.enable": true,
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
</details>
|
|
42
|
+
|
|
43
|
+
#### LICENSE
|
|
44
|
+
|
|
45
|
+
MIT License © 2025-PRESENT [Jiakun Zhao](https://github.com/jiakun-zhao)
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
|
|
|
4
4
|
|
|
5
5
|
/* This file is generated by eslint-typegen, for augmenting rules types in ESLint */
|
|
6
6
|
/* You might want to include this file in tsconfig.json but excluded from git */
|
|
7
|
-
/* eslint-typegen-hash:
|
|
7
|
+
/* eslint-typegen-hash: -AUfUQM0_NDYtGZWthHGIFC1_sS_ud0xf_XNyTI_F-8 */
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -1182,9 +1182,9 @@ interface RuleOptions {
|
|
|
1182
1182
|
'mine/no-blank-before-astro-element'?: Linter.RuleEntry<[]>
|
|
1183
1183
|
/**
|
|
1184
1184
|
* Enforce no blank in astro frontmatter start
|
|
1185
|
-
* @see https://example.com/no-blank-in-astro-frontmatter-
|
|
1185
|
+
* @see https://example.com/no-blank-in-astro-frontmatter-edge
|
|
1186
1186
|
*/
|
|
1187
|
-
'mine/no-blank-in-astro-frontmatter-
|
|
1187
|
+
'mine/no-blank-in-astro-frontmatter-edge'?: Linter.RuleEntry<[]>
|
|
1188
1188
|
/**
|
|
1189
1189
|
* Enforce no space in empty object
|
|
1190
1190
|
* @see https://example.com/no-space-in-empty-block
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { FlatGitignoreOptions } from 'eslint-config-flat-gitignore';
|
|
|
4
4
|
|
|
5
5
|
/* This file is generated by eslint-typegen, for augmenting rules types in ESLint */
|
|
6
6
|
/* You might want to include this file in tsconfig.json but excluded from git */
|
|
7
|
-
/* eslint-typegen-hash:
|
|
7
|
+
/* eslint-typegen-hash: -AUfUQM0_NDYtGZWthHGIFC1_sS_ud0xf_XNyTI_F-8 */
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
@@ -1182,9 +1182,9 @@ interface RuleOptions {
|
|
|
1182
1182
|
'mine/no-blank-before-astro-element'?: Linter.RuleEntry<[]>
|
|
1183
1183
|
/**
|
|
1184
1184
|
* Enforce no blank in astro frontmatter start
|
|
1185
|
-
* @see https://example.com/no-blank-in-astro-frontmatter-
|
|
1185
|
+
* @see https://example.com/no-blank-in-astro-frontmatter-edge
|
|
1186
1186
|
*/
|
|
1187
|
-
'mine/no-blank-in-astro-frontmatter-
|
|
1187
|
+
'mine/no-blank-in-astro-frontmatter-edge'?: Linter.RuleEntry<[]>
|
|
1188
1188
|
/**
|
|
1189
1189
|
* Enforce no space in empty object
|
|
1190
1190
|
* @see https://example.com/no-space-in-empty-block
|
package/dist/index.mjs
CHANGED
|
@@ -135,7 +135,7 @@ async function astro() {
|
|
|
135
135
|
const pluginAstro = await findDynamicPlugin("eslint-plugin-astro");
|
|
136
136
|
return pluginAstro && createSharedAstroConfig(pluginAstro, {
|
|
137
137
|
"mine/no-blank-before-astro-element": "warn",
|
|
138
|
-
"mine/no-blank-in-astro-frontmatter-
|
|
138
|
+
"mine/no-blank-in-astro-frontmatter-edge": "warn"
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
function createSharedAstroConfig(plugin, rules = {}) {
|
|
@@ -372,23 +372,17 @@ function jsonc() {
|
|
|
372
372
|
];
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
const version = "4.0.
|
|
375
|
+
const version = "4.0.3";
|
|
376
376
|
|
|
377
|
-
|
|
378
|
-
const isNull = (val) => toString(val) === "[object Null]";
|
|
379
|
-
|
|
380
|
-
function isFileStart(node) {
|
|
377
|
+
function isDocumentStart(node) {
|
|
381
378
|
return node.range[0] === 0;
|
|
382
379
|
}
|
|
383
380
|
function isLineStart(node) {
|
|
384
381
|
return node.loc.start.column === 0;
|
|
385
382
|
}
|
|
386
|
-
function
|
|
383
|
+
function numOfLines(left, right) {
|
|
387
384
|
return right.loc.start.line - left.loc.end.line;
|
|
388
385
|
}
|
|
389
|
-
function isFrontmatterToken(token) {
|
|
390
|
-
return token?.value === "---";
|
|
391
|
-
}
|
|
392
386
|
|
|
393
387
|
const name$2 = "no-blank-before-astro-element";
|
|
394
388
|
const _noBlankBeforeAstroElement = createRule({
|
|
@@ -408,13 +402,13 @@ const _noBlankBeforeAstroElement = createRule({
|
|
|
408
402
|
return {
|
|
409
403
|
AstroFragment(node) {
|
|
410
404
|
const token = context.sourceCode.getTokenBefore(node);
|
|
411
|
-
if (
|
|
405
|
+
if (!token && !isDocumentStart(node)) {
|
|
412
406
|
context.report({
|
|
413
407
|
fix: (fixer) => fixer.removeRange([0, node.range[0]]),
|
|
414
408
|
loc: { start: { line: 1, column: 0 }, end: node.loc.start },
|
|
415
409
|
messageId: "unexpectedBlank"
|
|
416
410
|
});
|
|
417
|
-
} else if (
|
|
411
|
+
} else if (token && token.value === "---" && (!isLineStart(node) || numOfLines(token, node) !== 2)) {
|
|
418
412
|
context.report({
|
|
419
413
|
fix: (fixer) => fixer.replaceTextRange([token.range[1], node.range[0]], "\n\n"),
|
|
420
414
|
loc: { start: token.loc.end, end: node.loc.start },
|
|
@@ -426,8 +420,8 @@ const _noBlankBeforeAstroElement = createRule({
|
|
|
426
420
|
}
|
|
427
421
|
});
|
|
428
422
|
|
|
429
|
-
const name$1 = "no-blank-in-astro-frontmatter-
|
|
430
|
-
const
|
|
423
|
+
const name$1 = "no-blank-in-astro-frontmatter-edge";
|
|
424
|
+
const _noBlankInAstroFrontmatterEdge = createRule({
|
|
431
425
|
name: name$1,
|
|
432
426
|
meta: {
|
|
433
427
|
docs: {
|
|
@@ -444,13 +438,23 @@ const _noBlankInAstroFrontmatterStart = createRule({
|
|
|
444
438
|
return {
|
|
445
439
|
Program(node) {
|
|
446
440
|
const [first, next] = context.sourceCode.getFirstTokens(node, { count: 2 });
|
|
447
|
-
if (
|
|
441
|
+
if (first && first.value === "---" && next && next.loc.start.line !== 2) {
|
|
448
442
|
context.report({
|
|
449
443
|
fix: (fixer) => fixer.replaceTextRange([3, next.range[0]], "\n"),
|
|
450
444
|
loc: { start: { line: 1, column: 0 }, end: next.loc.start },
|
|
451
445
|
messageId: "unexpectedBlank"
|
|
452
446
|
});
|
|
453
447
|
}
|
|
448
|
+
},
|
|
449
|
+
AstroFragment(node) {
|
|
450
|
+
const [left, right] = context.sourceCode.getTokensBefore(node, { count: 2 });
|
|
451
|
+
if (right && right.value === "---" && left && left.value !== "---" && numOfLines(left, right) !== 1) {
|
|
452
|
+
context.report({
|
|
453
|
+
fix: (fixer) => fixer.replaceTextRange([left.range[1], right.range[0]], "\n"),
|
|
454
|
+
loc: { start: right.loc.end, end: left.loc.start },
|
|
455
|
+
messageId: "unexpectedBlank"
|
|
456
|
+
});
|
|
457
|
+
}
|
|
454
458
|
}
|
|
455
459
|
};
|
|
456
460
|
}
|
|
@@ -506,7 +510,7 @@ const _noSpaceInEmptyObject = createRule({
|
|
|
506
510
|
const rules = {
|
|
507
511
|
[name]: _noSpaceInEmptyObject,
|
|
508
512
|
[name$2]: _noBlankBeforeAstroElement,
|
|
509
|
-
[name$1]:
|
|
513
|
+
[name$1]: _noBlankInAstroFrontmatterEdge
|
|
510
514
|
};
|
|
511
515
|
const pluginMine = {
|
|
512
516
|
meta: {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jiakun-zhao/eslint-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
5
|
-
"description": "Jiakun's ESLint config.",
|
|
4
|
+
"version": "4.0.3",
|
|
5
|
+
"description": "Jiakun Zhao's ESLint config.",
|
|
6
6
|
"author": "Jiakun Zhao <hi@zhaojiakun.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"homepage": "https://github.com/jiakun-zhao/eslint-config",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"dev": "config-inspector --open=false",
|
|
72
72
|
"release": "bumpp && pnpm publish && npx cnpm sync @jiakun-zhao/eslint-config",
|
|
73
73
|
"stub": "unbuild --stub",
|
|
74
|
-
"test": "vitest"
|
|
74
|
+
"test": "vitest",
|
|
75
|
+
"typegen": "tsx ./scripts/typegen.ts"
|
|
75
76
|
}
|
|
76
77
|
}
|