@kazupon/eslint-config 0.33.3 → 0.35.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
@@ -140,7 +140,7 @@ The following built-in preset configurations are supported:
140
140
  | `jsonc` | [`eslint-plugin-jsonc`](https://www.npmjs.com/package/eslint-plugin-jsonc) | yes |
141
141
  | `yml` | [`eslint-plugin-yml`](https://www.npmjs.com/package/eslint-plugin-yml) | yes |
142
142
  | `toml` | [`eslint-plugin-toml`](https://www.npmjs.com/package/eslint-plugin-toml) | yes |
143
- | `markdown` | [`@eslint/markdown`](https://www.npmjs.com/package/@eslint/markdown) | yes |
143
+ | `markdown` | [`@eslint/markdown`](https://www.npmjs.com/package/@eslint/markdown), [`eslint-plugin-markdown-preferences`](https://github.com/ota-meshi/eslint-plugin-markdown-preferences) | yes |
144
144
  | `css` | [`@eslint/css`](https://www.npmjs.com/package/@eslint/css) | yes |
145
145
  | `html` | [`@html-eslint/eslint-plugin`](https://www.npmjs.com/package/@html-eslint/eslint-plugin) | yes |
146
146
 
package/dist/index.d.ts CHANGED
@@ -99,6 +99,11 @@ interface CommentsRules {
99
99
  */
100
100
  "@kazupon/no-tag-comments"?: Linter.RuleEntry<KazuponNoTagComments>;
101
101
  /**
102
+ * enforce the use of inline code for specific words on comments
103
+ * @see https://eslint-plugin.kazupon.dev/rules/prefer-inline-code-words-comments
104
+ */
105
+ "@kazupon/prefer-inline-code-words-comments"?: Linter.RuleEntry<KazuponPreferInlineCodeWordsComments>;
106
+ /**
102
107
  * enforce adding a scope to tag comments
103
108
  * @see https://eslint-plugin.kazupon.dev/rules/prefer-scope-on-tag-comment
104
109
  */
@@ -123,6 +128,10 @@ type EslintCommunityEslintCommentsRequireDescription = [] | [{
123
128
  type KazuponNoTagComments = [] | [{
124
129
  tags?: [string, ...(string)[]];
125
130
  }];
131
+ // ----- @kazupon/prefer-inline-code-words-comments -----
132
+ type KazuponPreferInlineCodeWordsComments = [] | [{
133
+ words: string[];
134
+ }];
126
135
  // ----- @kazupon/prefer-scope-on-tag-comment -----
127
136
  type KazuponPreferScopeOnTagComment = [] | [{
128
137
  tags?: [string, ...(string)[]];
@@ -5341,6 +5350,31 @@ type JsoncSpaceUnaryOps = [] | [{
5341
5350
  //#endregion
5342
5351
  //#region src/types/gens/markdown.d.ts
5343
5352
  interface MarkdownRules {
5353
+ /**
5354
+ * enforce consistent hard linebreak style.
5355
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/hard-linebreak-style.html
5356
+ */
5357
+ "markdown-preferences/hard-linebreak-style"?: Linter.RuleEntry<MarkdownPreferencesHardLinebreakStyle>;
5358
+ /**
5359
+ * disallow text backslash at the end of a line.
5360
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/no-text-backslash-linebreak.html
5361
+ */
5362
+ "markdown-preferences/no-text-backslash-linebreak"?: Linter.RuleEntry<[]>;
5363
+ /**
5364
+ * disallow trailing whitespace at the end of lines in Markdown files.
5365
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/no-trailing-spaces.html
5366
+ */
5367
+ "markdown-preferences/no-trailing-spaces"?: Linter.RuleEntry<MarkdownPreferencesNoTrailingSpaces>;
5368
+ /**
5369
+ * enforce the use of inline code for specific words.
5370
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/prefer-inline-code-words.html
5371
+ */
5372
+ "markdown-preferences/prefer-inline-code-words"?: Linter.RuleEntry<MarkdownPreferencesPreferInlineCodeWords>;
5373
+ /**
5374
+ * enforce the specified word to be a link.
5375
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/prefer-linked-words.html
5376
+ */
5377
+ "markdown-preferences/prefer-linked-words"?: Linter.RuleEntry<MarkdownPreferencesPreferLinkedWords>;
5344
5378
  /**
5345
5379
  * Require languages for fenced code blocks
5346
5380
  * @see https://github.com/eslint/markdown/blob/main/docs/rules/fenced-code-language.md
@@ -5433,6 +5467,41 @@ interface MarkdownRules {
5433
5467
  "markdown/table-column-count"?: Linter.RuleEntry<MarkdownTableColumnCount>;
5434
5468
  }
5435
5469
  /* ======= Declarations ======= */
5470
+ // ----- markdown-preferences/hard-linebreak-style -----
5471
+ type MarkdownPreferencesHardLinebreakStyle = [] | [{
5472
+ style?: ("backslash" | "spaces");
5473
+ }];
5474
+ // ----- markdown-preferences/no-trailing-spaces -----
5475
+ type MarkdownPreferencesNoTrailingSpaces = [] | [{
5476
+ skipBlankLines?: boolean;
5477
+ ignoreComments?: boolean;
5478
+ }];
5479
+ // ----- markdown-preferences/prefer-inline-code-words -----
5480
+ type MarkdownPreferencesPreferInlineCodeWords = [] | [{
5481
+ words: string[];
5482
+ ignores?: {
5483
+ words?: (string | string[]);
5484
+ node?: {
5485
+ [k: string]: unknown | undefined;
5486
+ };
5487
+ [k: string]: unknown | undefined;
5488
+ }[];
5489
+ [k: string]: unknown | undefined;
5490
+ }];
5491
+ // ----- markdown-preferences/prefer-linked-words -----
5492
+ type MarkdownPreferencesPreferLinkedWords = [] | [{
5493
+ words: ({
5494
+ [k: string]: (string | null);
5495
+ } | string[]);
5496
+ ignores?: {
5497
+ words?: (string | string[]);
5498
+ node?: {
5499
+ [k: string]: unknown | undefined;
5500
+ };
5501
+ [k: string]: unknown | undefined;
5502
+ }[];
5503
+ [k: string]: unknown | undefined;
5504
+ }];
5436
5505
  // ----- markdown/fenced-code-language -----
5437
5506
  type MarkdownFencedCodeLanguage = [] | [{
5438
5507
  required?: string[];
@@ -15685,6 +15754,13 @@ interface CommentsOptions {
15685
15754
  * An options for `@kazupon/eslint-plugin` comment config
15686
15755
  */
15687
15756
  kazupon?: OverridesOptions<CommentsRules>;
15757
+ /**
15758
+ * enforce inline code for specific words on comments
15759
+ *
15760
+ * @see https://eslint-plugin.kazupon.dev/rules/prefer-inline-code-words-comments#options
15761
+ * @default []
15762
+ */
15763
+ inlineCodeWords?: string[];
15688
15764
  }
15689
15765
  /**
15690
15766
  * configure comments preset for the below plugins
@@ -15903,6 +15979,55 @@ interface MarkdownOptions {
15903
15979
  * enable block extensions
15904
15980
  */
15905
15981
  blockExtensions?: string[];
15982
+ /**
15983
+ * enable preferences
15984
+ *
15985
+ * @see https://github.com/ota-meshi/eslint-plugin-markdown-preferences
15986
+ * @default true
15987
+ */
15988
+ preferences?: boolean;
15989
+ /**
15990
+ * detect inline code words for back-quoted in markdown (`words` option of `markdown-preferences/prefer-inline-code-words`)
15991
+ *
15992
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/prefer-inline-code-words.html#%F0%9F%94%A7-options
15993
+ * @default []
15994
+ */
15995
+ inlineCodeWords?: string[];
15996
+ /**
15997
+ * ignore inline code words for back-quoted in markdown (`ignores` option of `markdown-preferences/prefer-inline-code-words`)
15998
+ *
15999
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/prefer-inline-code-words.html#%F0%9F%94%A7-options
16000
+ * @default []
16001
+ */
16002
+ inlineCodeWordsIgnores?: {
16003
+ words?: string | string[];
16004
+ node?: {
16005
+ [k: string]: unknown | undefined;
16006
+ };
16007
+ [k: string]: unknown | undefined;
16008
+ }[];
16009
+ /**
16010
+ * detect linked words for linked in markdown (`words` option of `markdown-preferences/prefer-linked-words`)
16011
+ *
16012
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/prefer-linked-words.html#%F0%9F%94%A7-options
16013
+ * @default []
16014
+ */
16015
+ linkedWords?: {
16016
+ [k: string]: string | null;
16017
+ } | string[];
16018
+ /**
16019
+ * ignore linked words for linked in markdown (`ignores` option of `markdown-preferences/prefer-linked-words`)
16020
+ *
16021
+ * @see https://ota-meshi.github.io/eslint-plugin-markdown-preferences/rules/prefer-linked-words.html#%F0%9F%94%A7-options
16022
+ * @default []
16023
+ */
16024
+ linkedWordsIgnores?: {
16025
+ words?: string | string[];
16026
+ node?: {
16027
+ [k: string]: unknown | undefined;
16028
+ };
16029
+ [k: string]: unknown | undefined;
16030
+ }[];
15906
16031
  }
15907
16032
  // export const parserPlain: Linter.Parser = {
15908
16033
  // meta: {
package/dist/index.js CHANGED
@@ -112,6 +112,7 @@ async function comments(options = {}) {
112
112
  const kazupon = await loadPlugin("@kazupon/eslint-plugin");
113
113
  const directives = options.directives ?? {};
114
114
  const kazuponOptions = options.kazupon ?? {};
115
+ const inlineCodeWords = options.inlineCodeWords ?? [];
115
116
  return [{
116
117
  name: "@eslint-community/eslint-comments",
117
118
  ignores: directives.ignores ? [GLOB_MARKDOWN, ...directives.ignores] : [GLOB_MARKDOWN],
@@ -126,6 +127,7 @@ async function comments(options = {}) {
126
127
  ignores: [...config.ignores, ...kazuponOptions.ignores || []],
127
128
  rules: {
128
129
  ...config.rules,
130
+ "@kazupon/prefer-inline-code-words-comments": ["error", { words: inlineCodeWords }],
129
131
  ...kazuponOptions.rules
130
132
  }
131
133
  }))];
@@ -555,7 +557,7 @@ function jsoncSort() {
555
557
  * @returns {Promise<Linter.Config[]>} eslint flat configurations with `@eslint/markdown` and overrides
556
558
  */
557
559
  async function markdown(options = {}) {
558
- const { rules: overrideRules = {}, files = [GLOB_MARKDOWN], blockExtensions = [] } = options;
560
+ const { rules: overrideRules = {}, files = [GLOB_MARKDOWN], blockExtensions = [], preferences = true, inlineCodeWords = [], inlineCodeWordsIgnores = [], linkedWords = [], linkedWordsIgnores = [] } = options;
559
561
  const language = options.language || "gfm";
560
562
  /**
561
563
  * TODO: remove this option
@@ -566,7 +568,7 @@ async function markdown(options = {}) {
566
568
  const recommended = { ...markdown$1.configs["recommended"][0] };
567
569
  const codeblocks = markdown$1.configs.processor[2];
568
570
  recommended.language = `markdown/${language}`;
569
- return [
571
+ const configs = [
570
572
  recommended,
571
573
  {
572
574
  name: "markdown/makedown-in-markdown",
@@ -578,20 +580,40 @@ async function markdown(options = {}) {
578
580
  name: "makrdown/ignore-lint-blocks-in-typescript",
579
581
  files: ["**/*.md/**"],
580
582
  languageOptions: { parserOptions: { project: null } }
581
- },
582
- {
583
- name: "@kazupon/markdown",
584
- files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, ...blockExtensions.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
585
- languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
583
+ }
584
+ ];
585
+ if (preferences) {
586
+ const preferencesPlugin = await loadPlugin("eslint-plugin-markdown-preferences");
587
+ configs.push({
588
+ ...preferencesPlugin.configs.recommended,
586
589
  rules: {
587
- ...codeblocks.rules,
588
- "import/no-unresolved": "off",
589
- "unused-imports/no-unused-vars": "off",
590
- "@typescript-eslint/no-unused-vars": "off",
591
- ...overrideRules
590
+ ...preferencesPlugin.configs.recommended.rules,
591
+ "markdown-preferences/no-trailing-spaces": "error",
592
+ "markdown-preferences/prefer-linked-words": ["error", {
593
+ words: linkedWords,
594
+ ignores: linkedWordsIgnores
595
+ }],
596
+ "markdown-preferences/prefer-inline-code-words": ["error", {
597
+ words: inlineCodeWords,
598
+ ignores: inlineCodeWordsIgnores
599
+ }]
592
600
  }
601
+ });
602
+ }
603
+ const custom = {
604
+ name: "@kazupon/markdown",
605
+ files: [`${GLOB_MARKDOWN}/${GLOB_SRC}`, ...blockExtensions.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
606
+ languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
607
+ rules: {
608
+ ...codeblocks.rules,
609
+ "import/no-unresolved": "off",
610
+ "unused-imports/no-unused-vars": "off",
611
+ "@typescript-eslint/no-unused-vars": "off",
612
+ ...overrideRules
593
613
  }
594
- ];
614
+ };
615
+ configs.push(custom);
616
+ return configs;
595
617
  }
596
618
  const md = markdown;
597
619
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kazupon/eslint-config",
3
3
  "description": "ESLint config for @kazupon",
4
- "version": "0.33.3",
4
+ "version": "0.35.0",
5
5
  "author": {
6
6
  "email": "kawakazu80@gmail.com",
7
7
  "name": "kazuya kawaguchi"
@@ -51,7 +51,7 @@
51
51
  "dependencies": {
52
52
  "@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
53
53
  "@eslint/js": "^9.32.0",
54
- "@kazupon/eslint-plugin": "^0.5.0",
54
+ "@kazupon/eslint-plugin": "^0.6.1",
55
55
  "@kazupon/jts-utils": "^0.6.0",
56
56
  "@stylistic/eslint-plugin": "^4.4.1",
57
57
  "eslint-flat-config-utils": "^2.1.0",
@@ -70,6 +70,7 @@
70
70
  "eslint-plugin-import": ">=2.31.0",
71
71
  "eslint-plugin-jsdoc": ">=51.0.0",
72
72
  "eslint-plugin-jsonc": ">=2.16.0",
73
+ "eslint-plugin-markdown-preferences": ">=0.5.0",
73
74
  "eslint-plugin-module-interop": ">=0.3.0",
74
75
  "eslint-plugin-promise": ">=6.4.0",
75
76
  "eslint-plugin-react": ">=7.35.0",
@@ -119,6 +120,9 @@
119
120
  "eslint-plugin-jsonc": {
120
121
  "optional": true
121
122
  },
123
+ "eslint-plugin-markdown-preferences": {
124
+ "optional": true
125
+ },
122
126
  "eslint-plugin-module-interop": {
123
127
  "optional": true
124
128
  },
@@ -188,6 +192,7 @@
188
192
  "eslint-plugin-import": "^2.32.0",
189
193
  "eslint-plugin-jsdoc": "^52.0.0",
190
194
  "eslint-plugin-jsonc": "^2.20.1",
195
+ "eslint-plugin-markdown-preferences": "^0.5.0",
191
196
  "eslint-plugin-module-interop": "^0.3.1",
192
197
  "eslint-plugin-promise": "^7.2.1",
193
198
  "eslint-plugin-react": "^7.37.5",