@mark1russell7/ste-lint 0.1.1 → 0.1.2
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 +26 -5
- package/dist/.tsbuildinfo +1 -1
- package/dist/config-core.d.ts +92 -0
- package/dist/config-core.d.ts.map +1 -0
- package/dist/config-core.js +198 -0
- package/dist/config-core.js.map +1 -0
- package/dist/config.d.ts +2 -76
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -186
- package/dist/config.js.map +1 -1
- package/dist/core.d.ts +16 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +16 -0
- package/dist/core.js.map +1 -0
- package/dist/dictionary-core.d.ts +72 -0
- package/dist/dictionary-core.d.ts.map +1 -0
- package/dist/dictionary-core.js +150 -0
- package/dist/dictionary-core.js.map +1 -0
- package/dist/dictionary.d.ts +4 -69
- package/dist/dictionary.d.ts.map +1 -1
- package/dist/dictionary.js +4 -147
- package/dist/dictionary.js.map +1 -1
- package/dist/engine.d.ts +44 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +122 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/lint.d.ts +6 -16
- package/dist/lint.d.ts.map +1 -1
- package/dist/lint.js +7 -116
- package/dist/lint.js.map +1 -1
- package/dist/source/code.d.ts +9 -0
- package/dist/source/code.d.ts.map +1 -0
- package/dist/source/code.js +16 -0
- package/dist/source/code.js.map +1 -0
- package/package.json +10 -2
- package/src/config-core.ts +258 -0
- package/src/config.ts +3 -238
- package/src/core.test.ts +87 -0
- package/src/core.ts +32 -0
- package/src/dictionary-core.ts +158 -0
- package/src/dictionary.ts +4 -155
- package/src/engine.ts +138 -0
- package/src/index.ts +4 -0
- package/src/lint.ts +10 -115
- package/src/source/code.ts +17 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parts of the configuration that need no file system: the types of
|
|
3
|
+
* `ste.config.json`, the defaults, the validation and the word list merge.
|
|
4
|
+
* A browser can use this module.
|
|
5
|
+
*/
|
|
6
|
+
import { isRuleId, RULE_IDS } from "./types.js";
|
|
7
|
+
import { DEFAULT_WORD_LIST } from "./word-list.js";
|
|
8
|
+
export const CONFIG_FILE_NAME = "ste.config.json";
|
|
9
|
+
/** The environment variable that gives the path of the local dictionary. It has priority over `dictionaryPath`. */
|
|
10
|
+
export const DICTIONARY_ENV = "STE_DICTIONARY";
|
|
11
|
+
export const DEFAULT_INCLUDE = [
|
|
12
|
+
"README.md",
|
|
13
|
+
"docs/**/*.{md,mdx}",
|
|
14
|
+
"packages/*/README.md",
|
|
15
|
+
"packages/*/src/**/*.{ts,tsx}",
|
|
16
|
+
"packages/*/build/**/*.{ts,tsx}",
|
|
17
|
+
"packages/*/commands/**/*.{ts,tsx}",
|
|
18
|
+
"packages/*/*.config.{ts,mts}",
|
|
19
|
+
];
|
|
20
|
+
export const DEFAULT_IGNORE = [
|
|
21
|
+
"**/node_modules/**",
|
|
22
|
+
"**/dist/**",
|
|
23
|
+
"**/*.d.ts",
|
|
24
|
+
"**/*.test.ts",
|
|
25
|
+
"**/*.test.tsx",
|
|
26
|
+
"**/*.spec.ts",
|
|
27
|
+
"**/*.spec.tsx",
|
|
28
|
+
];
|
|
29
|
+
export const DEFAULT_LIMITS = {
|
|
30
|
+
instructionWords: 20,
|
|
31
|
+
descriptionWords: 25,
|
|
32
|
+
paragraphSentences: 6,
|
|
33
|
+
nounClusterNouns: 3,
|
|
34
|
+
};
|
|
35
|
+
/** An error in the configuration. */
|
|
36
|
+
export class ConfigError extends Error {
|
|
37
|
+
name = "ConfigError";
|
|
38
|
+
}
|
|
39
|
+
const SETTINGS = ["error", "warning", "off"];
|
|
40
|
+
const KNOWN_KEYS = new Set([
|
|
41
|
+
"$schema", "include", "ignore", "technicalNouns", "technicalVerbs", "properNouns", "allowedWords",
|
|
42
|
+
"rules", "wordList", "limits", "dictionaryPath",
|
|
43
|
+
]);
|
|
44
|
+
const WORD_LIST_KEYS = new Set(["id", "match", "suggest", "note", "severity", "verbOnly"]);
|
|
45
|
+
/** This function makes sure that `value` is a valid configuration. It throws a `ConfigError` that lists all problems. */
|
|
46
|
+
export function validateConfig(value, source) {
|
|
47
|
+
const problems = [];
|
|
48
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
49
|
+
throw new ConfigError(`${source}: the configuration must be a JSON object.`);
|
|
50
|
+
}
|
|
51
|
+
const record = value;
|
|
52
|
+
for (const key of Object.keys(record)) {
|
|
53
|
+
if (!KNOWN_KEYS.has(key))
|
|
54
|
+
problems.push(`"${key}" is not a known property. Known properties: ${[...KNOWN_KEYS].join(", ")}.`);
|
|
55
|
+
}
|
|
56
|
+
for (const key of ["include", "ignore", "technicalNouns", "technicalVerbs", "properNouns", "allowedWords"]) {
|
|
57
|
+
const item = record[key];
|
|
58
|
+
if (item !== undefined && !(Array.isArray(item) && item.every((entry) => typeof entry === "string"))) {
|
|
59
|
+
problems.push(`"${key}" must be an array of strings.`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const rules = record["rules"];
|
|
63
|
+
if (rules !== undefined) {
|
|
64
|
+
if (typeof rules !== "object" || rules === null || Array.isArray(rules)) {
|
|
65
|
+
problems.push(`"rules" must be an object.`);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
for (const [id, setting] of Object.entries(rules)) {
|
|
69
|
+
if (!isRuleId(id))
|
|
70
|
+
problems.push(`"rules.${id}" is not a known rule. Known rules: ${RULE_IDS.join(", ")}.`);
|
|
71
|
+
if (typeof setting !== "string" || !SETTINGS.includes(setting))
|
|
72
|
+
problems.push(`"rules.${id}" must be "error", "warning" or "off".`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const limits = record["limits"];
|
|
77
|
+
if (limits !== undefined) {
|
|
78
|
+
if (typeof limits !== "object" || limits === null || Array.isArray(limits)) {
|
|
79
|
+
problems.push(`"limits" must be an object.`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
for (const [key, limit] of Object.entries(limits)) {
|
|
83
|
+
if (!Object.hasOwn(DEFAULT_LIMITS, key))
|
|
84
|
+
problems.push(`"limits.${key}" is not a known limit. Known limits: ${Object.keys(DEFAULT_LIMITS).join(", ")}.`);
|
|
85
|
+
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1)
|
|
86
|
+
problems.push(`"limits.${key}" must be an integer of 1 or more.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const dictionaryPath = record["dictionaryPath"];
|
|
91
|
+
if (dictionaryPath !== undefined && dictionaryPath !== null && typeof dictionaryPath !== "string") {
|
|
92
|
+
problems.push(`"dictionaryPath" must be a string or null.`);
|
|
93
|
+
}
|
|
94
|
+
const wordList = record["wordList"];
|
|
95
|
+
if (wordList !== undefined) {
|
|
96
|
+
if (!Array.isArray(wordList)) {
|
|
97
|
+
problems.push(`"wordList" must be an array.`);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
wordList.forEach((item, index) => problems.push(...validateWordListEntry(item, `wordList[${index}]`)));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (problems.length > 0)
|
|
104
|
+
throw new ConfigError(`${source}:\n - ${problems.join("\n - ")}`);
|
|
105
|
+
return record;
|
|
106
|
+
}
|
|
107
|
+
function validateWordListEntry(item, where) {
|
|
108
|
+
if (typeof item !== "object" || item === null || Array.isArray(item))
|
|
109
|
+
return [`"${where}" must be an object.`];
|
|
110
|
+
const problems = [];
|
|
111
|
+
const entry = item;
|
|
112
|
+
for (const key of Object.keys(entry)) {
|
|
113
|
+
if (!WORD_LIST_KEYS.has(key))
|
|
114
|
+
problems.push(`"${where}.${key}" is not a known property.`);
|
|
115
|
+
}
|
|
116
|
+
const match = entry["match"];
|
|
117
|
+
const matchValid = typeof match === "string" || (Array.isArray(match) && match.length > 0 && match.every((word) => typeof word === "string"));
|
|
118
|
+
if (match !== undefined && !matchValid)
|
|
119
|
+
problems.push(`"${where}.match" must be a string or an array of strings.`);
|
|
120
|
+
if (entry["id"] !== undefined && typeof entry["id"] !== "string")
|
|
121
|
+
problems.push(`"${where}.id" must be a string.`);
|
|
122
|
+
if (entry["id"] === undefined && match === undefined)
|
|
123
|
+
problems.push(`"${where}" must have "id" or "match".`);
|
|
124
|
+
for (const key of ["suggest", "note"]) {
|
|
125
|
+
const text = entry[key];
|
|
126
|
+
if (text !== undefined && text !== null && typeof text !== "string")
|
|
127
|
+
problems.push(`"${where}.${key}" must be a string or null.`);
|
|
128
|
+
}
|
|
129
|
+
const severity = entry["severity"];
|
|
130
|
+
if (severity !== undefined && (typeof severity !== "string" || !SETTINGS.includes(severity)))
|
|
131
|
+
problems.push(`"${where}.severity" must be "error", "warning" or "off".`);
|
|
132
|
+
if (entry["verbOnly"] !== undefined && typeof entry["verbOnly"] !== "boolean")
|
|
133
|
+
problems.push(`"${where}.verbOnly" must be true or false.`);
|
|
134
|
+
return problems;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* This function merges the default word list and the entries of the
|
|
138
|
+
* configuration. An entry with the ID (or the first `match` word) of a
|
|
139
|
+
* default entry changes that entry. The severity "off" removes the entry
|
|
140
|
+
* with that ID, and it removes the `match` words from all entries.
|
|
141
|
+
*/
|
|
142
|
+
export function mergeWordList(defaults, overrides) {
|
|
143
|
+
const entries = new Map(defaults.map((entry) => [entry.id, entry]));
|
|
144
|
+
for (const override of overrides) {
|
|
145
|
+
const match = override.match === undefined ? undefined : typeof override.match === "string" ? [override.match] : [...override.match];
|
|
146
|
+
const id = override.id ?? match[0];
|
|
147
|
+
const base = entries.get(id) ?? null;
|
|
148
|
+
if (override.severity === "off") {
|
|
149
|
+
entries.set(id, null);
|
|
150
|
+
const removed = new Set((match ?? []).map((word) => word.toLowerCase()));
|
|
151
|
+
for (const [key, entry] of entries) {
|
|
152
|
+
if (entry === null)
|
|
153
|
+
continue;
|
|
154
|
+
const kept = entry.match.filter((word) => !removed.has(word.toLowerCase()));
|
|
155
|
+
entries.set(key, kept.length === 0 ? null : { ...entry, match: kept });
|
|
156
|
+
}
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const merged = {
|
|
160
|
+
id,
|
|
161
|
+
match: match ?? base?.match ?? [id],
|
|
162
|
+
suggest: override.suggest !== undefined ? override.suggest : base?.suggest ?? null,
|
|
163
|
+
note: override.note !== undefined ? override.note : base?.note ?? null,
|
|
164
|
+
severity: override.severity ?? base?.severity ?? "error",
|
|
165
|
+
verbOnly: override.verbOnly ?? base?.verbOnly ?? false,
|
|
166
|
+
context: base?.context ?? null,
|
|
167
|
+
};
|
|
168
|
+
entries.set(id, merged);
|
|
169
|
+
}
|
|
170
|
+
return [...entries.values()].filter((entry) => entry !== null);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* This function applies the defaults to a configuration file. It reads no
|
|
174
|
+
* file and no environment variable, thus the result has no dictionary path.
|
|
175
|
+
*/
|
|
176
|
+
export function baseConfig(file = {}, options = {}) {
|
|
177
|
+
const rules = {};
|
|
178
|
+
for (const [id, setting] of Object.entries(file.rules ?? {})) {
|
|
179
|
+
if (isRuleId(id))
|
|
180
|
+
rules[id] = setting;
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
root: options.root ?? "",
|
|
184
|
+
configFile: options.configFile ?? null,
|
|
185
|
+
include: file.include ?? DEFAULT_INCLUDE,
|
|
186
|
+
ignore: file.ignore ?? DEFAULT_IGNORE,
|
|
187
|
+
technicalNouns: file.technicalNouns ?? [],
|
|
188
|
+
technicalVerbs: file.technicalVerbs ?? [],
|
|
189
|
+
properNouns: file.properNouns ?? [],
|
|
190
|
+
allowedWords: file.allowedWords ?? [],
|
|
191
|
+
rules,
|
|
192
|
+
wordList: mergeWordList(DEFAULT_WORD_LIST, file.wordList ?? []),
|
|
193
|
+
limits: { ...DEFAULT_LIMITS, ...file.limits },
|
|
194
|
+
dictionaryPath: null,
|
|
195
|
+
dictionarySource: null,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=config-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-core.js","sourceRoot":"","sources":["../src/config-core.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAgD,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,iBAAiB,EAAsB,MAAM,gBAAgB,CAAC;AAEvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAElD,mHAAmH;AACnH,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AA8D/C,MAAM,CAAC,MAAM,eAAe,GAAuB;IAC/C,WAAW;IACX,oBAAoB;IACpB,sBAAsB;IACtB,8BAA8B;IAC9B,gCAAgC;IAChC,mCAAmC;IACnC,8BAA8B;CACjC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAuB;IAC9C,oBAAoB;IACpB,YAAY;IACZ,WAAW;IACX,cAAc;IACd,eAAe;IACf,cAAc;IACd,eAAe;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAY;IACnC,gBAAgB,EAAG,EAAE;IACrB,gBAAgB,EAAG,EAAE;IACrB,kBAAkB,EAAG,CAAC;IACtB,gBAAgB,EAAG,CAAC;CACvB,CAAC;AAEF,qCAAqC;AACrC,MAAM,OAAO,WAAY,SAAQ,KAAK;IAChB,IAAI,GAAY,aAAa,CAAC;CACnD;AAED,MAAM,QAAQ,GAAuB,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;AAEjE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACvB,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,cA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C,iBAAiB,EAAE,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;QAChE,MAAM,EAAG,EAAE,GAAG,cAAc,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE;QAC9C,cAAc,EAAG,IAAI;QACrB,gBAAgB,EAAG,IAAI;KAC1B,CAAC;AACN,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -2,82 +2,8 @@
|
|
|
2
2
|
* The configuration file `ste.config.json`, and the configuration that the
|
|
3
3
|
* linter uses after it reads the file, the environment and the defaults.
|
|
4
4
|
*/
|
|
5
|
-
import { type
|
|
6
|
-
|
|
7
|
-
export declare const CONFIG_FILE_NAME = "ste.config.json";
|
|
8
|
-
/** The environment variable that gives the path of the local dictionary. It has priority over `dictionaryPath`. */
|
|
9
|
-
export declare const DICTIONARY_ENV = "STE_DICTIONARY";
|
|
10
|
-
/** An entry of `wordList` in the configuration file. */
|
|
11
|
-
export type WordListEntryConfig = {
|
|
12
|
-
/** The ID of a default entry to change. A new entry gets the first word of `match` as its ID. */
|
|
13
|
-
readonly id?: string;
|
|
14
|
-
readonly match?: string | readonly string[];
|
|
15
|
-
readonly suggest?: string | null;
|
|
16
|
-
readonly note?: string | null;
|
|
17
|
-
readonly severity?: RuleSetting;
|
|
18
|
-
readonly verbOnly?: boolean;
|
|
19
|
-
};
|
|
20
|
-
export type LimitsConfig = {
|
|
21
|
-
/** The maximum number of words in an instruction. Default: 20 (STE Rule 5.1). */
|
|
22
|
-
readonly instructionWords?: number;
|
|
23
|
-
/** The maximum number of words in a description. Default: 25 (STE Rule 6.3). */
|
|
24
|
-
readonly descriptionWords?: number;
|
|
25
|
-
/** The maximum number of sentences in a paragraph. Default: 6 (STE Rule 6.6). */
|
|
26
|
-
readonly paragraphSentences?: number;
|
|
27
|
-
/** The maximum number of nouns in a noun cluster. Default: 3 (STE Rule 2.1). */
|
|
28
|
-
readonly nounClusterNouns?: number;
|
|
29
|
-
};
|
|
30
|
-
/** The contents of `ste.config.json`. All properties are optional. */
|
|
31
|
-
export type SteConfigFile = {
|
|
32
|
-
readonly $schema?: string;
|
|
33
|
-
readonly include?: readonly string[];
|
|
34
|
-
readonly ignore?: readonly string[];
|
|
35
|
-
readonly technicalNouns?: readonly string[];
|
|
36
|
-
readonly technicalVerbs?: readonly string[];
|
|
37
|
-
readonly properNouns?: readonly string[];
|
|
38
|
-
readonly allowedWords?: readonly string[];
|
|
39
|
-
readonly rules?: Readonly<Record<string, RuleSetting>>;
|
|
40
|
-
readonly wordList?: readonly WordListEntryConfig[];
|
|
41
|
-
readonly limits?: LimitsConfig;
|
|
42
|
-
readonly dictionaryPath?: string | null;
|
|
43
|
-
};
|
|
44
|
-
export type Limits = Required<LimitsConfig>;
|
|
45
|
-
export type ResolvedConfig = {
|
|
46
|
-
/** The directory that `include` and `ignore` are relative to. */
|
|
47
|
-
readonly root: string;
|
|
48
|
-
/** The configuration file, or null when the linter uses the defaults. */
|
|
49
|
-
readonly configFile: string | null;
|
|
50
|
-
readonly include: readonly string[];
|
|
51
|
-
readonly ignore: readonly string[];
|
|
52
|
-
readonly technicalNouns: readonly string[];
|
|
53
|
-
readonly technicalVerbs: readonly string[];
|
|
54
|
-
readonly properNouns: readonly string[];
|
|
55
|
-
readonly allowedWords: readonly string[];
|
|
56
|
-
/** The rule settings from the configuration. A rule without a setting uses its default severity. */
|
|
57
|
-
readonly rules: Readonly<Partial<Record<RuleId, RuleSetting>>>;
|
|
58
|
-
readonly wordList: readonly WordListEntry[];
|
|
59
|
-
readonly limits: Limits;
|
|
60
|
-
/** The absolute path of the local dictionary, or null. */
|
|
61
|
-
readonly dictionaryPath: string | null;
|
|
62
|
-
/** Where the dictionary path came from. */
|
|
63
|
-
readonly dictionarySource: "env" | "config" | null;
|
|
64
|
-
};
|
|
65
|
-
export declare const DEFAULT_INCLUDE: readonly string[];
|
|
66
|
-
export declare const DEFAULT_IGNORE: readonly string[];
|
|
67
|
-
export declare const DEFAULT_LIMITS: Limits;
|
|
68
|
-
/** An error in the configuration. */
|
|
69
|
-
export declare class ConfigError extends Error {
|
|
70
|
-
readonly name: string;
|
|
71
|
-
}
|
|
72
|
-
/** This function makes sure that `value` is a valid configuration. It throws a `ConfigError` that lists all problems. */
|
|
73
|
-
export declare function validateConfig(value: unknown, source: string): SteConfigFile;
|
|
74
|
-
/**
|
|
75
|
-
* This function merges the default word list and the entries of the
|
|
76
|
-
* configuration. An entry with the ID (or the first `match` word) of a
|
|
77
|
-
* default entry changes that entry. The severity "off" removes the entry
|
|
78
|
-
* with that ID, and it removes the `match` words from all entries.
|
|
79
|
-
*/
|
|
80
|
-
export declare function mergeWordList(defaults: readonly WordListEntry[], overrides: readonly WordListEntryConfig[]): WordListEntry[];
|
|
5
|
+
import { type ResolvedConfig, type SteConfigFile } from "./config-core.js";
|
|
6
|
+
export * from "./config-core.js";
|
|
81
7
|
/** This function expands a leading `~/` to the home directory, and makes the path absolute. */
|
|
82
8
|
export declare function resolvePath(path: string, base: string): string;
|
|
83
9
|
export type ResolveOptions = {
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAA6E,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtJ,cAAc,kBAAkB,CAAC;AAEjC,+FAA+F;AAC/F,wBAAgB,WAAW,CAAC,IAAI,EAAG,MAAM,EAAE,IAAI,EAAG,MAAM,GAAI,MAAM,CAGjE;AAED,MAAM,MAAM,cAAc,GAAG;IACzB,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAG,MAAM,GAAG,IAAI,CAAC;IACrC,iEAAiE;IACjE,QAAQ,CAAC,GAAG,CAAC,EAAG,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,sFAAsF;AACtF,wBAAgB,aAAa,CAAC,IAAI,EAAG,aAAa,EAAE,OAAO,EAAG,cAAc,GAAI,cAAc,CAc7F;AAED,sFAAsF;AACtF,wBAAgB,cAAc,CAAC,GAAG,EAAG,MAAM,GAAI,MAAM,GAAG,IAAI,CAS3D;AAED,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,CAAC,GAAG,EAAG,MAAM,CAAC;IACtB,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,CAAC,EAAG,MAAM,CAAC;IAC9B,QAAQ,CAAC,GAAG,CAAC,EAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;CAChE,CAAC;AAEF,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,OAAO,EAAG,WAAW,GAAI,cAAc,CAkBjE"}
|
package/dist/config.js
CHANGED
|
@@ -5,172 +5,8 @@
|
|
|
5
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
import { dirname, join, resolve } from "node:path";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
export const CONFIG_FILE_NAME = "ste.config.json";
|
|
11
|
-
/** The environment variable that gives the path of the local dictionary. It has priority over `dictionaryPath`. */
|
|
12
|
-
export const DICTIONARY_ENV = "STE_DICTIONARY";
|
|
13
|
-
export const DEFAULT_INCLUDE = [
|
|
14
|
-
"README.md",
|
|
15
|
-
"docs/**/*.{md,mdx}",
|
|
16
|
-
"packages/*/README.md",
|
|
17
|
-
"packages/*/src/**/*.{ts,tsx}",
|
|
18
|
-
"packages/*/build/**/*.{ts,tsx}",
|
|
19
|
-
"packages/*/commands/**/*.{ts,tsx}",
|
|
20
|
-
"packages/*/*.config.{ts,mts}",
|
|
21
|
-
];
|
|
22
|
-
export const DEFAULT_IGNORE = [
|
|
23
|
-
"**/node_modules/**",
|
|
24
|
-
"**/dist/**",
|
|
25
|
-
"**/*.d.ts",
|
|
26
|
-
"**/*.test.ts",
|
|
27
|
-
"**/*.test.tsx",
|
|
28
|
-
"**/*.spec.ts",
|
|
29
|
-
"**/*.spec.tsx",
|
|
30
|
-
];
|
|
31
|
-
export const DEFAULT_LIMITS = {
|
|
32
|
-
instructionWords: 20,
|
|
33
|
-
descriptionWords: 25,
|
|
34
|
-
paragraphSentences: 6,
|
|
35
|
-
nounClusterNouns: 3,
|
|
36
|
-
};
|
|
37
|
-
/** An error in the configuration. */
|
|
38
|
-
export class ConfigError extends Error {
|
|
39
|
-
name = "ConfigError";
|
|
40
|
-
}
|
|
41
|
-
const SETTINGS = ["error", "warning", "off"];
|
|
42
|
-
const KNOWN_KEYS = new Set([
|
|
43
|
-
"$schema", "include", "ignore", "technicalNouns", "technicalVerbs", "properNouns", "allowedWords",
|
|
44
|
-
"rules", "wordList", "limits", "dictionaryPath",
|
|
45
|
-
]);
|
|
46
|
-
const WORD_LIST_KEYS = new Set(["id", "match", "suggest", "note", "severity", "verbOnly"]);
|
|
47
|
-
/** This function makes sure that `value` is a valid configuration. It throws a `ConfigError` that lists all problems. */
|
|
48
|
-
export function validateConfig(value, source) {
|
|
49
|
-
const problems = [];
|
|
50
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
51
|
-
throw new ConfigError(`${source}: the configuration must be a JSON object.`);
|
|
52
|
-
}
|
|
53
|
-
const record = value;
|
|
54
|
-
for (const key of Object.keys(record)) {
|
|
55
|
-
if (!KNOWN_KEYS.has(key))
|
|
56
|
-
problems.push(`"${key}" is not a known property. Known properties: ${[...KNOWN_KEYS].join(", ")}.`);
|
|
57
|
-
}
|
|
58
|
-
for (const key of ["include", "ignore", "technicalNouns", "technicalVerbs", "properNouns", "allowedWords"]) {
|
|
59
|
-
const item = record[key];
|
|
60
|
-
if (item !== undefined && !(Array.isArray(item) && item.every((entry) => typeof entry === "string"))) {
|
|
61
|
-
problems.push(`"${key}" must be an array of strings.`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
const rules = record["rules"];
|
|
65
|
-
if (rules !== undefined) {
|
|
66
|
-
if (typeof rules !== "object" || rules === null || Array.isArray(rules)) {
|
|
67
|
-
problems.push(`"rules" must be an object.`);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
for (const [id, setting] of Object.entries(rules)) {
|
|
71
|
-
if (!isRuleId(id))
|
|
72
|
-
problems.push(`"rules.${id}" is not a known rule. Known rules: ${RULE_IDS.join(", ")}.`);
|
|
73
|
-
if (typeof setting !== "string" || !SETTINGS.includes(setting))
|
|
74
|
-
problems.push(`"rules.${id}" must be "error", "warning" or "off".`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
const limits = record["limits"];
|
|
79
|
-
if (limits !== undefined) {
|
|
80
|
-
if (typeof limits !== "object" || limits === null || Array.isArray(limits)) {
|
|
81
|
-
problems.push(`"limits" must be an object.`);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
for (const [key, limit] of Object.entries(limits)) {
|
|
85
|
-
if (!Object.hasOwn(DEFAULT_LIMITS, key))
|
|
86
|
-
problems.push(`"limits.${key}" is not a known limit. Known limits: ${Object.keys(DEFAULT_LIMITS).join(", ")}.`);
|
|
87
|
-
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1)
|
|
88
|
-
problems.push(`"limits.${key}" must be an integer of 1 or more.`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
const dictionaryPath = record["dictionaryPath"];
|
|
93
|
-
if (dictionaryPath !== undefined && dictionaryPath !== null && typeof dictionaryPath !== "string") {
|
|
94
|
-
problems.push(`"dictionaryPath" must be a string or null.`);
|
|
95
|
-
}
|
|
96
|
-
const wordList = record["wordList"];
|
|
97
|
-
if (wordList !== undefined) {
|
|
98
|
-
if (!Array.isArray(wordList)) {
|
|
99
|
-
problems.push(`"wordList" must be an array.`);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
wordList.forEach((item, index) => problems.push(...validateWordListEntry(item, `wordList[${index}]`)));
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
if (problems.length > 0)
|
|
106
|
-
throw new ConfigError(`${source}:\n - ${problems.join("\n - ")}`);
|
|
107
|
-
return record;
|
|
108
|
-
}
|
|
109
|
-
function validateWordListEntry(item, where) {
|
|
110
|
-
if (typeof item !== "object" || item === null || Array.isArray(item))
|
|
111
|
-
return [`"${where}" must be an object.`];
|
|
112
|
-
const problems = [];
|
|
113
|
-
const entry = item;
|
|
114
|
-
for (const key of Object.keys(entry)) {
|
|
115
|
-
if (!WORD_LIST_KEYS.has(key))
|
|
116
|
-
problems.push(`"${where}.${key}" is not a known property.`);
|
|
117
|
-
}
|
|
118
|
-
const match = entry["match"];
|
|
119
|
-
const matchValid = typeof match === "string" || (Array.isArray(match) && match.length > 0 && match.every((word) => typeof word === "string"));
|
|
120
|
-
if (match !== undefined && !matchValid)
|
|
121
|
-
problems.push(`"${where}.match" must be a string or an array of strings.`);
|
|
122
|
-
if (entry["id"] !== undefined && typeof entry["id"] !== "string")
|
|
123
|
-
problems.push(`"${where}.id" must be a string.`);
|
|
124
|
-
if (entry["id"] === undefined && match === undefined)
|
|
125
|
-
problems.push(`"${where}" must have "id" or "match".`);
|
|
126
|
-
for (const key of ["suggest", "note"]) {
|
|
127
|
-
const text = entry[key];
|
|
128
|
-
if (text !== undefined && text !== null && typeof text !== "string")
|
|
129
|
-
problems.push(`"${where}.${key}" must be a string or null.`);
|
|
130
|
-
}
|
|
131
|
-
const severity = entry["severity"];
|
|
132
|
-
if (severity !== undefined && (typeof severity !== "string" || !SETTINGS.includes(severity)))
|
|
133
|
-
problems.push(`"${where}.severity" must be "error", "warning" or "off".`);
|
|
134
|
-
if (entry["verbOnly"] !== undefined && typeof entry["verbOnly"] !== "boolean")
|
|
135
|
-
problems.push(`"${where}.verbOnly" must be true or false.`);
|
|
136
|
-
return problems;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* This function merges the default word list and the entries of the
|
|
140
|
-
* configuration. An entry with the ID (or the first `match` word) of a
|
|
141
|
-
* default entry changes that entry. The severity "off" removes the entry
|
|
142
|
-
* with that ID, and it removes the `match` words from all entries.
|
|
143
|
-
*/
|
|
144
|
-
export function mergeWordList(defaults, overrides) {
|
|
145
|
-
const entries = new Map(defaults.map((entry) => [entry.id, entry]));
|
|
146
|
-
for (const override of overrides) {
|
|
147
|
-
const match = override.match === undefined ? undefined : typeof override.match === "string" ? [override.match] : [...override.match];
|
|
148
|
-
const id = override.id ?? match[0];
|
|
149
|
-
const base = entries.get(id) ?? null;
|
|
150
|
-
if (override.severity === "off") {
|
|
151
|
-
entries.set(id, null);
|
|
152
|
-
const removed = new Set((match ?? []).map((word) => word.toLowerCase()));
|
|
153
|
-
for (const [key, entry] of entries) {
|
|
154
|
-
if (entry === null)
|
|
155
|
-
continue;
|
|
156
|
-
const kept = entry.match.filter((word) => !removed.has(word.toLowerCase()));
|
|
157
|
-
entries.set(key, kept.length === 0 ? null : { ...entry, match: kept });
|
|
158
|
-
}
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
const merged = {
|
|
162
|
-
id,
|
|
163
|
-
match: match ?? base?.match ?? [id],
|
|
164
|
-
suggest: override.suggest !== undefined ? override.suggest : base?.suggest ?? null,
|
|
165
|
-
note: override.note !== undefined ? override.note : base?.note ?? null,
|
|
166
|
-
severity: override.severity ?? base?.severity ?? "error",
|
|
167
|
-
verbOnly: override.verbOnly ?? base?.verbOnly ?? false,
|
|
168
|
-
context: base?.context ?? null,
|
|
169
|
-
};
|
|
170
|
-
entries.set(id, merged);
|
|
171
|
-
}
|
|
172
|
-
return [...entries.values()].filter((entry) => entry !== null);
|
|
173
|
-
}
|
|
8
|
+
import { baseConfig, CONFIG_FILE_NAME, ConfigError, DICTIONARY_ENV, validateConfig } from "./config-core.js";
|
|
9
|
+
export * from "./config-core.js";
|
|
174
10
|
/** This function expands a leading `~/` to the home directory, and makes the path absolute. */
|
|
175
11
|
export function resolvePath(path, base) {
|
|
176
12
|
const expanded = path === "~" ? homedir() : path.startsWith("~/") || path.startsWith("~\\") ? join(homedir(), path.slice(2)) : path;
|
|
@@ -191,26 +27,7 @@ export function resolveConfig(file, options) {
|
|
|
191
27
|
dictionaryPath = resolvePath(file.dictionaryPath.trim(), options.root);
|
|
192
28
|
dictionarySource = "config";
|
|
193
29
|
}
|
|
194
|
-
|
|
195
|
-
for (const [id, setting] of Object.entries(file.rules ?? {})) {
|
|
196
|
-
if (isRuleId(id))
|
|
197
|
-
rules[id] = setting;
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
root: options.root,
|
|
201
|
-
configFile: options.configFile ?? null,
|
|
202
|
-
include: file.include ?? DEFAULT_INCLUDE,
|
|
203
|
-
ignore: file.ignore ?? DEFAULT_IGNORE,
|
|
204
|
-
technicalNouns: file.technicalNouns ?? [],
|
|
205
|
-
technicalVerbs: file.technicalVerbs ?? [],
|
|
206
|
-
properNouns: file.properNouns ?? [],
|
|
207
|
-
allowedWords: file.allowedWords ?? [],
|
|
208
|
-
rules,
|
|
209
|
-
wordList: mergeWordList(DEFAULT_WORD_LIST, file.wordList ?? []),
|
|
210
|
-
limits: { ...DEFAULT_LIMITS, ...file.limits },
|
|
211
|
-
dictionaryPath,
|
|
212
|
-
dictionarySource,
|
|
213
|
-
};
|
|
30
|
+
return { ...baseConfig(file, { root: options.root, configFile: options.configFile ?? null }), dictionaryPath, dictionarySource };
|
|
214
31
|
}
|
|
215
32
|
/** The first `ste.config.json` in `cwd` or one of its parent directories, or null. */
|
|
216
33
|
export function findConfigFile(cwd) {
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-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,CAAC;IACpG,CAAC;IACD,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAC/C,OAAO,aAAa,CAAC,IAAI,EAAE,EAAE,IAAI,EAAG,OAAO,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,GAAG,EAAG,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;AACnG,CAAC"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@mark1russell7/ste-lint/core`: the linter without a file system, for a
|
|
3
|
+
* browser or another host that has the text in memory. It examines Markdown
|
|
4
|
+
* and MDX. For TypeScript doc comments, give the extractor of
|
|
5
|
+
* `@mark1russell7/ste-lint/code` to `ProseLinter`. The rules are the same
|
|
6
|
+
* rules that the command line uses.
|
|
7
|
+
*/
|
|
8
|
+
export { baseConfig, CONFIG_FILE_NAME, ConfigError, DEFAULT_IGNORE, DEFAULT_INCLUDE, DEFAULT_LIMITS, DICTIONARY_ENV, mergeWordList, validateConfig, type BaseConfigOptions, type Limits, type LimitsConfig, type ResolvedConfig, type SteConfigFile, type WordListEntryConfig, } from "./config-core.js";
|
|
9
|
+
export { Dictionary, DICTIONARY_FORMAT, DictionaryError, parseDictionary, type DictionaryEntry, type DictionaryLookup } from "./dictionary-core.js";
|
|
10
|
+
export { fileKind, ProseLinter, type CodeExtractor, type FileKind, type ProseLinterOptions } from "./engine.js";
|
|
11
|
+
export { formatJson, formatText, summarize, type RuleCount, type Summary } from "./format.js";
|
|
12
|
+
export { buildLexicon, type Lexicon } from "./lexicon.js";
|
|
13
|
+
export { getRule, RULES, type Rule } from "./rules/index.js";
|
|
14
|
+
export { isRuleId, RULE_IDS, type Finding, type RuleId, type RuleSetting, type Severity } from "./types.js";
|
|
15
|
+
export { DEFAULT_WORD_LIST, type WordListEntry } from "./word-list.js";
|
|
16
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACH,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GAC3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACpJ,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAChH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC5G,OAAO,EAAE,iBAAiB,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@mark1russell7/ste-lint/core`: the linter without a file system, for a
|
|
3
|
+
* browser or another host that has the text in memory. It examines Markdown
|
|
4
|
+
* and MDX. For TypeScript doc comments, give the extractor of
|
|
5
|
+
* `@mark1russell7/ste-lint/code` to `ProseLinter`. The rules are the same
|
|
6
|
+
* rules that the command line uses.
|
|
7
|
+
*/
|
|
8
|
+
export { baseConfig, CONFIG_FILE_NAME, ConfigError, DEFAULT_IGNORE, DEFAULT_INCLUDE, DEFAULT_LIMITS, DICTIONARY_ENV, mergeWordList, validateConfig, } from "./config-core.js";
|
|
9
|
+
export { Dictionary, DICTIONARY_FORMAT, DictionaryError, parseDictionary } from "./dictionary-core.js";
|
|
10
|
+
export { fileKind, ProseLinter } from "./engine.js";
|
|
11
|
+
export { formatJson, formatText, summarize } from "./format.js";
|
|
12
|
+
export { buildLexicon } from "./lexicon.js";
|
|
13
|
+
export { getRule, RULES } from "./rules/index.js";
|
|
14
|
+
export { isRuleId, RULE_IDS } from "./types.js";
|
|
15
|
+
export { DEFAULT_WORD_LIST } from "./word-list.js";
|
|
16
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACH,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,eAAe,EACf,cAAc,EACd,cAAc,EACd,aAAa,EACb,cAAc,GAOjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAA+C,MAAM,sBAAsB,CAAC;AACpJ,OAAO,EAAE,QAAQ,EAAE,WAAW,EAA8D,MAAM,aAAa,CAAC;AAChH,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAgC,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,YAAY,EAAgB,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAa,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAA8D,MAAM,YAAY,CAAC;AAC5G,OAAO,EAAE,iBAAiB,EAAsB,MAAM,gBAAgB,CAAC"}
|