Skip to content

Commit 9ffbaae

Browse files
committedJun 10, 2023
fix: changed lib from js to ts
Signed-off-by: prisis <d.bannert@anolilab.de>
1 parent dc44699 commit 9ffbaae

11 files changed

+426
-415
lines changed
 

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
"packages/*"
5555
],
5656
"scripts": {
57-
"build:packages": "pnpm --filter \"package-json-utils\" run build && nx run-many --target=build --projects=browserslist-config-anolilab,babel-preset,prettier-config",
58-
"build:prod:packages": "pnpm --filter \"package-json-utils\" run build:prod && nx run-many --target=build:prod --projects=browserslist-config-anolilab,babel-preset,prettier-config",
57+
"build:packages": "pnpm --filter \"package-json-utils\" run build && nx run-many --target=build --projects=browserslist-config-anolilab,babel-preset,prettier-config,textlint-config",
58+
"build:prod:packages": "pnpm --filter \"package-json-utils\" run build:prod && nx run-many --target=build:prod --projects=browserslist-config-anolilab,babel-preset,prettier-config,textlint-config",
5959
"preinstall": "node verify-node-version.cjs",
6060
"postinstall": "is-ci || husky install",
6161
"lint:eslint": "cross-env NO_LOGS=true eslint -c ./.eslintrc.cjs --ext .js,.cjs,.mjs,.ts,.tsx ./packages --cache --cache-strategy content .",

‎packages/textlint-config/README.md

+140-141
Original file line numberDiff line numberDiff line change
@@ -20,157 +20,156 @@ Anolilab Coding Standard for text linting.
2020
npm install --dev-save @anolilab/textlint-config textlint
2121
```
2222

23+
```sh
24+
$ yarn add -D @anolilab/textlint-config textlint
25+
```
26+
27+
```sh
28+
$ pnpm add -D @anolilab/textlint-config textlint
29+
```
30+
2331
## Usage
2432

2533
If you don’t have a `.textlintrc`, we will create the file for you after installing `@anolilab/textlint-config`.
2634

2735
If you already have a `.textlintrc`, then you can extend the `.textlintrc`, with `@anolilab/textlint-config`.
2836

29-
```text
37+
```json5
3038
{
31-
"filters": {
32-
"comments": true
33-
},
34-
"rules": {
35-
"en-capitalization": true,
36-
"footnote-order": true,
37-
"no-todo": true,
38-
"no-dead-link": {
39-
"ignore": [
40-
"bc_data_*",
41-
]
42-
},
43-
"no-empty-section": true,
44-
"terminology": true,
45-
"apostrophe": true,
46-
"diacritics": true,
47-
"@textlint-rule/no-invalid-control-character": true,
48-
"@textlint-rule/no-unmatched-pair": true,
49-
"abbr-within-parentheses": true,
50-
"alex": {
51-
"allow": [
52-
"period",
53-
"european",
54-
"failure",
55-
"fore",
56-
"attack",
57-
"execution",
58-
"executed",
59-
"remain",
60-
"execute"
61-
]
39+
"@textlint/markdown": {
40+
"extensions": [".md", ".mdx"]
6241
},
63-
"@textlint-rule/preset-google": true,
64-
"write-good": {
65-
"passive": false,
66-
"eprime": false,
42+
"filters": {
43+
"comments": true
6744
},
68-
"common-misspellings": true,
69-
"terminology": {
70-
"defaultTerms": false,
71-
"terms": [
72-
// Abbreviations
73-
"API",
74-
["API['’]?s", "APIs"],
75-
"Ajax",
76-
"CLI",
77-
"CSS",
78-
"CORS",
79-
["^E2E", "E2E"],
80-
"gif",
81-
["^HTML", "HTML"],
82-
["^URL(s?)", "URL$1"],
83-
["^HTTP", "HTTP"],
84-
["^HTTPS", "HTTPS"],
85-
"SSO",
86-
["^XHR(s?)", "XHR$1"],
87-
["^XHR['’]?s", "XHRs"],
88-
"Xvfb",
89-
"YAML",
90-
91-
// Words and phrases
92-
["\\(s\\)he", "they"],
93-
["he or she", "they"],
94-
["he/she", "they"],
95-
["crazy", "complex"],
96-
["crazier", "more complex"],
97-
["craziest", "most complex"],
98-
["dumb", "unintended"],
99-
["insane", "outrageous"],
100-
101-
// Prefer American spelling
102-
["behaviour", "behavior"],
103-
["cancelled", "canceled"],
104-
["cancelling", "canceling"],
105-
["centre", "center"],
106-
["colour", "color"],
107-
["customise", "customize"],
108-
["customisation", "customization"],
109-
["favourite", "favorite"],
110-
["labelled", "labeled"],
111-
["licence", "license"],
112-
["organise", "organize"],
113-
114-
// Common misspellings
115-
["gaurantee", "guarantee"],
116-
117-
// Words we would like to not use altogether
118-
["simply", ""],
119-
120-
// Single word
121-
["change[- ]log(s?)", "changelog$1"],
122-
["code[- ]base(es?)", "codebase$1"],
123-
["e[- ]mail(s?)", "email$1"],
124-
["end[- ]point(s?)", "endpoint$1"],
125-
["file[- ]name(s?)", "filename$1"],
126-
["can[- ]not", "cannot$1"],
127-
128-
// Multiple words
129-
["back-?end(s?)", "back end$1"],
130-
["front-?end(s?)", "front end$1"],
131-
["full-?stack(s?)", "full stack$1"],
132-
["open-?source(ed?)", "open source$1"],
133-
["web-?page(s?)", "web page$1"],
134-
135-
// Hyphenated
136-
["end ?to ?end", "end-to-end"],
137-
["retryability", "retry-ability"],
138-
["retriability", "retry-ability"],
139-
140-
["some", ""],
141-
["filetype", "file type"],
142-
["stylesheet", "style sheet"],
143-
["like this", ""],
144-
["probably", ""],
145-
["known as", ""],
146-
["really", ""],
147-
["just", ""],
148-
["simple", ""],
149-
["obvious", ""],
150-
["straightforward", ""],
151-
["very", ""],
152-
["a little", ""],
153-
["note that", ""],
154-
["good to note", ""],
155-
["good to remember", ""],
156-
["basically", ""],
157-
["actually", ""],
158-
["pretty", ""],
159-
["easy", ""],
160-
["interesting", ""],
161-
["way to", ""],
162-
["In order to", "To"],
163-
["in order to", "to"],
164-
["might", ""],
165-
["us", ""],
166-
["I'll", ""],
167-
["I've", ""],
168-
["they'll", ""],
169-
["it is", "it's"],
170-
["It is", "It's"],
171-
]
45+
"rules": {
46+
"en-capitalization": true,
47+
"footnote-order": true,
48+
"no-todo": true,
49+
"no-dead-link": {
50+
"ignore": ["bc_data_*"]
51+
},
52+
"no-empty-section": true,
53+
"terminology": true,
54+
"apostrophe": true,
55+
"diacritics": true,
56+
"@textlint-rule/no-invalid-control-character": true,
57+
"@textlint-rule/no-unmatched-pair": true,
58+
"abbr-within-parentheses": true,
59+
"alex": {
60+
"allow": ["period", "european", "failure", "fore", "attack", "execution", "executed", "remain", "execute"]
61+
},
62+
"@textlint-rule/preset-google": true,
63+
"write-good": {
64+
"passive": false,
65+
"eprime": false
66+
},
67+
"common-misspellings": true,
68+
"terminology": {
69+
"defaultTerms": false,
70+
"terms": [
71+
// Abbreviations
72+
"API",
73+
["API['’]?s", "APIs"],
74+
"Ajax",
75+
"CLI",
76+
"CSS",
77+
"CORS",
78+
["^E2E", "E2E"],
79+
"gif",
80+
["^HTML", "HTML"],
81+
["^URL(s?)", "URL$1"],
82+
["^HTTP", "HTTP"],
83+
["^HTTPS", "HTTPS"],
84+
"SSO",
85+
["^XHR(s?)", "XHR$1"],
86+
["^XHR['’]?s", "XHRs"],
87+
"Xvfb",
88+
"YAML",
89+
90+
// Words and phrases
91+
["\\(s\\)he", "they"],
92+
["he or she", "they"],
93+
["he/she", "they"],
94+
["crazy", "complex"],
95+
["crazier", "more complex"],
96+
["craziest", "most complex"],
97+
["dumb", "unintended"],
98+
["insane", "outrageous"],
99+
100+
// Prefer American spelling
101+
["behaviour", "behavior"],
102+
["cancelled", "canceled"],
103+
["cancelling", "canceling"],
104+
["centre", "center"],
105+
["colour", "color"],
106+
["customise", "customize"],
107+
["customisation", "customization"],
108+
["favourite", "favorite"],
109+
["labelled", "labeled"],
110+
["licence", "license"],
111+
["organise", "organize"],
112+
113+
// Common misspellings
114+
["gaurantee", "guarantee"],
115+
116+
// Words we would like to not use altogether
117+
["simply", ""],
118+
119+
// Single word
120+
["change[- ]log(s?)", "changelog$1"],
121+
["code[- ]base(es?)", "codebase$1"],
122+
["e[- ]mail(s?)", "email$1"],
123+
["end[- ]point(s?)", "endpoint$1"],
124+
["file[- ]name(s?)", "filename$1"],
125+
["can[- ]not", "cannot$1"],
126+
127+
// Multiple words
128+
["back-?end(s?)", "back end$1"],
129+
["front-?end(s?)", "front end$1"],
130+
["full-?stack(s?)", "full stack$1"],
131+
["open-?source(ed?)", "open source$1"],
132+
["web-?page(s?)", "web page$1"],
133+
134+
// Hyphenated
135+
["end ?to ?end", "end-to-end"],
136+
["retryability", "retry-ability"],
137+
["retriability", "retry-ability"],
138+
139+
["some", ""],
140+
["filetype", "file type"],
141+
["stylesheet", "style sheet"],
142+
["like this", ""],
143+
["probably", ""],
144+
["known as", ""],
145+
["really", ""],
146+
["just", ""],
147+
["simple", ""],
148+
["obvious", ""],
149+
["straightforward", ""],
150+
["very", ""],
151+
["a little", ""],
152+
["note that", ""],
153+
["good to note", ""],
154+
["good to remember", ""],
155+
["basically", ""],
156+
["actually", ""],
157+
["pretty", ""],
158+
["easy", ""],
159+
["interesting", ""],
160+
["way to", ""],
161+
["In order to", "To"],
162+
["in order to", "to"],
163+
["might", ""],
164+
["us", ""],
165+
["I'll", ""],
166+
["I've", ""],
167+
["they'll", ""],
168+
["it is", "it's"],
169+
["It is", "It's"]
170+
]
171+
}
172172
}
173-
}
174173
}
175174
```
176175

‎packages/textlint-config/lib/postinstall.js

-218
This file was deleted.

‎packages/textlint-config/package.json

+23-37
Original file line numberDiff line numberDiff line change
@@ -30,38 +30,41 @@
3030
"name": "Daniel Bannert",
3131
"email": "d.bannert@anolilab.de"
3232
},
33-
"type": "module",
33+
"source": "src/postinstall.ts",
3434
"files": [
35-
"lib",
35+
"dist",
3636
"README.md",
3737
"CHANGELOG.md",
3838
"LICENSE.md"
3939
],
4040
"scripts": {
41-
"postinstall": "node lib/postinstall.js"
41+
"build": "cross-env NODE_ENV=development tsup",
42+
"build:prod": "cross-env NODE_ENV=production tsup",
43+
"clean": "rimraf node_modules dist",
44+
"postinstall": "node ./skip.js || node ./dist/postinstall.js"
4245
},
4346
"dependencies": {
44-
"@textlint-rule/textlint-rule-no-invalid-control-character": "2.0.0",
45-
"@textlint-rule/textlint-rule-no-unmatched-pair": "1.0.9",
46-
"@textlint-rule/textlint-rule-preset-google": "0.1.2",
47+
"@textlint-rule/textlint-rule-no-invalid-control-character": "^2.0.0",
48+
"@textlint-rule/textlint-rule-no-unmatched-pair": "^1.0.9",
49+
"@textlint-rule/textlint-rule-preset-google": "^0.1.2",
4750
"@textlint/ast-node-types": "^13.3.2",
4851
"@textlint/types": "^13.3.2",
4952
"textlint-filter-rule-comments": "^1.2.2",
50-
"textlint-rule-abbr-within-parentheses": "1.0.2",
51-
"textlint-rule-alex": "3.0.0",
52-
"textlint-rule-apostrophe": "2.0.0",
53-
"textlint-rule-common-misspellings": "1.0.1",
53+
"textlint-rule-abbr-within-parentheses": "^1.0.2",
54+
"textlint-rule-alex": "^3.0.0",
55+
"textlint-rule-apostrophe": "^2.0.0",
56+
"textlint-rule-common-misspellings": "^1.0.1",
5457
"textlint-rule-date-weekday-mismatch": "^1.0.6",
55-
"textlint-rule-diacritics": "1.0.0",
56-
"textlint-rule-en-capitalization": "2.0.3",
57-
"textlint-rule-footnote-order": "1.0.3",
58-
"textlint-rule-helper": "2.3.0",
59-
"textlint-rule-no-dead-link": "5.1.2",
60-
"textlint-rule-no-empty-section": "1.1.0",
61-
"textlint-rule-no-todo": "2.0.1",
62-
"textlint-rule-terminology": "3.0.4",
63-
"textlint-rule-write-good": "2.0.0",
64-
"write-good": "1.0.8"
58+
"textlint-rule-diacritics": "^1.0.0",
59+
"textlint-rule-en-capitalization": "^2.0.3",
60+
"textlint-rule-footnote-order": "^1.0.3",
61+
"textlint-rule-helper": "^2.3.0",
62+
"textlint-rule-no-dead-link": "^5.1.2",
63+
"textlint-rule-no-empty-section": "^1.1.0",
64+
"textlint-rule-no-todo": "^2.0.1",
65+
"textlint-rule-terminology": "^3.0.4",
66+
"textlint-rule-write-good": "^2.0.0",
67+
"write-good": "^1.0.8"
6568
},
6669
"devDependencies": {
6770
"@anolilab/semantic-release-preset": "3.0.0",
@@ -76,22 +79,5 @@
7679
"publishConfig": {
7780
"access": "public",
7881
"provenance": true
79-
},
80-
"pnpm": {
81-
"overrides": {
82-
"glob-parent@<5.1.2": ">=5.1.2",
83-
"minimist@<1.2.6": ">=1.2.6",
84-
"chrono-node@<2.2.4": ">=2.2.4",
85-
"yargs-parser@>=6.0.0 <13.1.2": ">=13.1.2",
86-
"trim@<0.0.3": ">=0.0.3",
87-
"trim-newlines@<3.0.1": ">=3.0.1",
88-
"moment@<2.29.2": ">=2.29.2",
89-
"semver-regex@<3.1.4": ">=3.1.4",
90-
"npm@>=7.9.0 <8.11.0": ">=8.11.0",
91-
"got@<11.8.5": ">=11.8.5",
92-
"moment@>=2.18.0 <2.29.4": ">=2.29.4",
93-
"ansi-regex@>=3.0.0 <3.0.1": ">=3.0.1",
94-
"ansi-regex@>=4.0.0 <4.1.1": ">=4.1.1"
95-
}
9682
}
9783
}

