Skip to content

Commit 4da7a28

Browse files
authored
refactor(eslint-plugin-mark): restructure configs and update tsconfig.json (#12)
This pull request includes several changes to the `eslint-plugin-mark` package, focusing on configuration refactoring and build script updates. The most important changes are summarized below: ### Configuration Refactoring: * [`packages/eslint-plugin-mark/src/configs/all.js`](diffhunk://#diff-dcdf50541cdda584e7b5e20419349e2a8760d86d4d140d12dbd1d97b3084703fL2-R9): Refactored to import the new `base.js` configuration and updated the `all` function to extend the base configuration. [[1]](diffhunk://#diff-dcdf50541cdda584e7b5e20419349e2a8760d86d4d140d12dbd1d97b3084703fL2-R9) [[2]](diffhunk://#diff-dcdf50541cdda584e7b5e20419349e2a8760d86d4d140d12dbd1d97b3084703fL26-R33) * [`packages/eslint-plugin-mark/src/configs/base.js`](diffhunk://#diff-ca6e352859484792fa1631527eb0aea682ea1b33b962674c8fe86ecb09edf0d5R1-R41): Added a new base configuration file to centralize common configuration settings. * [`packages/eslint-plugin-mark/src/configs/index.js`](diffhunk://#diff-b203cdc09e7b9c5b3872303a75b6a7d4570e43a16311e2f9c3484e18b15247f9R2-R4): Updated to export the new `base` configuration alongside the existing `all` configuration. * [`packages/eslint-plugin-mark/src/index.js`](diffhunk://#diff-70f2388a14811bff072b178c7cfb31ba7a827976b08cc805892d9175b97e2277L12-R12): Modified to import and use the new `base` configuration, and updated the `configs` export to include both `all` and `base` configurations for `commonmark` and `gfm`. [[1]](diffhunk://#diff-70f2388a14811bff072b178c7cfb31ba7a827976b08cc805892d9175b97e2277L12-R12) [[2]](diffhunk://#diff-70f2388a14811bff072b178c7cfb31ba7a827976b08cc805892d9175b97e2277R28-R29) [[3]](diffhunk://#diff-70f2388a14811bff072b178c7cfb31ba7a827976b08cc805892d9175b97e2277L43-R48) ### Build Script Update: * [`packages/eslint-plugin-mark/package.json`](diffhunk://#diff-9b9400561d26b4f60200e53b8fbb54b0ef18955f8348a54f396c6ac386667a0dL57-R57): Updated the `build` script to include copying the `types.d.ts` file from the `src/core` directory to the `build/core` directory. ### Minor Changes: * [`eslint.config.mjs`](diffhunk://#diff-9601a8f6c734c2001be34a2361f76946d19a39a709b5e8c624a2a5a0aade05f2L11-R11): Corrected the configuration name from `mark.configs.all.gfm` to `mark.configs.allGfm`. * [`packages/eslint-plugin-mark/tsconfig.json`](diffhunk://#diff-d43f970297ed51b8f9c9ac1d51eccb4b9151da678cfcb9275e284a21143acddaL14-R14): Expanded the `include` paths to cover `.mjs` and `.cjs` files.
1 parent e867d94 commit 4da7a28

File tree

7 files changed

+58
-22
lines changed

7 files changed

+58
-22
lines changed

eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export default [
88
},
99
bananass.configs.js,
1010
bananass.configs.ts,
11-
mark.configs.all.gfm,
11+
mark.configs.allGfm,
1212
];

