@nzyme/eslint 0.15.1 → 0.16.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/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/markdown.d.ts +8 -0
- package/dist/markdown.js +22 -0
- package/dist/markdown.js.map +1 -0
- package/dist/packageJson.d.ts +7 -0
- package/dist/packageJson.js +23 -0
- package/dist/packageJson.js.map +1 -0
- package/dist/plugin.d.ts +6 -0
- package/dist/plugin.js +18 -0
- package/dist/plugin.js.map +1 -0
- package/dist/rules/exportsSourceFirst.d.ts +12 -0
- package/dist/rules/exportsSourceFirst.js +110 -0
- package/dist/rules/exportsSourceFirst.js.map +1 -0
- package/dist/rules/exportsSourceFirst.test.d.ts +1 -0
- package/dist/rules/exportsSourceFirst.test.js +87 -0
- package/dist/rules/exportsSourceFirst.test.js.map +1 -0
- package/dist/rules/filesCoverExports.d.ts +10 -0
- package/dist/rules/filesCoverExports.js +105 -0
- package/dist/rules/filesCoverExports.js.map +1 -0
- package/dist/rules/filesCoverExports.test.d.ts +1 -0
- package/dist/rules/filesCoverExports.test.js +87 -0
- package/dist/rules/filesCoverExports.test.js.map +1 -0
- package/dist/rules/formatMarkdown.d.ts +7 -0
- package/dist/rules/formatMarkdown.js +149 -0
- package/dist/rules/formatMarkdown.js.map +1 -0
- package/dist/rules/formatMarkdown.test.d.ts +1 -0
- package/dist/rules/formatMarkdown.test.js +45 -0
- package/dist/rules/formatMarkdown.test.js.map +1 -0
- package/dist/rules/jsonPackage.d.ts +9 -0
- package/dist/rules/jsonPackage.js +25 -0
- package/dist/rules/jsonPackage.js.map +1 -0
- package/dist/rules/markdownFormat.d.ts +10 -0
- package/dist/rules/markdownFormat.js +42 -0
- package/dist/rules/markdownFormat.js.map +1 -0
- package/dist/rules/markdownFormat.test.d.ts +1 -0
- package/dist/rules/markdownFormat.test.js +46 -0
- package/dist/rules/markdownFormat.test.js.map +1 -0
- package/dist/rules/publishAccessPublic.d.ts +9 -0
- package/dist/rules/publishAccessPublic.js +44 -0
- package/dist/rules/publishAccessPublic.js.map +1 -0
- package/dist/rules/publishAccessPublic.test.d.ts +1 -0
- package/dist/rules/publishAccessPublic.test.js +38 -0
- package/dist/rules/publishAccessPublic.test.js.map +1 -0
- package/oxlintrc.json +8 -0
- package/package.json +26 -12
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an ESLint config for Markdown files.
|
|
3
|
+
*
|
|
4
|
+
* Files are parsed as GitHub-flavored Markdown with YAML frontmatter, and `nzyme/markdown-format`
|
|
5
|
+
* keeps them in the token-minimising format: `eslint --fix` rewrites an unformatted file. Gitignored
|
|
6
|
+
* files are skipped by the rule itself, because ESLint does not read `.gitignore`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function markdown(): import("eslint/config").ConfigObject[];
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import markdownPlugin from '@eslint/markdown';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import { nzymePlugin } from './plugin.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates an ESLint config for Markdown files.
|
|
6
|
+
*
|
|
7
|
+
* Files are parsed as GitHub-flavored Markdown with YAML frontmatter, and `nzyme/markdown-format`
|
|
8
|
+
* keeps them in the token-minimising format: `eslint --fix` rewrites an unformatted file. Gitignored
|
|
9
|
+
* files are skipped by the rule itself, because ESLint does not read `.gitignore`.
|
|
10
|
+
*/
|
|
11
|
+
export function markdown() {
|
|
12
|
+
return defineConfig({
|
|
13
|
+
files: ['**/*.md', '**/*.mdx'],
|
|
14
|
+
plugins: { markdown: markdownPlugin, nzyme: nzymePlugin },
|
|
15
|
+
language: 'markdown/gfm',
|
|
16
|
+
languageOptions: { frontmatter: 'yaml' },
|
|
17
|
+
rules: {
|
|
18
|
+
'nzyme/markdown-format': 'error',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown.js","sourceRoot":"","sources":["../src/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ;IACpB,OAAO,YAAY,CAAC;QAChB,KAAK,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;QAC9B,OAAO,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,KAAK,EAAE,WAAW,EAAE;QACzD,QAAQ,EAAE,cAAc;QACxB,eAAe,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE;QACxC,KAAK,EAAE;YACH,uBAAuB,EAAE,OAAO;SACnC;KACJ,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates an ESLint config for `package.json` files.
|
|
3
|
+
*
|
|
4
|
+
* Files are parsed with `jsonc-eslint-parser`, the parser `eslint-plugin-package-json` rules
|
|
5
|
+
* require too, so further `package.json` checks can share this config block.
|
|
6
|
+
*/
|
|
7
|
+
export declare function packageJson(): import("eslint/config").ConfigObject[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as jsoncParser from 'jsonc-eslint-parser';
|
|
2
|
+
import { defineConfig } from 'eslint/config';
|
|
3
|
+
import { nzymePlugin } from './plugin.js';
|
|
4
|
+
/**
|
|
5
|
+
* Creates an ESLint config for `package.json` files.
|
|
6
|
+
*
|
|
7
|
+
* Files are parsed with `jsonc-eslint-parser`, the parser `eslint-plugin-package-json` rules
|
|
8
|
+
* require too, so further `package.json` checks can share this config block.
|
|
9
|
+
*/
|
|
10
|
+
export function packageJson() {
|
|
11
|
+
return defineConfig({
|
|
12
|
+
files: ['**/package.json'],
|
|
13
|
+
plugins: { nzyme: nzymePlugin },
|
|
14
|
+
languageOptions: {
|
|
15
|
+
parser: jsoncParser,
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
'nzyme/exports-source-first': 'error',
|
|
19
|
+
'nzyme/files-cover-exports': 'error',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=packageJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageJson.js","sourceRoot":"","sources":["../src/packageJson.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,UAAU,WAAW;IACvB,OAAO,YAAY,CAAC;QAChB,KAAK,EAAE,CAAC,iBAAiB,CAAC;QAC1B,OAAO,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE;QAC/B,eAAe,EAAE;YACb,MAAM,EAAE,WAAW;SACtB;QACD,KAAK,EAAE;YACH,4BAA4B,EAAE,OAAO;YACrC,2BAA2B,EAAE,OAAO;SACvC;KACJ,CAAC,CAAC;AACP,CAAC"}
|
package/dist/plugin.d.ts
ADDED
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { exportsSourceFirst } from './rules/exportsSourceFirst.js';
|
|
2
|
+
import { filesCoverExports } from './rules/filesCoverExports.js';
|
|
3
|
+
import { markdownFormat } from './rules/markdownFormat.js';
|
|
4
|
+
import { publishAccessPublic } from './rules/publishAccessPublic.js';
|
|
5
|
+
/**
|
|
6
|
+
* The `nzyme` ESLint plugin with every custom rule. Presets share this one object: flat config
|
|
7
|
+
* refuses two different plugin objects registered under the same name.
|
|
8
|
+
*/
|
|
9
|
+
export const nzymePlugin = {
|
|
10
|
+
meta: { name: '@nzyme/eslint' },
|
|
11
|
+
rules: {
|
|
12
|
+
'exports-source-first': exportsSourceFirst,
|
|
13
|
+
'files-cover-exports': filesCoverExports,
|
|
14
|
+
'markdown-format': markdownFormat,
|
|
15
|
+
'publish-access-public': publishAccessPublic,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAkB;IACtC,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;IAC/B,KAAK,EAAE;QACH,sBAAsB,EAAE,kBAAkB;QAC1C,qBAAqB,EAAE,iBAAiB;QACxC,iBAAiB,EAAE,cAAc;QACjC,uBAAuB,EAAE,mBAAmB;KAC/C;CACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* ESLint rule for `package.json`: every conditions object inside `exports` that points a runtime
|
|
4
|
+
* condition into `dist` must have a `source` condition, placed directly after `types` (or first when
|
|
5
|
+
* there is no `types`).
|
|
6
|
+
*
|
|
7
|
+
* Node and Bun match conditions in key order, so `bun --conditions=source` (used to run code
|
|
8
|
+
* generators from source, without building anything first) only reaches `source` when no other
|
|
9
|
+
* runtime condition comes before it. Reordering an existing `source` is autofixed; a missing one is
|
|
10
|
+
* only reported, because its `src` path cannot be guessed safely.
|
|
11
|
+
*/
|
|
12
|
+
export declare const exportsSourceFirst: Rule.RuleModule;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { assert } from '@nzyme/utils';
|
|
2
|
+
import { propertyName } from './jsonPackage.js';
|
|
3
|
+
const DECISION = 'docs/decisions/workspace-code-generators-run-from-source.md in the healed repository';
|
|
4
|
+
/**
|
|
5
|
+
* ESLint rule for `package.json`: every conditions object inside `exports` that points a runtime
|
|
6
|
+
* condition into `dist` must have a `source` condition, placed directly after `types` (or first when
|
|
7
|
+
* there is no `types`).
|
|
8
|
+
*
|
|
9
|
+
* Node and Bun match conditions in key order, so `bun --conditions=source` (used to run code
|
|
10
|
+
* generators from source, without building anything first) only reaches `source` when no other
|
|
11
|
+
* runtime condition comes before it. Reordering an existing `source` is autofixed; a missing one is
|
|
12
|
+
* only reported, because its `src` path cannot be guessed safely.
|
|
13
|
+
*/
|
|
14
|
+
export const exportsSourceFirst = {
|
|
15
|
+
meta: {
|
|
16
|
+
type: 'problem',
|
|
17
|
+
fixable: 'code',
|
|
18
|
+
schema: [],
|
|
19
|
+
messages: {
|
|
20
|
+
missing: `This "exports" conditions object points into dist but has no "source" condition, so \`bun --conditions=source\` (used to run code generators from source) falls through to dist. Add "source" pointing at the matching file under src, directly after "types". See ${DECISION}.`,
|
|
21
|
+
misplaced: `"source" must come directly after "types" (or first without "types") and before every runtime condition: \`bun --conditions=source\` (used to run code generators from source) matches conditions in key order and never reaches "source" when "import" or "default" comes first. See ${DECISION}.`,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
create(context) {
|
|
25
|
+
const sourceCode = context.sourceCode;
|
|
26
|
+
function check(object) {
|
|
27
|
+
const properties = object.properties;
|
|
28
|
+
const isSubpaths = properties.some(property => propertyName(property).startsWith('.'));
|
|
29
|
+
if (!isSubpaths && pointsIntoDist(properties)) {
|
|
30
|
+
const sourceIndex = properties.findIndex(property => propertyName(property) === 'source');
|
|
31
|
+
if (sourceIndex === -1) {
|
|
32
|
+
context.report({ loc: object.loc, messageId: 'missing' });
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const first = properties[0];
|
|
36
|
+
assert(first);
|
|
37
|
+
const desiredIndex = propertyName(first) === 'types' ? 1 : 0;
|
|
38
|
+
if (sourceIndex !== desiredIndex) {
|
|
39
|
+
reportMisplaced(properties, sourceIndex, desiredIndex);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
for (const property of properties) {
|
|
44
|
+
if (property.value.type === 'JSONObjectExpression') {
|
|
45
|
+
check(property.value);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function reportMisplaced(properties, sourceIndex, desiredIndex) {
|
|
50
|
+
const property = properties[sourceIndex];
|
|
51
|
+
assert(property);
|
|
52
|
+
context.report({
|
|
53
|
+
loc: property.loc,
|
|
54
|
+
messageId: 'misplaced',
|
|
55
|
+
fix(fixer) {
|
|
56
|
+
const from = Math.min(sourceIndex, desiredIndex);
|
|
57
|
+
const to = Math.max(sourceIndex, desiredIndex);
|
|
58
|
+
const affected = properties.slice(from, to + 1);
|
|
59
|
+
const head = affected[0];
|
|
60
|
+
const tail = affected.at(-1);
|
|
61
|
+
assert(head);
|
|
62
|
+
assert(tail);
|
|
63
|
+
const reordered = [...affected];
|
|
64
|
+
reordered.splice(sourceIndex - from, 1);
|
|
65
|
+
reordered.splice(desiredIndex - from, 0, property);
|
|
66
|
+
// Keep each separator (comma, whitespace, comments) in its original slot.
|
|
67
|
+
let text = '';
|
|
68
|
+
reordered.forEach((moved, i) => {
|
|
69
|
+
text += sourceCode.text.slice(...moved.range);
|
|
70
|
+
const current = affected[i];
|
|
71
|
+
assert(current);
|
|
72
|
+
const next = affected[i + 1];
|
|
73
|
+
if (next) {
|
|
74
|
+
text += sourceCode.text.slice(current.range[1], next.range[0]);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return fixer.replaceTextRange([head.range[0], tail.range[1]], text);
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
JSONProperty(visited) {
|
|
83
|
+
// The visited node is a jsonc-eslint-parser node, which ESLint's ESTree types do not know.
|
|
84
|
+
const node = visited;
|
|
85
|
+
if (!isJsonProperty(node)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const parent = node.parent;
|
|
89
|
+
const isRoot = parent.type === 'JSONObjectExpression' && parent.parent.type === 'JSONExpressionStatement';
|
|
90
|
+
if (isRoot && propertyName(node) === 'exports' && node.value.type === 'JSONObjectExpression') {
|
|
91
|
+
check(node.value);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
function isJsonProperty(node) {
|
|
98
|
+
return typeof node === 'object' && node !== null && 'type' in node && node.type === 'JSONProperty';
|
|
99
|
+
}
|
|
100
|
+
/** Whether any runtime condition (everything but `types`) targets a file in `dist`. */
|
|
101
|
+
function pointsIntoDist(properties) {
|
|
102
|
+
return properties.some(property => {
|
|
103
|
+
const value = property.value;
|
|
104
|
+
return (propertyName(property) !== 'types' &&
|
|
105
|
+
value.type === 'JSONLiteral' &&
|
|
106
|
+
typeof value.value === 'string' &&
|
|
107
|
+
/^\.\/dist(\/|$)/.test(value.value));
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=exportsSourceFirst.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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C,IAAI,KAAK,sBAAsB,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,yBAAyB,CAAC;gBAC/F,IAAI,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;oBAC3F,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACtB,CAAC;YACL,CAAC;SACJ,CAAC;IACN,CAAC;CACJ,CAAC;AAEF,SAAS,cAAc,CAAC,IAAa;IACjC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC;AACvG,CAAC;AAED,uFAAuF;AACvF,SAAS,cAAc,CAAC,UAA8B;IAClD,OAAO,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC7B,OAAO,CACH,YAAY,CAAC,QAAQ,CAAC,KAAK,OAAO;YAClC,KAAK,CAAC,IAAI,KAAK,aAAa;YAC5B,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;YAC/B,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CACtC,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { RuleTester } from 'eslint';
|
|
2
|
+
import * as jsoncParser from 'jsonc-eslint-parser';
|
|
3
|
+
import { describe, it } from 'bun:test';
|
|
4
|
+
import { exportsSourceFirst } from './exportsSourceFirst.js';
|
|
5
|
+
RuleTester.describe = describe;
|
|
6
|
+
RuleTester.it = it;
|
|
7
|
+
const tester = new RuleTester({
|
|
8
|
+
languageOptions: { parser: jsoncParser },
|
|
9
|
+
});
|
|
10
|
+
function pkg(exports) {
|
|
11
|
+
return `{\n "name": "x",\n "exports": ${exports}\n}\n`;
|
|
12
|
+
}
|
|
13
|
+
tester.run('exports-source-first', exportsSourceFirst, {
|
|
14
|
+
valid: [
|
|
15
|
+
{
|
|
16
|
+
name: 'source after types',
|
|
17
|
+
code: pkg(`{ ".": { "types": "./dist/index.d.ts", "source": "./src/index.ts", "import": "./dist/index.js" } }`),
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'source first without types',
|
|
21
|
+
code: pkg(`{ ".": { "source": "./src/index.ts", "default": "./dist/index.js" } }`),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'source first even when types comes later',
|
|
25
|
+
code: pkg(`{ ".": { "source": "./src/index.ts", "import": "./dist/index.js", "types": "./dist/index.d.ts" } }`),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'every condition already points at src',
|
|
29
|
+
code: pkg(`{ ".": { "types": "./src/index.ts", "default": "./src/index.ts" } }`),
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'nested conditions are checked at their own level',
|
|
33
|
+
code: pkg(`{ ".": { "node": { "types": "./dist/a.d.ts", "source": "./src/a.ts", "default": "./dist/a.js" }, "default": { "source": "./src/b.ts", "default": "./dist/b.js" } } }`),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'string exports are not conditions',
|
|
37
|
+
code: pkg(`"./dist/index.js"`),
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'only types points into dist',
|
|
41
|
+
code: pkg(`{ ".": { "types": "./dist/index.d.ts", "default": "./src/index.ts" } }`),
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'objects outside exports are ignored',
|
|
45
|
+
code: `{ "publishConfig": { "import": "./dist/index.js" } }`,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
invalid: [
|
|
49
|
+
{
|
|
50
|
+
name: 'source after import is moved up',
|
|
51
|
+
code: pkg(`{\n ".": {\n "types": "./dist/index.d.ts",\n "import": "./dist/index.js",\n "source": "./src/index.ts",\n "default": "./dist/index.js"\n }\n }`),
|
|
52
|
+
output: pkg(`{\n ".": {\n "types": "./dist/index.d.ts",\n "source": "./src/index.ts",\n "import": "./dist/index.js",\n "default": "./dist/index.js"\n }\n }`),
|
|
53
|
+
errors: [{ messageId: 'misplaced' }],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'source last without types is moved to the front',
|
|
57
|
+
code: pkg(`{ ".": { "default": "./dist/index.js", "source": "./src/index.ts" } }`),
|
|
58
|
+
output: pkg(`{ ".": { "source": "./src/index.ts", "default": "./dist/index.js" } }`),
|
|
59
|
+
errors: [{ messageId: 'misplaced' }],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'types after the runtime conditions pulls source to the front',
|
|
63
|
+
code: pkg(`{ ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts", "source": "./src/index.ts" } }`),
|
|
64
|
+
output: pkg(`{ ".": { "source": "./src/index.ts", "import": "./dist/index.js", "types": "./dist/index.d.ts" } }`),
|
|
65
|
+
errors: [{ messageId: 'misplaced' }],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'missing source is reported without a fix',
|
|
69
|
+
code: pkg(`{ ".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" } }`),
|
|
70
|
+
output: null,
|
|
71
|
+
errors: [{ messageId: 'missing' }],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'missing source in a nested conditions object',
|
|
75
|
+
code: pkg(`{ ".": { "node": { "types": "./dist/a.d.ts", "default": "./dist/a.js" } } }`),
|
|
76
|
+
output: null,
|
|
77
|
+
errors: [{ messageId: 'missing' }],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'a source wildcard subpath is checked too',
|
|
81
|
+
code: pkg(`{ "./*.js": { "import": "./dist/*.js", "source": "./src/*.ts" } }`),
|
|
82
|
+
output: pkg(`{ "./*.js": { "source": "./src/*.ts", "import": "./dist/*.js" } }`),
|
|
83
|
+
errors: [{ messageId: 'misplaced' }],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=exportsSourceFirst.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exportsSourceFirst.test.js","sourceRoot":"","sources":["../../src/rules/exportsSourceFirst.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC/B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;AAEnB,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC;IAC1B,eAAe,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;CAC3C,CAAC,CAAC;AAEH,SAAS,GAAG,CAAC,OAAe;IACxB,OAAO,uCAAuC,OAAO,OAAO,CAAC;AACjE,CAAC;AAED,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,kBAAkB,EAAE;IACnD,KAAK,EAAE;QACH;YACI,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,GAAG,CACL,oGAAoG,CACvG;SACJ;QACD;YACI,IAAI,EAAE,4BAA4B;YAClC,IAAI,EAAE,GAAG,CAAC,uEAAuE,CAAC;SACrF;QACD;YACI,IAAI,EAAE,0CAA0C;YAChD,IAAI,EAAE,GAAG,CACL,oGAAoG,CACvG;SACJ;QACD;YACI,IAAI,EAAE,uCAAuC;YAC7C,IAAI,EAAE,GAAG,CAAC,qEAAqE,CAAC;SACnF;QACD;YACI,IAAI,EAAE,kDAAkD;YACxD,I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mE,CAAC;YAC9E,MAAM,EAAE,GAAG,CAAC,mEAAmE,CAAC;YAChF,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;SACvC;KACJ;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* ESLint rule for `package.json`: in a published package that declares `files`, every `exports`,
|
|
4
|
+
* `main` and `types` target must be covered by `files`, otherwise the tarball ships without the
|
|
5
|
+
* entry point it advertises.
|
|
6
|
+
*
|
|
7
|
+
* Targets of the `source` condition are exempt (they point at `src`, which is deliberately not
|
|
8
|
+
* published), and so are private packages and packages without `files` (npm then ships everything).
|
|
9
|
+
*/
|
|
10
|
+
export declare const filesCoverExports: Rule.RuleModule;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { propertyName, publishedPackageRoot } from './jsonPackage.js';
|
|
2
|
+
/**
|
|
3
|
+
* ESLint rule for `package.json`: in a published package that declares `files`, every `exports`,
|
|
4
|
+
* `main` and `types` target must be covered by `files`, otherwise the tarball ships without the
|
|
5
|
+
* entry point it advertises.
|
|
6
|
+
*
|
|
7
|
+
* Targets of the `source` condition are exempt (they point at `src`, which is deliberately not
|
|
8
|
+
* published), and so are private packages and packages without `files` (npm then ships everything).
|
|
9
|
+
*/
|
|
10
|
+
export const filesCoverExports = {
|
|
11
|
+
meta: {
|
|
12
|
+
type: 'problem',
|
|
13
|
+
schema: [],
|
|
14
|
+
messages: {
|
|
15
|
+
notShipped: '"{{target}}" is not covered by "files", so it is missing from the published package. Add the directory or file that contains it (for example "{{suggestion}}") to "files".',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
return {
|
|
20
|
+
'Program:exit'() {
|
|
21
|
+
const root = publishedPackageRoot(context);
|
|
22
|
+
if (!root) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const filesProperty = root.properties.find(property => propertyName(property) === 'files');
|
|
26
|
+
if (!filesProperty || filesProperty.value.type !== 'JSONArrayExpression') {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const patterns = filesProperty.value.elements.flatMap(element => element?.type === 'JSONLiteral' && typeof element.value === 'string' ? [element.value] : []);
|
|
30
|
+
const matchers = patterns.filter(pattern => !pattern.startsWith('!')).map(toMatcher);
|
|
31
|
+
for (const property of root.properties) {
|
|
32
|
+
const name = propertyName(property);
|
|
33
|
+
if (name === 'exports') {
|
|
34
|
+
collectTargets(property.value, targets => check(targets, matchers));
|
|
35
|
+
}
|
|
36
|
+
else if (name === 'main' || name === 'types') {
|
|
37
|
+
check([property.value], matchers);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
function check(nodes, matchers) {
|
|
43
|
+
for (const node of nodes) {
|
|
44
|
+
if (node.type !== 'JSONLiteral' || typeof node.value !== 'string') {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const path = normalize(node.value);
|
|
48
|
+
if (path === 'package.json' || matchers.some(matches => matches(path))) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const top = path.split('/')[0] ?? path;
|
|
52
|
+
context.report({
|
|
53
|
+
loc: node.loc,
|
|
54
|
+
messageId: 'notShipped',
|
|
55
|
+
data: { target: node.value, suggestion: path.includes('/') ? top : path },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
/** Calls `visit` with every string-valued target in an `exports` value, skipping `source` conditions. */
|
|
62
|
+
function collectTargets(value, visit) {
|
|
63
|
+
if (value.type === 'JSONObjectExpression') {
|
|
64
|
+
for (const property of value.properties) {
|
|
65
|
+
const name = propertyName(property);
|
|
66
|
+
if (name !== 'source' || name.startsWith('.')) {
|
|
67
|
+
collectTargets(property.value, visit);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else if (value.type === 'JSONArrayExpression') {
|
|
72
|
+
for (const element of value.elements) {
|
|
73
|
+
if (element) {
|
|
74
|
+
collectTargets(element, visit);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
visit([value]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function normalize(path) {
|
|
83
|
+
return path.replace(/^\.\//, '').replace(/\/+$/, '');
|
|
84
|
+
}
|
|
85
|
+
/** A `files` entry covers a path when it equals it, is a directory containing it, or is a glob matching it. */
|
|
86
|
+
function toMatcher(pattern) {
|
|
87
|
+
const entry = normalize(pattern);
|
|
88
|
+
if (!entry.includes('*')) {
|
|
89
|
+
return path => path === entry || path.startsWith(`${entry}/`);
|
|
90
|
+
}
|
|
91
|
+
// `**/` matches zero or more directories, a remaining `**` anything, `*` one path segment.
|
|
92
|
+
const source = entry
|
|
93
|
+
.split('**/')
|
|
94
|
+
.map(segment => segment
|
|
95
|
+
.split('**')
|
|
96
|
+
.map(part => part.split('*').map(escapeRegExp).join('[^/]*'))
|
|
97
|
+
.join('.*'))
|
|
98
|
+
.join('(?:.*/)?');
|
|
99
|
+
const regExp = new RegExp(`^${source}(/.*)?$`);
|
|
100
|
+
return path => regExp.test(path);
|
|
101
|
+
}
|
|
102
|
+
function escapeRegExp(text) {
|
|
103
|
+
return text.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=filesCoverExports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesCoverExports.js","sourceRoot":"","sources":["../../src/rules/filesCoverExports.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEtE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAoB;IAC9C,IAAI,EAAE;QACF,IAAI,EAAE,SAAS;QACf,MAAM,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C,CAAC;SAC5D,IAAI,CAAC,IAAI,CAAC,CAClB;SACA,IAAI,CAAC,UAAU,CAAC,CAAC;IACtB,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,MAAM,SAAS,CAAC,CAAC;IAC/C,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { RuleTester } from 'eslint';
|
|
2
|
+
import * as jsoncParser from 'jsonc-eslint-parser';
|
|
3
|
+
import { describe, it } from 'bun:test';
|
|
4
|
+
import { filesCoverExports } from './filesCoverExports.js';
|
|
5
|
+
RuleTester.describe = describe;
|
|
6
|
+
RuleTester.it = it;
|
|
7
|
+
const tester = new RuleTester({
|
|
8
|
+
languageOptions: { parser: jsoncParser },
|
|
9
|
+
});
|
|
10
|
+
tester.run('files-cover-exports', filesCoverExports, {
|
|
11
|
+
valid: [
|
|
12
|
+
{
|
|
13
|
+
name: 'dist covers the exports, main and types targets',
|
|
14
|
+
code: `{ "files": ["dist"], "main": "./dist/index.js", "types": "./dist/index.d.ts", "exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } } }`,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: 'source condition targets may live outside files',
|
|
18
|
+
code: `{ "files": ["dist"], "exports": { ".": { "types": "./dist/index.d.ts", "source": "./src/index.ts", "import": "./dist/index.js" } } }`,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'wildcard targets are covered by their directory',
|
|
22
|
+
code: `{ "files": ["dist"], "exports": { "./*.js": { "source": "./src/*.ts", "import": "./dist/*.js" } } }`,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'packages that ship src list it',
|
|
26
|
+
code: `{ "files": ["src"], "exports": { ".": "./src/index.ts" } }`,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'a files entry may be a single file or a glob',
|
|
30
|
+
code: `{ "files": ["dist/index.js", "types/*.d.ts"], "main": "./dist/index.js", "types": "./types/index.d.ts" }`,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'a `**/` glob matches zero directories',
|
|
34
|
+
code: `{ "files": ["dist/**/*.js"], "main": "./dist/index.js" }`,
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'package.json is always shipped',
|
|
38
|
+
code: `{ "files": ["dist"], "exports": { "./package.json": "./package.json" } }`,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'no files means npm ships everything',
|
|
42
|
+
code: `{ "main": "./dist/index.js" }`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'private packages are never flagged',
|
|
46
|
+
code: `{ "private": true, "files": ["dist"], "main": "./lib/index.js" }`,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
invalid: [
|
|
50
|
+
{
|
|
51
|
+
name: 'exports target outside files',
|
|
52
|
+
code: `{ "files": ["dist"], "exports": { ".": { "import": "./lib/index.js" } } }`,
|
|
53
|
+
errors: [{ messageId: 'notShipped', data: { target: './lib/index.js', suggestion: 'lib' } }],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'main outside files',
|
|
57
|
+
code: `{ "files": ["dist"], "main": "./src/index.js" }`,
|
|
58
|
+
errors: [{ messageId: 'notShipped' }],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'types outside files',
|
|
62
|
+
code: `{ "files": ["dist"], "types": "./types/index.d.ts" }`,
|
|
63
|
+
errors: [{ messageId: 'notShipped' }],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'only the uncovered targets are reported',
|
|
67
|
+
code: `{ "files": ["dist"], "exports": { ".": { "types": "./types/a.d.ts", "import": "./dist/a.js", "default": "./cjs/a.js" } } }`,
|
|
68
|
+
errors: [{ messageId: 'notShipped' }, { messageId: 'notShipped' }],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: 'a negated files entry does not cover anything',
|
|
72
|
+
code: `{ "files": ["!dist"], "main": "./dist/index.js" }`,
|
|
73
|
+
errors: [{ messageId: 'notShipped' }],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: 'a nested source condition is exempt but its siblings are not',
|
|
77
|
+
code: `{ "files": ["dist"], "exports": { ".": { "node": { "source": "./src/a.ts", "default": "./lib/a.js" } } } }`,
|
|
78
|
+
errors: [{ messageId: 'notShipped' }],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'a source subpath key is not mistaken for the condition',
|
|
82
|
+
code: `{ "files": ["dist"], "exports": { "./source": "./lib/source.js" } }`,
|
|
83
|
+
errors: [{ messageId: 'notShipped' }],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=filesCoverExports.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesCoverExports.test.js","sourceRoot":"","sources":["../../src/rules/filesCoverExports.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC/B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;AAEnB,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC;IAC1B,eAAe,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;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EAAE,YAAY,EAAE,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;SACrE;QACD;YACI,IAAI,EAAE,+CAA+C;YACrD,IAAI,EAAE,mDAAmD;YACzD,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;SACxC;QACD;YACI,IAAI,EAAE,8DAA8D;YACpE,IAAI,EAAE,4GAA4G;YAClH,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;SACxC;QACD;YACI,IAAI,EAAE,wDAAwD;YAC9D,IAAI,EAAE,qEAAqE;YAC3E,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;SACxC;KACJ;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats Markdown for minimal tokens: reserialises it through remark with compact GFM tables,
|
|
3
|
+
* single-space list indentation and prose-preserving handlers, then drops escapes that do not change
|
|
4
|
+
* how the document parses. Returns the input unchanged when it is already formatted.
|
|
5
|
+
* @__NO_SIDE_EFFECTS__
|
|
6
|
+
*/
|
|
7
|
+
export declare function formatMarkdown(source: string): string;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { defaultHandlers } from 'mdast-util-to-markdown';
|
|
2
|
+
import { remark } from 'remark';
|
|
3
|
+
import remarkFrontmatter from 'remark-frontmatter';
|
|
4
|
+
import remarkGfm from 'remark-gfm';
|
|
5
|
+
/** Parse-only pipeline used to check whether dropping an escape changes document structure. */
|
|
6
|
+
const structureChecker = remark().use(remarkFrontmatter, ['yaml']).use(remarkGfm, { singleTilde: false });
|
|
7
|
+
/**
|
|
8
|
+
* Removes backslashes that do not affect how the complete document parses. Checking the whole
|
|
9
|
+
* document keeps surrounding delimiters in view and covers escapes emitted outside text nodes,
|
|
10
|
+
* such as image destinations and line-start punctuation.
|
|
11
|
+
* @__NO_SIDE_EFFECTS__
|
|
12
|
+
*/
|
|
13
|
+
function removeInertEscapes(markdown) {
|
|
14
|
+
const expectedStructure = markdownStructure(markdown);
|
|
15
|
+
let result = markdown;
|
|
16
|
+
const escapedCharacters = new Set();
|
|
17
|
+
for (const match of markdown.matchAll(/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g)) {
|
|
18
|
+
escapedCharacters.add(match[0]);
|
|
19
|
+
}
|
|
20
|
+
for (const escaped of escapedCharacters) {
|
|
21
|
+
const candidate = result.split(escaped).join(escaped.slice(1));
|
|
22
|
+
if (candidate !== result && markdownStructure(candidate) === expectedStructure) {
|
|
23
|
+
result = candidate;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const escapePositions = [];
|
|
27
|
+
for (const match of result.matchAll(/\\[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]/g)) {
|
|
28
|
+
if (match.index != null) {
|
|
29
|
+
escapePositions.push(match.index);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return removeEscapeGroup(result, escapePositions);
|
|
33
|
+
function removeEscapeGroup(current, positions) {
|
|
34
|
+
if (positions.length === 0) {
|
|
35
|
+
return current;
|
|
36
|
+
}
|
|
37
|
+
let candidate = '';
|
|
38
|
+
let copiedThrough = 0;
|
|
39
|
+
for (const position of positions) {
|
|
40
|
+
candidate += current.slice(copiedThrough, position);
|
|
41
|
+
copiedThrough = position + 1;
|
|
42
|
+
}
|
|
43
|
+
candidate += current.slice(copiedThrough);
|
|
44
|
+
if (markdownStructure(candidate) === expectedStructure) {
|
|
45
|
+
return candidate;
|
|
46
|
+
}
|
|
47
|
+
if (positions.length === 1) {
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
const midpoint = Math.ceil(positions.length / 2);
|
|
51
|
+
const afterRight = removeEscapeGroup(current, positions.slice(midpoint));
|
|
52
|
+
return removeEscapeGroup(afterRight, positions.slice(0, midpoint));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Serializes an mdast tree without source positions so equivalent parses compare identically.
|
|
57
|
+
* @__NO_SIDE_EFFECTS__
|
|
58
|
+
*/
|
|
59
|
+
function markdownStructure(markdown) {
|
|
60
|
+
return JSON.stringify(structureChecker.parse(markdown), (key, value) => key === 'position' ? undefined : value);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether the bare text alone parses back into exactly the same link, i.e. it is a literal
|
|
64
|
+
* autolink that gfm-autolink-literal re-links on its own. Asking the parser instead of matching
|
|
65
|
+
* known schemes is what keeps ordinary links whose text equals their destination — relative paths
|
|
66
|
+
* like `[README.md](README.md)` or `[#anchor](#anchor)` — from being unwrapped into plain text,
|
|
67
|
+
* which would destroy them.
|
|
68
|
+
* @__NO_SIDE_EFFECTS__
|
|
69
|
+
*/
|
|
70
|
+
function isLiteralAutolink(text, url) {
|
|
71
|
+
const root = structureChecker.parse(text);
|
|
72
|
+
const [paragraph, ...blocks] = root.children;
|
|
73
|
+
if (blocks.length > 0 || paragraph?.type !== 'paragraph') {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const [link, ...siblings] = paragraph.children;
|
|
77
|
+
if (siblings.length > 0 || link?.type !== 'link' || link.url !== url || link.title) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
const [child, ...rest] = link.children;
|
|
81
|
+
return rest.length === 0 && child?.type === 'text' && child.value === text;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Link handler that emits a bare literal autolink instead of wrapping it. gfm-autolink-literal
|
|
85
|
+
* parses bare URLs/emails into link nodes, and the default stringifier then emits noise:
|
|
86
|
+
* `http://localhost:6006` → `<http://localhost:6006>`, `a@b.com` → `<a@b.com>`, and
|
|
87
|
+
* `www.foo.com` → `[www.foo.com](http://www.foo.com)`. When a link is exactly such an autolink —
|
|
88
|
+
* a single text child, no title, and text the parser turns back into this very link — return the
|
|
89
|
+
* raw text so it stays bare. This renders identically (gfm re-links it) and is idempotent.
|
|
90
|
+
* Everything else defers to the default handler.
|
|
91
|
+
*/
|
|
92
|
+
function unwrapAutolink(node, parent, state, info) {
|
|
93
|
+
const [child, ...rest] = node.children;
|
|
94
|
+
if (!node.title && rest.length === 0 && child?.type === 'text') {
|
|
95
|
+
if (isLiteralAutolink(child.value, node.url)) {
|
|
96
|
+
return child.value;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return defaultHandlers.link(node, parent, state, info);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Hard-break handler: emit the invisible two-space form instead of the default visible `\`.
|
|
103
|
+
* Delegates to the default handler first so unsafe scopes (table cells, headings — where a raw
|
|
104
|
+
* newline is illegal) still collapse to a space. Only the real backslash break is rewritten, and
|
|
105
|
+
* it is `info.before`-aware: if the preceding text already ends in spaces, emit only enough to
|
|
106
|
+
* total two, so `word \` (one stray source space) canonicalises to exactly `word␣␣` in a single
|
|
107
|
+
* pass rather than `word␣␣␣` (idempotency would otherwise need two passes).
|
|
108
|
+
*/
|
|
109
|
+
function twoSpaceBreak(node, parent, state, info) {
|
|
110
|
+
const rendered = defaultHandlers.break(node, parent, state, info);
|
|
111
|
+
if (rendered !== '\\\n') {
|
|
112
|
+
return rendered;
|
|
113
|
+
}
|
|
114
|
+
const trailingSpaces = (/ *$/.exec(info.before) ?? [''])[0].length;
|
|
115
|
+
return ' '.repeat(Math.max(0, 2 - trailingSpaces)) + '\n';
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* remark-stringify settings tuned to minimise tokens: compact (unaligned) GFM tables,
|
|
119
|
+
* single-space list indentation, `-` bullets/rules, and prose-preserving handlers (no escaping
|
|
120
|
+
* noise, bare URLs, invisible hard breaks). No prose re-wrapping — remark preserves author line
|
|
121
|
+
* breaks by default.
|
|
122
|
+
*/
|
|
123
|
+
const STRINGIFY_SETTINGS = {
|
|
124
|
+
bullet: '-',
|
|
125
|
+
listItemIndent: 'one',
|
|
126
|
+
rule: '-',
|
|
127
|
+
fences: true,
|
|
128
|
+
tightDefinitions: true,
|
|
129
|
+
handlers: { link: unwrapAutolink, break: twoSpaceBreak },
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* A remark pipeline that round-trips YAML frontmatter verbatim and renders GFM tables
|
|
133
|
+
* without alignment padding — the padding oxfmt adds is the dominant token cost.
|
|
134
|
+
*/
|
|
135
|
+
const processor = remark()
|
|
136
|
+
.use(remarkFrontmatter, ['yaml'])
|
|
137
|
+
.use(remarkGfm, { tablePipeAlign: false, tableCellPadding: false, singleTilde: false })
|
|
138
|
+
.data('settings', STRINGIFY_SETTINGS);
|
|
139
|
+
/**
|
|
140
|
+
* Formats Markdown for minimal tokens: reserialises it through remark with compact GFM tables,
|
|
141
|
+
* single-space list indentation and prose-preserving handlers, then drops escapes that do not change
|
|
142
|
+
* how the document parses. Returns the input unchanged when it is already formatted.
|
|
143
|
+
* @__NO_SIDE_EFFECTS__
|
|
144
|
+
*/
|
|
145
|
+
export function formatMarkdown(source) {
|
|
146
|
+
const safelyFormatted = String(processor.processSync(source));
|
|
147
|
+
return safelyFormatted === source ? source : removeInertEscapes(safelyFormatted);
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=formatMarkdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatMarkdown.js","sourceRoot":"","sources":["../../src/rules/formatMarkdown.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,+FAA+F;AAC/F,MAAM,gBAAgB,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,CAAC;AAE1G;;;;;GAKG;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|
|
|
1
|
+
import { expect, test } from 'bun:test';
|
|
2
|
+
import { formatMarkdown } from './formatMarkdown.js';
|
|
3
|
+
test('formats ambiguous markdown idempotently without unnecessary escapes', () => {
|
|
4
|
+
const source = [
|
|
5
|
+
'- **@/\\* import resolution**: Handles `@/*` imports correctly',
|
|
6
|
+
'',
|
|
7
|
+
'',
|
|
8
|
+
'',
|
|
9
|
+
'**Example Query: **',
|
|
10
|
+
'',
|
|
11
|
+
'curl --request GET \\',
|
|
12
|
+
"--url '{{BASE_URL}}/v3/order/{{order_id}}/result/pdf' \\",
|
|
13
|
+
"--header 'accept: application/json'",
|
|
14
|
+
'',
|
|
15
|
+
'[OLH - API TRT.postman_collection.json](./assets/OLH - API TRT.postman_collection.json)',
|
|
16
|
+
'',
|
|
17
|
+
'- **support@clientdomain.com**** - contact support',
|
|
18
|
+
' or \\*\\*',
|
|
19
|
+
'',
|
|
20
|
+
].join('\n');
|
|
21
|
+
const firstPass = formatMarkdown(source);
|
|
22
|
+
expect(formatMarkdown(firstPass)).toBe(firstPass);
|
|
23
|
+
expect(firstPass).toContain('**@/\\* import resolution**');
|
|
24
|
+
expect(firstPass).not.toContain('\\&');
|
|
25
|
+
expect(firstPass).not.toContain('\\--url');
|
|
26
|
+
expect(firstPass).not.toContain(']\\(');
|
|
27
|
+
expect(firstPass).not.toContain('\\*\\*Example Query');
|
|
28
|
+
});
|
|
29
|
+
test('keeps links whose text equals their destination but only unwraps literal autolinks', () => {
|
|
30
|
+
const source = [
|
|
31
|
+
'See [README.md](README.md), [docs/foo.md](docs/foo.md) and [#anchor](#anchor).',
|
|
32
|
+
'',
|
|
33
|
+
'Autolinks: [http://localhost:6006](http://localhost:6006), [a@b.com](mailto:a@b.com)',
|
|
34
|
+
'and [www.foo.com](http://www.foo.com).',
|
|
35
|
+
'',
|
|
36
|
+
].join('\n');
|
|
37
|
+
const firstPass = formatMarkdown(source);
|
|
38
|
+
expect(formatMarkdown(firstPass)).toBe(firstPass);
|
|
39
|
+
expect(firstPass).toContain('[README.md](README.md)');
|
|
40
|
+
expect(firstPass).toContain('[docs/foo.md](docs/foo.md)');
|
|
41
|
+
expect(firstPass).toContain('[#anchor](#anchor)');
|
|
42
|
+
expect(firstPass).toContain('Autolinks: http://localhost:6006, a@b.com');
|
|
43
|
+
expect(firstPass).toContain('and www.foo.com.');
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=formatMarkdown.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatMarkdown.test.js","sourceRoot":"","sources":["../../src/rules/formatMarkdown.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,IAAI,CAAC,qEAAqE,EAAE,GAAG,EAAE;IAC7E,MAAM,MAAM,GAAG;QACX,gEAAgE;QAChE,EAAE;QACF,qEAAqE;QACrE,EAAE;QACF,qBAAqB;QACrB,EAAE;QACF,uBAAuB;QACvB,0DAA0D;QAC1D,qCAAqC;QACrC,EAAE;QACF,yFAAyF;QACzF,EAAE;QACF,oDAAoD;QACpD,aAAa;QACb,EAAE;KACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAEzC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;IAC3D,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC3C,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;AAC3D,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,oFAAoF,EAAE,GAAG,EAAE;IAC5F,MAAM,MAAM,GAAG;QACX,gFAAgF;QAChF,EAAE;QACF,sFAAsF;QACtF,wCAAwC;QACxC,EAAE;KACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAEzC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;IACtD,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;IAC1D,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAClD,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,2CAA2C,CAAC,CAAC;IACzE,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
import type { AST } from 'jsonc-eslint-parser';
|
|
3
|
+
/** Reads the name of a `jsonc-eslint-parser` property key. */
|
|
4
|
+
export declare function propertyName(property: AST.JSONProperty): string;
|
|
5
|
+
/**
|
|
6
|
+
* Returns the top-level object of a `package.json` AST, or `null` when the package is private (private
|
|
7
|
+
* packages are never published, so publishing rules skip them).
|
|
8
|
+
*/
|
|
9
|
+
export declare function publishedPackageRoot(context: Rule.RuleContext): AST.JSONObjectExpression | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Reads the name of a `jsonc-eslint-parser` property key. */
|
|
2
|
+
export function propertyName(property) {
|
|
3
|
+
const key = property.key;
|
|
4
|
+
return key.type === 'JSONLiteral' ? String(key.value) : key.name;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Returns the top-level object of a `package.json` AST, or `null` when the package is private (private
|
|
8
|
+
* packages are never published, so publishing rules skip them).
|
|
9
|
+
*/
|
|
10
|
+
export function publishedPackageRoot(context) {
|
|
11
|
+
// The AST root is a jsonc-eslint-parser node, which ESLint's ESTree types do not know.
|
|
12
|
+
const body = context.sourceCode.ast.body[0];
|
|
13
|
+
if (!isJsonStatement(body) || body.expression.type !== 'JSONObjectExpression') {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const root = body.expression;
|
|
17
|
+
const isPrivate = root.properties.some(property => propertyName(property) === 'private' &&
|
|
18
|
+
property.value.type === 'JSONLiteral' &&
|
|
19
|
+
property.value.value === true);
|
|
20
|
+
return isPrivate ? null : root;
|
|
21
|
+
}
|
|
22
|
+
function isJsonStatement(node) {
|
|
23
|
+
return typeof node === 'object' && node !== null && 'type' in node && node.type === 'JSONExpressionStatement';
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=jsonPackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonPackage.js","sourceRoot":"","sources":["../../src/rules/jsonPackage.ts"],"names":[],"mappings":"AAGA,8DAA8D;AAC9D,MAAM,UAAU,YAAY,CAAC,QAA0B;IACnD,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;IACzB,OAAO,GAAG,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAyB;IAC1D,uFAAuF;IACvF,MAAM,IAAI,GAAY,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrD,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,KAAK,sBAAsB,EAAE,CAAC;QAC5E,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAClC,QAAQ,CAAC,EAAE,CACP,YAAY,CAAC,QAAQ,CAAC,KAAK,SAAS;QACpC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,aAAa;QACrC,QAAQ,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CACpC,CAAC;IACF,OAAO,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACnC,CAAC;AAED,SAAS,eAAe,CAAC,IAAa;IAClC,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,yBAAyB,CAAC;AAClH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MarkdownRuleDefinition } from '@eslint/markdown';
|
|
2
|
+
/**
|
|
3
|
+
* ESLint rule for Markdown: the file must already be in the token-minimising format produced by
|
|
4
|
+
* {@link formatMarkdown} (compact GFM tables, `-` bullets, no inert escapes, bare autolinks). An
|
|
5
|
+
* unformatted file is reported once, on the document root, and the fix rewrites the whole file.
|
|
6
|
+
*
|
|
7
|
+
* Gitignored files are skipped: ESLint does not read `.gitignore`, and generated Markdown (code
|
|
8
|
+
* indexes, local notes) is not ours to format.
|
|
9
|
+
*/
|
|
10
|
+
export declare const markdownFormat: MarkdownRuleDefinition;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { isFileIgnored } from '@nzyme/project-utils/isFileIgnored.js';
|
|
3
|
+
import { formatMarkdown } from './formatMarkdown.js';
|
|
4
|
+
/**
|
|
5
|
+
* ESLint rule for Markdown: the file must already be in the token-minimising format produced by
|
|
6
|
+
* {@link formatMarkdown} (compact GFM tables, `-` bullets, no inert escapes, bare autolinks). An
|
|
7
|
+
* unformatted file is reported once, on the document root, and the fix rewrites the whole file.
|
|
8
|
+
*
|
|
9
|
+
* Gitignored files are skipped: ESLint does not read `.gitignore`, and generated Markdown (code
|
|
10
|
+
* indexes, local notes) is not ours to format.
|
|
11
|
+
*/
|
|
12
|
+
export const markdownFormat = {
|
|
13
|
+
meta: {
|
|
14
|
+
type: 'layout',
|
|
15
|
+
fixable: 'code',
|
|
16
|
+
schema: [],
|
|
17
|
+
messages: {
|
|
18
|
+
unformatted: 'This Markdown file is not formatted. Run `bun lint` (or `eslint --fix`) to format it.',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
create(context) {
|
|
22
|
+
const filename = context.filename;
|
|
23
|
+
if (path.isAbsolute(filename) && isFileIgnored(filename) === true) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
root(node) {
|
|
28
|
+
const source = context.sourceCode.text;
|
|
29
|
+
const formatted = formatMarkdown(source);
|
|
30
|
+
if (formatted === source) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
context.report({
|
|
34
|
+
node,
|
|
35
|
+
messageId: 'unformatted',
|
|
36
|
+
fix: fixer => fixer.replaceTextRange([0, source.length], formatted),
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=markdownFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownFormat.js","sourceRoot":"","sources":["../../src/rules/markdownFormat.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAA2B;IAClD,IAAI,EAAE;QACF,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACN,WAAW,EAAE,uFAAuF;SACvG;KACJ;IACD,MAAM,CAAC,OAAO;QACV,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;YAChE,OAAO,EAAE,CAAC;QACd,CAAC;QAED,OAAO;YACH,IAAI,CAAC,IAAI;gBACL,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC;gBACvC,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;gBACzC,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;oBACvB,OAAO;gBACX,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACX,IAAI;oBACJ,SAAS,EAAE,aAAa;oBACxB,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;iBACtE,CAAC,CAAC;YACP,CAAC;SACJ,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { Linter, RuleTester } from 'eslint';
|
|
3
|
+
import markdownPlugin from '@eslint/markdown';
|
|
4
|
+
import { describe, expect, it } from 'bun:test';
|
|
5
|
+
import { markdown } from '../markdown.js';
|
|
6
|
+
import { packageJson } from '../packageJson.js';
|
|
7
|
+
import { markdownFormat } from './markdownFormat.js';
|
|
8
|
+
RuleTester.describe = describe;
|
|
9
|
+
RuleTester.it = it;
|
|
10
|
+
const PACKAGE_ROOT = path.resolve(import.meta.dirname, '../..');
|
|
11
|
+
const tester = new RuleTester({
|
|
12
|
+
plugins: { markdown: markdownPlugin },
|
|
13
|
+
language: 'markdown/gfm',
|
|
14
|
+
languageOptions: { frontmatter: 'yaml' },
|
|
15
|
+
});
|
|
16
|
+
tester.run('markdown-format', markdownFormat, {
|
|
17
|
+
valid: [
|
|
18
|
+
{
|
|
19
|
+
name: 'formatted file with YAML frontmatter and a compact table',
|
|
20
|
+
code: '---\ntitle: x\n---\n\n# Title\n\n|a|b|\n|-|-|\n|1|2|\n\n- item\n',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'unformatted but gitignored file is skipped',
|
|
24
|
+
code: '* item\n',
|
|
25
|
+
filename: path.join(PACKAGE_ROOT, 'dist/fixture.md'),
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
invalid: [
|
|
29
|
+
{
|
|
30
|
+
name: 'unformatted file is rewritten whole',
|
|
31
|
+
code: '* one\n* two\n\n| a | b |\n| --- | --- |\n| 1 | 2 |\n',
|
|
32
|
+
filename: path.join(PACKAGE_ROOT, 'src/fixture.md'),
|
|
33
|
+
output: '- one\n- two\n\n|a|b|\n|-|-|\n|1|2|\n',
|
|
34
|
+
errors: [{ messageId: 'unformatted' }],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
it('runs next to the package.json preset and fixes Markdown through the shared plugin', () => {
|
|
39
|
+
const linter = new Linter({ configType: 'flat', cwd: PACKAGE_ROOT });
|
|
40
|
+
const result = linter.verifyAndFix('* item\n', [...packageJson(), ...markdown()], {
|
|
41
|
+
filename: path.join(PACKAGE_ROOT, 'src/fixture.md'),
|
|
42
|
+
});
|
|
43
|
+
expect(result.messages).toEqual([]);
|
|
44
|
+
expect(result.output).toBe('- item\n');
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=markdownFormat.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownFormat.test.js","sourceRoot":"","sources":["../../src/rules/markdownFormat.test.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC/B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;AAEnB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAEhE,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC;IAC1B,OAAO,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE;IACrC,QAAQ,EAAE,cAAc;IACxB,eAAe,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE;CAC3C,CAAC,CAAC;AAEH,MAAM,CAAC,GAAG,CAAC,iBAAiB,EAAE,cAAc,EAAE;IAC1C,KAAK,EAAE;QACH;YACI,IAAI,EAAE,0DAA0D;YAChE,IAAI,EAAE,kEAAkE;SAC3E;QACD;YACI,IAAI,EAAE,4CAA4C;YAClD,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,iBAAiB,CAAC;SACvD;KACJ;IACD,OAAO,EAAE;QACL;YACI,IAAI,EAAE,qCAAqC;YAC3C,IAAI,EAAE,+DAA+D;YACrE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC;YACnD,MAAM,EAAE,uCAAuC;YAC/C,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;SACzC;KACJ;CACJ,CAAC,CAAC;AAEH,EAAE,CAAC,mFAAmF,EAAE,GAAG,EAAE;IACzF,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,GAAG,WAAW,EAAE,EAAE,GAAG,QAAQ,EAAE,CAAC,EAAE;QAC9E,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC;KACtD,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACpC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rule } from 'eslint';
|
|
2
|
+
/**
|
|
3
|
+
* ESLint rule for `package.json`: a published package must set `publishConfig.access` to `"public"`.
|
|
4
|
+
* `eslint-plugin-package-json`'s `require-publishConfig` only checks that `publishConfig` exists, and
|
|
5
|
+
* a scoped package without `access: "public"` is published as restricted (or the publish fails).
|
|
6
|
+
*
|
|
7
|
+
* Private packages are skipped.
|
|
8
|
+
*/
|
|
9
|
+
export declare const publishAccessPublic: Rule.RuleModule;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { propertyName, publishedPackageRoot } from './jsonPackage.js';
|
|
2
|
+
/**
|
|
3
|
+
* ESLint rule for `package.json`: a published package must set `publishConfig.access` to `"public"`.
|
|
4
|
+
* `eslint-plugin-package-json`'s `require-publishConfig` only checks that `publishConfig` exists, and
|
|
5
|
+
* a scoped package without `access: "public"` is published as restricted (or the publish fails).
|
|
6
|
+
*
|
|
7
|
+
* Private packages are skipped.
|
|
8
|
+
*/
|
|
9
|
+
export const publishAccessPublic = {
|
|
10
|
+
meta: {
|
|
11
|
+
type: 'problem',
|
|
12
|
+
schema: [],
|
|
13
|
+
messages: {
|
|
14
|
+
missing: 'A published package must declare `"publishConfig": { "access": "public" }`.',
|
|
15
|
+
notPublic: '`publishConfig.access` must be "public" in a published package.',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
return {
|
|
20
|
+
'Program:exit'() {
|
|
21
|
+
const root = publishedPackageRoot(context);
|
|
22
|
+
if (!root) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const publishConfig = root.properties.find(property => propertyName(property) === 'publishConfig');
|
|
26
|
+
if (!publishConfig || publishConfig.value.type !== 'JSONObjectExpression') {
|
|
27
|
+
// A missing publishConfig is eslint-plugin-package-json's `require-publishConfig` to report.
|
|
28
|
+
if (publishConfig) {
|
|
29
|
+
context.report({ loc: publishConfig.loc, messageId: 'missing' });
|
|
30
|
+
}
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const access = publishConfig.value.properties.find(property => propertyName(property) === 'access');
|
|
34
|
+
if (!access) {
|
|
35
|
+
context.report({ loc: publishConfig.loc, messageId: 'missing' });
|
|
36
|
+
}
|
|
37
|
+
else if (access.value.type !== 'JSONLiteral' || access.value.value !== 'public') {
|
|
38
|
+
context.report({ loc: access.loc, messageId: 'notPublic' });
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=publishAccessPublic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishAccessPublic.js","sourceRoot":"","sources":["../../src/rules/publishAccessPubl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,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;oBAChF,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,CAAC;gBAChE,CAAC;YACL,CAAC;SACJ,CAAC;IACN,CAAC;CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RuleTester } from 'eslint';
|
|
2
|
+
import * as jsoncParser from 'jsonc-eslint-parser';
|
|
3
|
+
import { describe, it } from 'bun:test';
|
|
4
|
+
import { publishAccessPublic } from './publishAccessPublic.js';
|
|
5
|
+
RuleTester.describe = describe;
|
|
6
|
+
RuleTester.it = it;
|
|
7
|
+
const tester = new RuleTester({
|
|
8
|
+
languageOptions: { parser: jsoncParser },
|
|
9
|
+
});
|
|
10
|
+
tester.run('publish-access-public', publishAccessPublic, {
|
|
11
|
+
valid: [
|
|
12
|
+
{ name: 'public access', code: `{ "publishConfig": { "access": "public" } }` },
|
|
13
|
+
{
|
|
14
|
+
name: 'private packages are skipped',
|
|
15
|
+
code: `{ "private": true, "publishConfig": { "access": "restricted" } }`,
|
|
16
|
+
},
|
|
17
|
+
{ name: 'private packages without publishConfig are skipped', code: `{ "private": true }` },
|
|
18
|
+
{ name: 'a missing publishConfig is left to require-publishConfig', code: `{ "name": "x" }` },
|
|
19
|
+
],
|
|
20
|
+
invalid: [
|
|
21
|
+
{
|
|
22
|
+
name: 'restricted access',
|
|
23
|
+
code: `{ "publishConfig": { "access": "restricted" } }`,
|
|
24
|
+
errors: [{ messageId: 'notPublic' }],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'publishConfig without access',
|
|
28
|
+
code: `{ "publishConfig": { "registry": "https://example.com" } }`,
|
|
29
|
+
errors: [{ messageId: 'missing' }],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'private: false is still published',
|
|
33
|
+
code: `{ "private": false, "publishConfig": { "access": "restricted" } }`,
|
|
34
|
+
errors: [{ messageId: 'notPublic' }],
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=publishAccessPublic.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publishAccessPublic.test.js","sourceRoot":"","sources":["../../src/rules/publishAccessPublic.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,KAAK,WAAW,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,UAAU,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC/B,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;AAEnB,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC;IAC1B,eAAe,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE;CAC3C,CAAC,CAAC;AAEH,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,mBAAmB,EAAE;IACrD,KAAK,EAAE;QACH,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,6CAA6C,EAAE;QAC9E;YACI,IAAI,EAAE,8BAA8B;YACpC,IAAI,EAAE,kEAAkE;SAC3E;QACD,EAAE,IAAI,EAAE,oDAAoD,EAAE,IAAI,EAAE,qBAAqB,EAAE;QAC3F,EAAE,IAAI,EAAE,0DAA0D,EAAE,IAAI,EAAE,iBAAiB,EAAE;KAChG;IACD,OAAO,EAAE;QACL;YACI,IAAI,EAAE,mBAAmB;YACzB,IAAI,EAAE,iDAAiD;YACvD,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;SACvC;QACD;YACI,IAAI,EAAE,8BAA8B;YACpC,IAAI,EAAE,4DAA4D;YAClE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;SACrC;QACD;YACI,IAAI,EAAE,mCAAmC;YACzC,IAAI,EAAE,mEAAmE;YACzE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;SACvC;KACJ;CACJ,CAAC,CAAC"}
|
package/oxlintrc.json
CHANGED
|
@@ -283,6 +283,14 @@
|
|
|
283
283
|
// type, with no failure to point at. Ordinary source keeps the rule.
|
|
284
284
|
"files": ["**/*.d.ts"],
|
|
285
285
|
"rules": { "import/no-empty-named-blocks": "off" }
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
// A story that passes `aria-*` to a component can make an axe failure go away without
|
|
289
|
+
// the component ever becoming accessible, and the next consumer ships the same
|
|
290
|
+
// violation. Stories are where that silencing happens, so the rule is scoped to them
|
|
291
|
+
// here, by file kind; the rule itself never looks at the filename.
|
|
292
|
+
"files": ["**/*.stories.tsx"],
|
|
293
|
+
"rules": { "nzyme/no-aria-on-component-in-story": "error" }
|
|
286
294
|
}
|
|
287
295
|
]
|
|
288
296
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nzyme/eslint",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shared Vue
|
|
3
|
+
"version": "0.16.0",
|
|
4
|
+
"description": "Shared ESLint configs (Vue, package.json, Markdown) and oxlint rule preset (framework)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Michał Kędrzyński <m.kedrzynski@gmail.com>",
|
|
7
7
|
"repository": {
|
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"source": "./src/index.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
21
22
|
},
|
|
22
23
|
"./*.js": {
|
|
23
24
|
"types": "./dist/*.d.ts",
|
|
24
|
-
"import": "./dist/*.js",
|
|
25
25
|
"source": "./src/*.ts",
|
|
26
|
+
"import": "./dist/*.js",
|
|
26
27
|
"default": "./dist/*.js"
|
|
27
28
|
}
|
|
28
29
|
},
|
|
@@ -34,16 +35,29 @@
|
|
|
34
35
|
"format": "oxfmt ./src > /dev/null"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
38
|
+
"@eslint/markdown": "^8.0.3",
|
|
39
|
+
"@nzyme/oxlint": "0.16.0",
|
|
40
|
+
"@nzyme/project-utils": "0.16.0",
|
|
41
|
+
"@nzyme/utils": "0.16.0",
|
|
42
|
+
"@typescript-eslint/parser": "^8.71.2",
|
|
43
|
+
"eslint-plugin-vue": "^10.11.1",
|
|
44
|
+
"jsonc-eslint-parser": "^3.3.0",
|
|
45
|
+
"mdast-util-to-markdown": "^2.2.0",
|
|
46
|
+
"remark": "^15.0.1",
|
|
47
|
+
"remark-frontmatter": "^5.0.0",
|
|
48
|
+
"remark-gfm": "^4.0.1",
|
|
49
|
+
"vue-eslint-parser": "^10.4.1"
|
|
42
50
|
},
|
|
43
51
|
"devDependencies": {
|
|
44
|
-
"@nzyme/tsconfig": "0.
|
|
52
|
+
"@nzyme/tsconfig": "0.16.0",
|
|
53
|
+
"@types/bun": "^1.4.4",
|
|
54
|
+
"@types/mdast": "4.0.4",
|
|
45
55
|
"@types/node": "^26.6.5",
|
|
46
56
|
"@typescript/native-preview": "^7.0.0-dev.20260707.2",
|
|
47
|
-
"
|
|
57
|
+
"eslint": "^10.13.0",
|
|
58
|
+
"oxfmt": "0.77.0"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"eslint": "^10.13.0"
|
|
48
62
|
}
|
|
49
63
|
}
|