‎packages/textlint-config/project.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
3+
"sourceRoot": "packages/textlint-config/src",
4+
"projectType": "library",
5+
"tags": ["textlint-config"],
6+
"implicitDependencies": []
7+
}

‎packages/textlint-config/skip.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// eslint-disable-next-line no-undef
2+
if (process.env.SKIP_BUILD) {
3+
// eslint-disable-next-line no-undef,unicorn/no-process-exit
4+
process.exit(0);
5+
} else {
6+
// eslint-disable-next-line no-undef,unicorn/no-process-exit
7+
process.exit(1);
8+
}
+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
#!/usr/bin/env node
2+
3+
import { existsSync, writeFile } from "node:fs";
4+
import { join, resolve } from "node:path";
5+
import { promisify } from "node:util";
6+
7+
if (process.env["CI"]) {
8+
// eslint-disable-next-line no-undef
9+
process.exit(0);
10+
}
11+
12+
const writeFileAsync = promisify(writeFile);
13+
14+
// get the path to the host project.
15+
// eslint-disable-next-line no-undef
16+
const projectPath = resolve(process.cwd(), "..", "..", "..");
17+
18+
console.log("Configuring @anolilab/textlint-config", projectPath, "\n");
19+
20+
/**
21+
* Writes .textlintrc if it doesn't exist. Warns if it exists.
22+
*/
23+
const writeTextLintRc = () => {
24+
const filePath = join(projectPath, ".textlintrc");
25+
const content = `{
26+
"@textlint/markdown": {
27+
"extensions": [".md", ".mdx"]
28+
},
29+
"filters": {
30+
"comments": true
31+
},
32+
"rules": {
33+
"en-capitalization": true,
34+
"footnote-order": true,
35+
"no-todo": true,
36+
"no-dead-link": {
37+
"ignore": ["bc_data_*"]
38+
},
39+
"no-empty-section": true,
40+
"terminology": true,
41+
"apostrophe": true,
42+
"diacritics": true,
43+
"@textlint-rule/no-invalid-control-character": true,
44+
"@textlint-rule/no-unmatched-pair": true,
45+
"abbr-within-parentheses": true,
46+
"alex": {
47+
"allow": ["period", "european", "failure", "fore", "attack", "execution", "executed", "remain", "execute"]
48+
},
49+
"@textlint-rule/preset-google": true,
50+
"write-good": {
51+
"passive": false,
52+
"eprime": false
53+
},
54+
"common-misspellings": true,
55+
"terminology": {
56+
"defaultTerms": false,
57+
"terms": [
58+
// Abbreviations
59+
"API",
60+
["API['’]?s", "APIs"],
61+
"Ajax",
62+
"CLI",
63+
"CSS",
64+
"CORS",
65+
["^E2E", "E2E"],
66+
"gif",
67+
["^HTML", "HTML"],
68+
["^URL(s?)", "URL$1"],
69+
["^HTTP", "HTTP"],
70+
["^HTTPS", "HTTPS"],
71+
"SSO",
72+
["^XHR(s?)", "XHR$1"],
73+
["^XHR['’]?s", "XHRs"],
74+
"Xvfb",
75+
"YAML",
76+
77+
// Words and phrases
78+
["\\(s\\)he", "they"],
79+
["he or she", "they"],
80+
["he/she", "they"],
81+
["crazy", "complex"],
82+
["crazier", "more complex"],
83+
["craziest", "most complex"],
84+
["dumb", "unintended"],
85+
["insane", "outrageous"],
86+
87+
// Prefer American spelling
88+
["behaviour", "behavior"],
89+
["cancelled", "canceled"],
90+
["cancelling", "canceling"],
91+
["centre", "center"],
92+
["colour", "color"],
93+
["customise", "customize"],
94+
["customisation", "customization"],
95+
["favourite", "favorite"],
96+
["labelled", "labeled"],
97+
["licence", "license"],
98+
["organise", "organize"],
99+
100+
// Common misspellings
101+
["gaurantee", "guarantee"],
102+
103+
// Words we would like to not use altogether
104+
["simply", ""],
105+
106+
// Single word
107+
["change[- ]log(s?)", "changelog$1"],
108+
["code[- ]base(es?)", "codebase$1"],
109+
["e[- ]mail(s?)", "email$1"],
110+
["end[- ]point(s?)", "endpoint$1"],
111+
["file[- ]name(s?)", "filename$1"],
112+
["can[- ]not", "cannot$1"],
113+
114+
// Multiple words
115+
["back-?end(s?)", "back end$1"],
116+
["front-?end(s?)", "front end$1"],
117+
["full-?stack(s?)", "full stack$1"],
118+
["open-?source(ed?)", "open source$1"],
119+
["web-?page(s?)", "web page$1"],
120+
121+
// Hyphenated
122+
["end ?to ?end", "end-to-end"],
123+
["retryability", "retry-ability"],
124+
["retriability", "retry-ability"],
125+
126+
["some", ""],
127+
["filetype", "file type"],
128+
["stylesheet", "style sheet"],
129+
["like this", ""],
130+
["probably", ""],
131+
["known as", ""],
132+
["really", ""],
133+
["just", ""],
134+
["simple", ""],
135+
["obvious", ""],
136+
["straightforward", ""],
137+
["very", ""],
138+
["a little", ""],
139+
["note that", ""],
140+
["good to note", ""],
141+
["good to remember", ""],
142+
["basically", ""],
143+
["actually", ""],
144+
["pretty", ""],
145+
["easy", ""],
146+
["interesting", ""],
147+
["way to", ""],
148+
["In order to", "To"],
149+
["in order to", "to"],
150+
["might", ""],
151+
["us", ""],
152+
["I'll", ""],
153+
["I've", ""],
154+
["they'll", ""],
155+
["it is", "it's"],
156+
["It is", "It's"]
157+
]
158+
}
159+
}
160+
}
161+
`;
162+
163+
if (existsSync(filePath)) {
164+
console.warn(`⚠️ .textlintrc already exists;
165+
Make sure that it includes the following for @anolilab/textlint-config'
166+
to work as it should: ${content}.`);
167+
168+
return Promise.resolve();
169+
}
170+
171+
return writeFileAsync(filePath, content, "utf-8");
172+
};
173+
174+
/**
175+
* Writes .textlintignore if it doesn't exist. Warns if it exists.
176+
*/
177+
const writeTextLintIgnore = () => {
178+
const filePath = join(projectPath, ".textlintignore");
179+
const content = "";
180+
181+
if (existsSync(filePath)) {
182+
console.warn("⚠️ .textlintignore already exists;");
183+
184+
return Promise.resolve();
185+
}
186+
187+
return writeFileAsync(filePath, content, "utf-8");
188+
};
189+
190+
// eslint-disable-next-line unicorn/prefer-top-level-await
191+
(async () => {
192+
try {
193+
await writeTextLintRc();
194+
await writeTextLintIgnore();
195+
196+
console.log("😎 Everything went well, have fun!");
197+
198+
// eslint-disable-next-line no-undef
199+
process.exit(0);
200+
} catch (error) {
201+
console.log("😬 something went wrong:");
202+
console.error(error);
203+
204+
// eslint-disable-next-line no-undef
205+
process.exit(1);
206+
}
207+
})();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "./tsconfig.json"
3+
}
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"display": "Node 16",
4+
"extends": "../../tsconfig.json",
5+
"baseUrl": "./",
6+
"include": ["src/**/*", "*.d.ts"]
7+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { createConfig } from "../../tsup.config";
2+
3+
const config = createConfig();
4+
5+
export default config;

‎pnpm-lock.yaml

+24-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.