@jiakun-zhao/eslint-config 4.0.2 → 4.0.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/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: eIswpN2Lb5CNp7vDuJhKvR7RwFYmqCMwNh9mkHCwgeU */
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-start
1185
+ * @see https://example.com/no-blank-in-astro-frontmatter-edge
1186
1186
  */
1187
- 'mine/no-blank-in-astro-frontmatter-start'?: Linter.RuleEntry<[]>
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: eIswpN2Lb5CNp7vDuJhKvR7RwFYmqCMwNh9mkHCwgeU */
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-start
1185
+ * @see https://example.com/no-blank-in-astro-frontmatter-edge
1186
1186
  */
1187
- 'mine/no-blank-in-astro-frontmatter-start'?: Linter.RuleEntry<[]>
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-start": "warn"
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.2";
375
+ const version = "4.0.4";
376
376
 
377
- const toString = (v) => Object.prototype.toString.call(v);
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 numOfBlankLines(left, right) {
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 (isNull(token) && !isFileStart(node)) {
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 (isFrontmatterToken(token) && (!isLineStart(node) || numOfBlankLines(token, node) !== 2)) {
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-start";
430
- const _noBlankInAstroFrontmatterStart = createRule({
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 (isFrontmatterToken(first) && next && next.loc.start.line !== 2) {
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: left.loc.end, end: right.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]: _noBlankInAstroFrontmatterStart
513
+ [name$1]: _noBlankInAstroFrontmatterEdge
510
514
  };
511
515
  const pluginMine = {
512
516
  meta: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jiakun-zhao/eslint-config",
3
3
  "type": "module",
4
- "version": "4.0.2",
4
+ "version": "4.0.4",
5
5
  "description": "Jiakun Zhao's ESLint config.",
6
6
  "author": "Jiakun Zhao <hi@zhaojiakun.com>",
7
7
  "license": "MIT",
@@ -69,7 +69,7 @@
69
69
  "scripts": {
70
70
  "build": "unbuild",
71
71
  "dev": "config-inspector --open=false",
72
- "release": "bumpp && pnpm publish && npx cnpm sync @jiakun-zhao/eslint-config",
72
+ "release": "pnpm typegen && bumpp && pnpm publish && npx cnpm sync @jiakun-zhao/eslint-config",
73
73
  "stub": "unbuild --stub",
74
74
  "test": "vitest",
75
75
  "typegen": "tsx ./scripts/typegen.ts"