@mslmio/eslint-config 2.2.0 → 2.3.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/package.json +3 -3
- package/plugin.js +1 -1
- package/rules/us-spelling.js +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mslmio/eslint-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Shareable ESLint flat config and house rules: US spelling, library hygiene, workspace layering, and Tailwind/React conventions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "8.70.
|
|
59
|
-
"@typescript-eslint/parser": "8.70.
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "8.70.1",
|
|
59
|
+
"@typescript-eslint/parser": "8.70.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"eslint": "^10.10.0",
|
package/plugin.js
CHANGED
|
@@ -9,7 +9,7 @@ import noUpwardImport from "./rules/no-upward-import.js";
|
|
|
9
9
|
import preferTableFacets from "./rules/prefer-table-facets.js";
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
|
-
meta: { name: "@mslmio/eslint-plugin", version: "2.
|
|
12
|
+
meta: { name: "@mslmio/eslint-plugin", version: "2.3.0" },
|
|
13
13
|
rules: {
|
|
14
14
|
"no-lib-process-env": noLibProcessEnv,
|
|
15
15
|
"no-module-scope-init": noModuleScopeInit,
|
package/rules/us-spelling.js
CHANGED
|
@@ -11,6 +11,9 @@ const ISE_VERBS = {
|
|
|
11
11
|
utilise: "utilize", visualise: "visualize",
|
|
12
12
|
};
|
|
13
13
|
const ISE_ENDINGS = ["e", "ed", "es", "ing", "ation", "ations", "er", "ers", "able"];
|
|
14
|
+
// A prefix an -ise verb takes as one word, which the fix keeps. A closed list, unlike
|
|
15
|
+
// COMPOUND_STEMS's open one, which would also match the tail of a snake_case value.
|
|
16
|
+
const ISE_PREFIXES = ["un", "re", "de", "dis", "pre", "over", "under", "mis"];
|
|
14
17
|
|
|
15
18
|
const WORDS = {
|
|
16
19
|
metre: "meter", metres: "meters", litre: "liter", litres: "liters", fibre: "fiber", fibres: "fibers",
|
|
@@ -73,6 +76,11 @@ const WORDS = {
|
|
|
73
76
|
|
|
74
77
|
const WORD_RE = new RegExp(`\\b(${Object.keys(WORDS).join("|")})\\b`, "gi");
|
|
75
78
|
const COMPOUND_RE = new RegExp(`\\b(\\w*?)(${Object.keys(COMPOUND_STEMS).join("|")})\\b`, "gi");
|
|
79
|
+
const ISE_STEMS = Object.keys(ISE_VERBS).map((gb) => gb.slice(0, -1));
|
|
80
|
+
const PREFIXED_ISE_RE = new RegExp(
|
|
81
|
+
`\\b(${ISE_PREFIXES.join("|")})(${ISE_STEMS.join("|")})(${ISE_ENDINGS.join("|")})\\b`,
|
|
82
|
+
"gi",
|
|
83
|
+
);
|
|
76
84
|
|
|
77
85
|
export default {
|
|
78
86
|
meta: {
|
|
@@ -154,6 +162,10 @@ function findAll(text) {
|
|
|
154
162
|
const stem = COMPOUND_STEMS[m[2].toLowerCase()];
|
|
155
163
|
hits.push([m[0], m[1] + matchCase(m[2], stem)]);
|
|
156
164
|
}
|
|
165
|
+
for (const m of text.matchAll(PREFIXED_ISE_RE)) {
|
|
166
|
+
const stem = ISE_VERBS[`${m[2].toLowerCase()}e`].slice(0, -1);
|
|
167
|
+
hits.push([m[0], matchCase(m[0], `${m[1]}${stem}${m[3]}`.toLowerCase())]);
|
|
168
|
+
}
|
|
157
169
|
return hits;
|
|
158
170
|
}
|
|
159
171
|
|