packages/eslint-plugin-mark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
},
5555
"scripts": {
5656
"prepublishOnly": "npm run build",
57-
"build": "npx tsc && shx cp ../../LICENSE.md ../../README.md .",
57+
"build": "npx tsc && shx cp ./src/core/types.d.ts ./build/core/types.d.ts && shx cp ../../LICENSE.md ../../README.md .",
5858
"test": "node --test"
5959
},
6060
"peerDependencies": {

packages/eslint-plugin-mark/src/configs/all.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
/**
2-
* @fileoverview All rulesets from `eslint-plugin-mark`.
2+
* @fileoverview All configuration.
33
*/
44

55
// --------------------------------------------------------------------------------
66
// Import
77
// --------------------------------------------------------------------------------
88

9-
import markdown from '@eslint/markdown';
10-
import rules from '../rules/index.js';
9+
import base from './base.js';
1110

1211
// --------------------------------------------------------------------------------
1312
// Typedefs
@@ -23,21 +22,15 @@ import rules from '../rules/index.js';
2322
// --------------------------------------------------------------------------------
2423

2524
/**
26-
* All rulesets from `eslint-plugin-mark`.
25+
* All configuration.
2726
*
2827
* @param {ParserMode} parserMode
2928
* @return {LinterConfig}
3029
*/
3130
export default function all(parserMode) {
3231
return {
33-
name: `all/${parserMode}`,
34-
files: ['**/*.md'],
35-
plugins: {
36-
markdown,
37-
// @ts-ignore -- TODO: https://github.com/eslint/eslint/issues/19521, https://github.com/eslint/eslint/issues/19523
38-
mark: { rules },
39-
},
40-
language: `markdown/${parserMode}`,
32+
...base(parserMode),
33+
name: `mark/all/${parserMode}`,
4134
rules: {
4235
'mark/no-curly-quotes': 'error',
4336
'mark/no-double-spaces': 'error',
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @fileoverview Base configuration.
3+
*/
4+
5+
// --------------------------------------------------------------------------------
6+
// Import
7+
// --------------------------------------------------------------------------------
8+
9+
import markdown from '@eslint/markdown';
10+
import rules from '../rules/index.js';
11+
12+
// --------------------------------------------------------------------------------
13+
// Typedefs
14+
// --------------------------------------------------------------------------------
15+
16+
/**
17+
* @typedef {import("@eslint/markdown").ParserMode} ParserMode
18+
* @typedef {import("eslint").Linter.Config} LinterConfig
19+
*/
20+
21+
// --------------------------------------------------------------------------------
22+
// Export
23+
// --------------------------------------------------------------------------------
24+
25+
/**
26+
* Base configuration.
27+
*
28+
* @param {ParserMode} parserMode
29+
* @return {LinterConfig}
30+
*/
31+
export default function base(parserMode) {
32+
return {
33+
name: `mark/base/${parserMode}`,
34+
files: ['**/*.md'],
35+
plugins: {
36+
markdown,
37+
mark: { rules },
38+
},
39+
language: `markdown/${parserMode}`,
40+
};
41+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import all from './all.js';
2+
import base from './base.js';
23

3-
export { all };
4+
export { all, base };

packages/eslint-plugin-mark/src/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import { createRequire } from 'node:module';
1111

12-
import { all } from './configs/index.js';
12+
import { all, base } from './configs/index.js';
1313
import rules from './rules/index.js';
1414

1515
// --------------------------------------------------------------------------------
@@ -25,6 +25,8 @@ import rules from './rules/index.js';
2525
// --------------------------------------------------------------------------------
2626

2727
const { name, version } = createRequire(import.meta.url)('../package.json');
28+
const commonmark = 'commonmark';
29+
const gfm = 'gfm';
2830

2931
// --------------------------------------------------------------------------------
3032
// Export
@@ -40,10 +42,9 @@ export default {
4042
rules,
4143

4244
configs: {
43-
all: {
44-
// @ts-ignore -- TODO: https://github.com/eslint/eslint/issues/19519
45-
commonmark: all('commonmark'),
46-
gfm: all('gfm'),
47-
},
45+
allCommonmark: all(commonmark),
46+
allGfm: all(gfm),
47+
baseCommonmark: base(commonmark),
48+
baseGfm: base(gfm),
4849
},
4950
};

packages/eslint-plugin-mark/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"moduleResolution": "Node",
1212
"skipLibCheck": true
1313
},
14-
"include": ["src/**/*.js"],
14+
"include": ["src/**/*.js", "src/**/*.mjs", "src/**/*.cjs"],
1515
"exclude": ["src/**/*.test.js"]
1616
}

0 commit comments

Comments
 (0)