@entro314labs/markdownfix 0.0.10 → 0.0.11
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/ESLINT_INTEGRATION.md +38 -1
- package/README.md +31 -1
- package/cli.js +26 -2
- package/package.json +3 -3
package/ESLINT_INTEGRATION.md
CHANGED
|
@@ -46,12 +46,35 @@ While remark-lint handles markdown syntax and formatting, ESLint adds:
|
|
|
46
46
|
|
|
47
47
|
## Installation
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
### Local Installation (Project-specific)
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
pnpm add -D eslint eslint-plugin-mdx eslint-plugin-react
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
+
### Global Installation (Recommended)
|
|
56
|
+
|
|
57
|
+
Install `markdownfix` globally to use across all projects:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm install -g @entro314labs/markdownfix
|
|
61
|
+
# or
|
|
62
|
+
pnpm add -g @entro314labs/markdownfix
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Then use anywhere:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cd your-project
|
|
69
|
+
mdfix nuclear
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The tool will:
|
|
73
|
+
|
|
74
|
+
- ✅ Use your local `eslint.config.js` if it exists
|
|
75
|
+
- ✅ Fall back to bundled ESLint config if not found
|
|
76
|
+
- ✅ Always respect your local `.remarkrc.js` if present
|
|
77
|
+
|
|
55
78
|
## Configuration Files
|
|
56
79
|
|
|
57
80
|
### [eslint.config.js](./eslint.config.js)
|
|
@@ -63,6 +86,12 @@ ESLint 9 flat config that:
|
|
|
63
86
|
- Enables code block linting
|
|
64
87
|
- Defines globals for documentation examples
|
|
65
88
|
|
|
89
|
+
**Note:** When `markdownfix` is installed globally and run in a project:
|
|
90
|
+
|
|
91
|
+
- ✅ Uses local `eslint.config.js` if it exists
|
|
92
|
+
- ✅ Falls back to bundled config if not found
|
|
93
|
+
- ℹ️ Shows a message when using bundled config
|
|
94
|
+
|
|
66
95
|
### [.remarkrc.js](./.remarkrc.js)
|
|
67
96
|
|
|
68
97
|
Existing remark configuration with 40+ lint rules. This is **automatically used** by ESLint via the `mdx/remark` rule.
|
|
@@ -135,6 +164,7 @@ pnpm test
|
|
|
135
164
|
```
|
|
136
165
|
|
|
137
166
|
This runs `process:safe` which:
|
|
167
|
+
|
|
138
168
|
1. Checks formatting (no writes)
|
|
139
169
|
2. Runs remark-lint
|
|
140
170
|
3. Runs ESLint
|
|
@@ -194,6 +224,7 @@ See [.remarkrc.js](./.remarkrc.js) for full configuration.
|
|
|
194
224
|
### Catching Code Block Issues
|
|
195
225
|
|
|
196
226
|
**Before:**
|
|
227
|
+
|
|
197
228
|
```javascript
|
|
198
229
|
function example() {
|
|
199
230
|
var unused = "bad";
|
|
@@ -202,10 +233,12 @@ function example() {
|
|
|
202
233
|
```
|
|
203
234
|
|
|
204
235
|
**ESLint warnings:**
|
|
236
|
+
|
|
205
237
|
- `no-var`: Unexpected var, use let or const instead
|
|
206
238
|
- `no-unused-vars`: 'unused' is assigned but never used
|
|
207
239
|
|
|
208
240
|
**After:**
|
|
241
|
+
|
|
209
242
|
```javascript
|
|
210
243
|
function greet(name) {
|
|
211
244
|
return `Hello ${name}`;
|
|
@@ -217,6 +250,7 @@ console.log(greet("World"));
|
|
|
217
250
|
### Markdown Issues (remark-lint)
|
|
218
251
|
|
|
219
252
|
**Before:**
|
|
253
|
+
|
|
220
254
|
```markdown
|
|
221
255
|
#No Space After Hash
|
|
222
256
|
- item 1
|
|
@@ -225,10 +259,12 @@ console.log(greet("World"));
|
|
|
225
259
|
```
|
|
226
260
|
|
|
227
261
|
**Remark-lint errors:**
|
|
262
|
+
|
|
228
263
|
- Headings must have space after `#`
|
|
229
264
|
- List items need blank lines between them
|
|
230
265
|
|
|
231
266
|
**After:**
|
|
267
|
+
|
|
232
268
|
```markdown
|
|
233
269
|
# Proper Heading
|
|
234
270
|
|
|
@@ -246,6 +282,7 @@ Files are ignored via:
|
|
|
246
282
|
2. **Remark** - [.remarkignore](./.remarkignore)
|
|
247
283
|
|
|
248
284
|
Common ignored files:
|
|
285
|
+
|
|
249
286
|
- `README.md`
|
|
250
287
|
- `CHANGELOG.md`
|
|
251
288
|
- `LICENSE`
|
package/README.md
CHANGED
|
@@ -138,12 +138,14 @@ This is a warning message!
|
|
|
138
138
|
```
|
|
139
139
|
|
|
140
140
|
**Perfect for:**
|
|
141
|
+
|
|
141
142
|
- Nuxt Content projects
|
|
142
143
|
- Component-driven documentation
|
|
143
144
|
- Interactive markdown content
|
|
144
145
|
- Vue.js documentation sites
|
|
145
146
|
|
|
146
147
|
**File Usage:**
|
|
148
|
+
|
|
147
149
|
- `.mdc` extension - Dedicated MDC files (like `.mdx` for JSX)
|
|
148
150
|
- MDC syntax also works in `.md` and `.mdx` files
|
|
149
151
|
|
|
@@ -337,6 +339,34 @@ Central configuration defining:
|
|
|
337
339
|
4. Lint presets + rules
|
|
338
340
|
5. `remark-stringify` - Must be last
|
|
339
341
|
|
|
342
|
+
### `eslint.config.js` (Optional)
|
|
343
|
+
|
|
344
|
+
When using ESLint integration for MDX/code blocks:
|
|
345
|
+
|
|
346
|
+
**Global Installation Behavior:**
|
|
347
|
+
|
|
348
|
+
- ✅ Uses your local `eslint.config.js` if it exists
|
|
349
|
+
- ✅ Falls back to bundled config if not found
|
|
350
|
+
- ℹ️ Shows message: "Using bundled ESLint config"
|
|
351
|
+
|
|
352
|
+
**Custom Configuration:**
|
|
353
|
+
|
|
354
|
+
Create `eslint.config.js` in your project to override defaults:
|
|
355
|
+
|
|
356
|
+
```javascript
|
|
357
|
+
import * as mdxPlugin from 'eslint-plugin-mdx';
|
|
358
|
+
|
|
359
|
+
export default [
|
|
360
|
+
{
|
|
361
|
+
files: ['**/*.{md,mdx,mdc,mdd}'],
|
|
362
|
+
...mdxPlugin.flat,
|
|
363
|
+
// Your custom rules here
|
|
364
|
+
}
|
|
365
|
+
];
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
See [ESLINT\_INTEGRATION.md](ESLINT_INTEGRATION.md) for full details.
|
|
369
|
+
|
|
340
370
|
### `.remarkignore`
|
|
341
371
|
|
|
342
372
|
Files excluded from processing:
|
|
@@ -468,7 +498,7 @@ Desktop knowledge management application with MDD integration:
|
|
|
468
498
|
## Documentation
|
|
469
499
|
|
|
470
500
|
- **[content/guides/style-guide.md](content/guides/style-guide.md)** - Style specifications
|
|
471
|
-
- **[
|
|
501
|
+
- **[ESLINT\_INTEGRATION.md](ESLINT_INTEGRATION.md)** - ESLint + MDX integration guide
|
|
472
502
|
|
|
473
503
|
## Tech Stack
|
|
474
504
|
|
package/cli.js
CHANGED
|
@@ -240,11 +240,18 @@ async function runNuclearMode(files, options = {}) {
|
|
|
240
240
|
|
|
241
241
|
// Step 3 & 4: ESLint (only if available)
|
|
242
242
|
if (hasEslint) {
|
|
243
|
+
const eslintConfig = await getEslintConfigPath();
|
|
244
|
+
const configSource = eslintConfig.includes(process.cwd()) ? 'local' : 'bundled';
|
|
245
|
+
|
|
246
|
+
if (!quiet && configSource === 'bundled') {
|
|
247
|
+
console.log(' ℹ️ Using bundled ESLint config (no local config found)\n');
|
|
248
|
+
}
|
|
249
|
+
|
|
243
250
|
// Step 3: ESLint auto-fix
|
|
244
251
|
if (!quiet) console.log('Step 3/4: Running ESLint auto-fix...');
|
|
245
252
|
try {
|
|
246
253
|
const fileList = files.join(' ');
|
|
247
|
-
const eslintCmd = `npx eslint --
|
|
254
|
+
const eslintCmd = `npx eslint --config "${eslintConfig}" --fix ${fileList}`;
|
|
248
255
|
|
|
249
256
|
try {
|
|
250
257
|
execSync(eslintCmd, {
|
|
@@ -267,7 +274,7 @@ async function runNuclearMode(files, options = {}) {
|
|
|
267
274
|
if (!quiet) console.log('Step 4/4: Running ESLint linting...');
|
|
268
275
|
try {
|
|
269
276
|
const fileList = files.join(' ');
|
|
270
|
-
const eslintCmd = `npx eslint --
|
|
277
|
+
const eslintCmd = `npx eslint --config "${eslintConfig}" ${fileList}`;
|
|
271
278
|
|
|
272
279
|
execSync(eslintCmd, {
|
|
273
280
|
stdio: quiet ? 'pipe' : 'inherit',
|
|
@@ -323,6 +330,23 @@ async function checkEslintAvailable() {
|
|
|
323
330
|
}
|
|
324
331
|
}
|
|
325
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Get ESLint config path
|
|
335
|
+
* Returns the config from current directory if it exists, otherwise uses the bundled one
|
|
336
|
+
*/
|
|
337
|
+
async function getEslintConfigPath() {
|
|
338
|
+
const localConfig = path.join(process.cwd(), 'eslint.config.js');
|
|
339
|
+
|
|
340
|
+
try {
|
|
341
|
+
await fs.access(localConfig);
|
|
342
|
+
return localConfig;
|
|
343
|
+
} catch {
|
|
344
|
+
// Use bundled config from markdownfix package
|
|
345
|
+
const bundledConfig = new URL('./eslint.config.js', import.meta.url).pathname;
|
|
346
|
+
return bundledConfig;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
326
350
|
/**
|
|
327
351
|
* Initialize .remarkrc.js configuration
|
|
328
352
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entro314labs/markdownfix",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Opinionated markdown formatter and linter for MD, MDX, MDC, and MDD files using Remark/Unified ecosystem",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -126,8 +126,8 @@
|
|
|
126
126
|
},
|
|
127
127
|
"scripts": {
|
|
128
128
|
"lint": "remark . --quiet --frail",
|
|
129
|
-
"lint:eslint": "eslint --
|
|
130
|
-
"lint:eslint:fix": "eslint --
|
|
129
|
+
"lint:eslint": "eslint --config eslint.config.js .",
|
|
130
|
+
"lint:eslint:fix": "eslint --config eslint.config.js --fix .",
|
|
131
131
|
"lint:all": "pnpm run lint && pnpm run lint:eslint",
|
|
132
132
|
"format": "remark . --output --quiet",
|
|
133
133
|
"format:check": "remark . --quiet",
|