@textmode/lint 0.1.3 → 0.2.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/LICENSE CHANGED
@@ -1,121 +1,21 @@
1
- Creative Commons Legal Code
2
-
3
- CC0 1.0 Universal
4
-
5
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
- HEREUNDER.
13
-
14
- Statement of Purpose
15
-
16
- The laws of most jurisdictions throughout the world automatically confer
17
- exclusive Copyright and Related Rights (defined below) upon the creator
18
- and subsequent owner(s) (each and all, an "owner") of an original work of
19
- authorship and/or a database (each, a "Work").
20
-
21
- Certain owners wish to permanently relinquish those rights to a Work for
22
- the purpose of contributing to a commons of creative, cultural and
23
- scientific works ("Commons") that the public can reliably and without fear
24
- of later claims of infringement build upon, modify, incorporate in other
25
- works, reuse and redistribute as freely as possible in any form whatsoever
26
- and for any purposes, including without limitation commercial purposes.
27
- These owners may contribute to the Commons to promote the ideal of a free
28
- culture and the further production of creative, cultural and scientific
29
- works, or to gain reputation or greater distribution for their Work in
30
- part through the use and efforts of others.
31
-
32
- For these and/or other purposes and motivations, and without any
33
- expectation of additional consideration or compensation, the person
34
- associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
- is an owner of Copyright and Related Rights in the Work, voluntarily
36
- elects to apply CC0 to the Work and publicly distribute the Work under its
37
- terms, with knowledge of his or her Copyright and Related Rights in the
38
- Work and the meaning and intended legal effect of CC0 on those rights.
39
-
40
- 1. Copyright and Related Rights. A Work made available under CC0 may be
41
- protected by copyright and related or neighboring rights ("Copyright and
42
- Related Rights"). Copyright and Related Rights include, but are not
43
- limited to, the following:
44
-
45
- i. the right to reproduce, adapt, distribute, perform, display,
46
- communicate, and translate a Work;
47
- ii. moral rights retained by the original author(s) and/or performer(s);
48
- iii. publicity and privacy rights pertaining to a person's image or
49
- likeness depicted in a Work;
50
- iv. rights protecting against unfair competition in regards to a Work,
51
- subject to the limitations in paragraph 4(a), below;
52
- v. rights protecting the extraction, dissemination, use and reuse of data
53
- in a Work;
54
- vi. database rights (such as those arising under Directive 96/9/EC of the
55
- European Parliament and of the Council of 11 March 1996 on the legal
56
- protection of databases, and under any national implementation
57
- thereof, including any amended or successor version of such
58
- directive); and
59
- vii. other similar, equivalent or corresponding rights throughout the
60
- world based on applicable law or treaty, and any national
61
- implementations thereof.
62
-
63
- 2. Waiver. To the greatest extent permitted by, but not in contravention
64
- of, applicable law, Affirmer hereby overtly, fully, permanently,
65
- irrevocably and unconditionally waives, abandons, and surrenders all of
66
- Affirmer's Copyright and Related Rights and associated claims and causes
67
- of action, whether now known or unknown (including existing as well as
68
- future claims and causes of action), in the Work (i) in all territories
69
- worldwide, (ii) for the maximum duration provided by applicable law or
70
- treaty (including future time extensions), (iii) in any current or future
71
- medium and for any number of copies, and (iv) for any purpose whatsoever,
72
- including without limitation commercial, advertising or promotional
73
- purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
- member of the public at large and to the detriment of Affirmer's heirs and
75
- successors, fully intending that such Waiver shall not be subject to
76
- revocation, rescission, cancellation, termination, or any other legal or
77
- equitable action to disrupt the quiet enjoyment of the Work by the public
78
- as contemplated by Affirmer's express Statement of Purpose.
79
-
80
- 3. Public License Fallback. Should any part of the Waiver for any reason
81
- be judged legally invalid or ineffective under applicable law, then the
82
- Waiver shall be preserved to the maximum extent permitted taking into
83
- account Affirmer's express Statement of Purpose. In addition, to the
84
- extent the Waiver is so judged Affirmer hereby grants to each affected
85
- person a royalty-free, non transferable, non sublicensable, non exclusive,
86
- irrevocable and unconditional license to exercise Affirmer's Copyright and
87
- Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
- maximum duration provided by applicable law or treaty (including future
89
- time extensions), (iii) in any current or future medium and for any number
90
- of copies, and (iv) for any purpose whatsoever, including without
91
- limitation commercial, advertising or promotional purposes (the
92
- "License"). The License shall be deemed effective as of the date CC0 was
93
- applied by Affirmer to the Work. Should any part of the License for any
94
- reason be judged legally invalid or ineffective under applicable law, such
95
- partial invalidity or ineffectiveness shall not invalidate the remainder
96
- of the License, and in such case Affirmer hereby affirms that he or she
97
- will not (i) exercise any of his or her remaining Copyright and Related
98
- Rights in the Work or (ii) assert any associated claims and causes of
99
- action with respect to the Work, in either case contrary to Affirmer's
100
- express Statement of Purpose.
101
-
102
- 4. Limitations and Disclaimers.
103
-
104
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
- surrendered, licensed or otherwise affected by this document.
106
- b. Affirmer offers the Work as-is and makes no representations or
107
- warranties of any kind concerning the Work, express, implied,
108
- statutory or otherwise, including without limitation warranties of
109
- title, merchantability, fitness for a particular purpose, non
110
- infringement, or the absence of latent or other defects, accuracy, or
111
- the present or absence of errors, whether or not discoverable, all to
112
- the greatest extent permissible under applicable law.
113
- c. Affirmer disclaims responsibility for clearing rights of other persons
114
- that may apply to the Work or any use thereof, including without
115
- limitation any person's Copyright and Related Rights in the Work.
116
- Further, Affirmer disclaims responsibility for obtaining any necessary
117
- consents, permissions or other rights required for any use of the
118
- Work.
119
- d. Affirmer understands and acknowledges that Creative Commons is not a
120
- party to this document and has no duty or obligation with respect to
121
- this CC0 or use of the Work.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 humanbydefinition
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  <div align="center">
4
4
 
5
- <img alt="@textmode/lint — lint textmode everywhere" src=".github/assets/readme-og.png" />
5
+ <img alt="@textmode/lint — lint textmode everywhere" src="../../.github/assets/readme-og-lint.png" />
6
6
 
7
- | [![JavaScript](https://img.shields.io/badge/JavaScript-F7DF1E?logo=javascript&logoColor=black)](https://developer.mozilla.org/en-US/docs/Web/JavaScript) [![ESLint](https://img.shields.io/badge/ESLint-4B32C3?logo=eslint&logoColor=white)](https://eslint.org/) [![Prettier](https://img.shields.io/badge/Prettier-F7B93E?logo=prettier&logoColor=black)](https://prettier.io/) [![markdownlint](https://img.shields.io/badge/markdownlint-000000?logo=markdownlint&logoColor=white)](https://github.com/DavidAnson/markdownlint) | [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/) [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) | [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![GitHub-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
7
+ | [![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![ESLint](https://img.shields.io/badge/ESLint-4B32C3?logo=eslint&logoColor=white)](https://eslint.org/) [![Prettier](https://img.shields.io/badge/Prettier-F7B93E?logo=prettier&logoColor=black)](https://prettier.io/) [![markdownlint](https://img.shields.io/badge/markdownlint-000000?logo=markdownlint&logoColor=white)](https://github.com/DavidAnson/markdownlint) | [![docs](https://img.shields.io/badge/docs-vitepress-646cff?logo=vitepress&logoColor=white)](https://code.textmode.art/) [![Discord](https://img.shields.io/discord/1357070706181017691?color=5865F2&label=Discord&logo=discord&logoColor=white)](https://discord.gg/sjrw8QXNks) | [![ko-fi](https://shields.io/badge/ko--fi-donate-ff5f5f?logo=ko-fi)](https://ko-fi.com/V7V8JG2FY) [![GitHub-sponsors](https://img.shields.io/badge/sponsor-30363D?logo=GitHub-Sponsors&logoColor=#EA4AAA)](https://github.com/sponsors/humanbydefinition) |
8
8
  | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
9
9
 
10
10
  </div>
@@ -66,24 +66,26 @@ textmode-lint check
66
66
  - `lint:markdown` lints Markdown with markdownlint-cli2.
67
67
  - `check` runs `format:check`, `lint`, and `lint:markdown` in order and stops at the first failure.
68
68
 
69
- Every argument after the command is forwarded to the underlying engine, so
70
- `textmode-lint lint --fix`, `textmode-lint lint src tests`, and
71
- `textmode-lint lint:markdown --fix` work without special handling.
69
+ Use `textmode-lint --help` or `textmode-lint --version` for the wrapper.
70
+ Use `--cwd <directory>` to set the working directory. Engine commands forward
71
+ their options to the engine, including `--help` after the command name and
72
+ `--fix` where supported. The `check` command takes no engine arguments.
72
73
 
73
- Every command accepts `--cwd <directory>`, `--help`, and `--version`. Exit
74
- status `0` means success, `1` means the engine reported a problem, and `2`
75
- means the invocation was invalid.
74
+ Exit status `0` means success, `1` means the engine reported a problem, and
75
+ `2` means the invocation was invalid or the engine could not start.
76
76
 
77
77
  ## Configuration
78
78
 
79
79
  ### ESLint
80
80
 
81
- Re-export the shared flat config from `eslint.config.js`:
81
+ Re-export the browser flat config from `eslint.config.js`:
82
82
 
83
83
  ```js
84
84
  export { default } from '@textmode/lint';
85
85
  ```
86
86
 
87
+ For Node.js tooling, import the preset from `@textmode/lint/node`.
88
+
87
89
  To extend the shared config, compose it into a local flat config array:
88
90
 
89
91
  ```js
@@ -129,23 +131,23 @@ and formatter). A project can override or extend it with its own
129
131
 
130
132
  `@textmode/lint` works with the following textmode-tooling packages:
131
133
 
132
- | Package | Relationship |
133
- | --------------------------------------------- | -------------------------------------------------------------------------------------- |
134
- | [`@textmode/release`](../release/README.md) | `textmode-release format-staged` uses `@textmode/lint` for the shared `pre-commit` hook |
135
- | [`@textmode/tsconfig`](../tsconfig/README.md) | Consumers commonly run type checks alongside lint checks in local package scripts |
134
+ | Package | Relationship |
135
+ | --- | --- |
136
+ | [`@textmode/release`](https://github.com/textmode-art/tooling/tree/main/packages/release) | `textmode-release format-staged` uses `@textmode/lint` for the shared `pre-commit` hook |
137
+ | [`@textmode/tsconfig`](https://github.com/textmode-art/tooling/tree/main/packages/tsconfig) | Consumers commonly run type checks alongside lint checks in local package scripts |
136
138
 
137
139
  ## License
138
140
 
139
- The `@textmode/lint` package is licensed under the [CC0 1.0 Universal](./LICENSE).
141
+ The `@textmode/lint` package is licensed under the [MIT License](https://github.com/textmode-art/tooling/blob/main/LICENSE).
140
142
 
141
143
  ## Acknowledgements
142
144
 
143
145
  - **[ESLint](https://eslint.org/)**
144
- - The linter behind `textmode-lint lint`.
145
- - License: [MIT](https://github.com/eslint/eslint/blob/main/LICENSE).
146
+ - The linter behind `textmode-lint lint`.
147
+ - License: [MIT](https://github.com/eslint/eslint/blob/main/LICENSE).
146
148
  - **[Prettier](https://prettier.io/)**
147
- - The formatter behind `textmode-lint format` and `format:check`.
148
- - License: [MIT](https://github.com/prettier/prettier/blob/main/LICENSE).
149
+ - The formatter behind `textmode-lint format` and `format:check`.
150
+ - License: [MIT](https://github.com/prettier/prettier/blob/main/LICENSE).
149
151
  - **[markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2)**
150
- - The Markdown linter behind `textmode-lint lint:markdown`.
151
- - License: [MIT](https://github.com/DavidAnson/markdownlint-cli2/blob/main/LICENSE).
152
+ - The Markdown linter behind `textmode-lint lint:markdown`.
153
+ - License: [MIT](https://github.com/DavidAnson/markdownlint-cli2/blob/main/LICENSE).
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=textmode-lint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textmode-lint.d.ts","sourceRoot":"","sources":["../../src/cli/textmode-lint.ts"],"names":[],"mappings":""}
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import process from 'node:process';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { runEngine } from '../internal/engines.js';
7
+ const PACKAGE_JSON = JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
8
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
9
+ const COMMANDS = new Set(['lint', 'format', 'format:check', 'lint:markdown', 'check']);
10
+ const ESLINT_CONFIG_FILES = [
11
+ 'eslint.config.js',
12
+ 'eslint.config.mjs',
13
+ 'eslint.config.cjs',
14
+ 'eslint.config.ts',
15
+ 'eslint.config.mts',
16
+ 'eslint.config.cts',
17
+ ];
18
+ function printGeneralHelp() {
19
+ console.log(`@textmode/lint ${PACKAGE_JSON.version}`);
20
+ console.log('');
21
+ console.log('Usage: textmode-lint <command> [options] [targets...]');
22
+ console.log('');
23
+ console.log('Commands:');
24
+ console.log(' lint [targets...] Run ESLint (default target: .)');
25
+ console.log(' format [targets...] Format files with Prettier in place (default target: .)');
26
+ console.log(' format:check [targets...] Check files with Prettier (default target: .)');
27
+ console.log(' lint:markdown [--fix] Lint Markdown with markdownlint-cli2');
28
+ console.log(' check Run format:check, lint, and lint:markdown in order');
29
+ console.log('');
30
+ console.log('Common options:');
31
+ console.log(' --cwd <directory> Directory to run the engine in');
32
+ console.log(' --help, -h Show help');
33
+ console.log(' --version, -v Show version');
34
+ console.log('');
35
+ console.log('Every argument after the command is forwarded to the underlying engine.');
36
+ }
37
+ function printCommandHelp(command) {
38
+ const usage = {
39
+ lint: 'textmode-lint lint [targets...]',
40
+ format: 'textmode-lint format [targets...]',
41
+ 'format:check': 'textmode-lint format:check [targets...]',
42
+ 'lint:markdown': 'textmode-lint lint:markdown [--fix]',
43
+ check: 'textmode-lint check',
44
+ };
45
+ console.log(`Usage: ${usage[command]}`);
46
+ }
47
+ function hasLocalEslintConfig(cwd) {
48
+ return ESLINT_CONFIG_FILES.some((file) => fs.existsSync(path.join(cwd, file)));
49
+ }
50
+ function parseLintArguments(argv) {
51
+ const values = {
52
+ cwd: undefined,
53
+ help: false,
54
+ version: false,
55
+ };
56
+ const rest = [];
57
+ let commandSeen = false;
58
+ for (let index = 0; index < argv.length; index += 1) {
59
+ const arg = argv[index];
60
+ if (arg === '--cwd') {
61
+ if (index + 1 >= argv.length || argv[index + 1].startsWith('-')) {
62
+ throw new Error('--cwd requires a directory value.');
63
+ }
64
+ values.cwd = argv[index + 1];
65
+ index += 1;
66
+ continue;
67
+ }
68
+ if (!commandSeen) {
69
+ if (arg === '--help' || arg === '-h') {
70
+ values.help = true;
71
+ continue;
72
+ }
73
+ if (arg === '--version' || arg === '-v') {
74
+ values.version = true;
75
+ continue;
76
+ }
77
+ if (!arg.startsWith('-')) {
78
+ commandSeen = true;
79
+ }
80
+ }
81
+ rest.push(arg);
82
+ }
83
+ const [rawCommand, ...forwarded] = rest;
84
+ if (rawCommand !== undefined && !COMMANDS.has(rawCommand)) {
85
+ throw new Error(`Unknown command "${rawCommand}".`);
86
+ }
87
+ const command = rawCommand;
88
+ if (command === 'check' && forwarded.length > 0) {
89
+ throw new Error('The check command does not accept arguments.');
90
+ }
91
+ return { command, forwarded, values };
92
+ }
93
+ function buildPrettierBaseArgs(cwd, check) {
94
+ const args = [check ? '--check' : '--write', '--config', path.join(PACKAGE_ROOT, 'prettier.json')];
95
+ if (!fs.existsSync(path.join(cwd, '.prettierignore'))) {
96
+ args.push('--ignore-path', path.join(PACKAGE_ROOT, '.prettierignore'));
97
+ }
98
+ args.push('--ignore-unknown');
99
+ return args;
100
+ }
101
+ function resolveLintEngineInvocation(command, forwarded, cwd) {
102
+ switch (command) {
103
+ case 'lint': {
104
+ const hasExplicitConfig = forwarded.some((arg) => arg === '--config' || arg === '-c');
105
+ // Use the shared config when the caller and the project have no ESLint config.
106
+ const configArgs = hasExplicitConfig || hasLocalEslintConfig(cwd)
107
+ ? []
108
+ : ['--config', path.join(PACKAGE_ROOT, 'dist', 'index.js')];
109
+ const hasTarget = forwarded.some((arg) => !arg.startsWith('-'));
110
+ return { engine: 'eslint', args: [...configArgs, ...forwarded, ...(hasTarget ? [] : ['.'])] };
111
+ }
112
+ case 'format':
113
+ case 'format:check':
114
+ return {
115
+ engine: 'prettier',
116
+ args: [
117
+ ...buildPrettierBaseArgs(cwd, command === 'format:check'),
118
+ ...(forwarded.length > 0 ? forwarded : ['.']),
119
+ ],
120
+ };
121
+ case 'lint:markdown': {
122
+ const hasTarget = forwarded.some((arg) => !arg.startsWith('-'));
123
+ const args = ['--config', path.join(PACKAGE_ROOT, 'markdownlint-cli2.jsonc'), ...forwarded];
124
+ if (!hasTarget) {
125
+ args.push('**/*.md');
126
+ }
127
+ return { engine: 'markdownlint-cli2', args };
128
+ }
129
+ }
130
+ }
131
+ function main(argv) {
132
+ let parsed;
133
+ try {
134
+ parsed = parseLintArguments(argv);
135
+ }
136
+ catch (error) {
137
+ console.error(error instanceof Error ? error.message : String(error));
138
+ return 2;
139
+ }
140
+ const { command, forwarded, values } = parsed;
141
+ const cwd = values.cwd ? path.resolve(values.cwd) : process.cwd();
142
+ if (values.version && command === undefined) {
143
+ console.log(PACKAGE_JSON.version);
144
+ return 0;
145
+ }
146
+ if (values.help && command === undefined) {
147
+ printGeneralHelp();
148
+ return 0;
149
+ }
150
+ if (command === undefined) {
151
+ console.error('Missing command. Run textmode-lint --help for usage.');
152
+ return 2;
153
+ }
154
+ if (values.help) {
155
+ printCommandHelp(command);
156
+ return 0;
157
+ }
158
+ if (command === 'check') {
159
+ for (const step of ['format:check', 'lint', 'lint:markdown']) {
160
+ console.log(`\n[textmode-lint] ${step}`);
161
+ const { engine, args } = resolveLintEngineInvocation(step, [], cwd);
162
+ const status = runEngine(engine, args, { cwd });
163
+ if (status !== 0) {
164
+ return status;
165
+ }
166
+ }
167
+ return 0;
168
+ }
169
+ const { engine, args } = resolveLintEngineInvocation(command, forwarded, cwd);
170
+ return runEngine(engine, args, { cwd });
171
+ }
172
+ process.exitCode = main(process.argv.slice(2));
173
+ //# sourceMappingURL=textmode-lint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textmode-lint.js","sourceRoot":"","sources":["../../src/cli/textmode-lint.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAuB,MAAM,wBAAwB,CAAC;AAExE,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAA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BAA2B,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC;IAC9E,OAAO,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;AACzC,CAAC;AAED,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shared ESLint flat configurations for the `textmode.js` ecosystem.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { Linter } from 'eslint';
7
+ /**
8
+ * Target runtime environment for {@link createLintConfig}.
9
+ */
10
+ export type LintEnvironment = 'browser' | 'node';
11
+ /**
12
+ * Configuration options for {@link createLintConfig}.
13
+ */
14
+ export interface CreateLintConfigOptions {
15
+ /** Runtime globals preset to apply. Defaults to `'browser'`. */
16
+ environment?: LintEnvironment;
17
+ /** File glob patterns checked by the preset. */
18
+ files?: string[];
19
+ /** Additional directory or file ignore patterns. */
20
+ ignores?: string[];
21
+ /** Optional ESLint rule overrides merged into the base config. */
22
+ rules?: Linter.RulesRecord;
23
+ }
24
+ /**
25
+ * Create a composed ESLint flat configuration for browser libraries or Node.js tooling.
26
+ *
27
+ * @param options - Optional environment, glob, ignore, and rule overrides.
28
+ * @returns ESLint flat configuration array.
29
+ * @example
30
+ * ```ts
31
+ * import { createLintConfig } from '@textmode/lint';
32
+ *
33
+ * export default createLintConfig({ environment: 'node' });
34
+ * ```
35
+ */
36
+ export declare function createLintConfig(options?: CreateLintConfigOptions): Linter.Config[];
37
+ /**
38
+ * Default ESLint flat configuration for `textmode.js` browser libraries.
39
+ */
40
+ declare const config: Linter.Config[];
41
+ export default config;
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,MAAM,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,gEAAgE;IAChE,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,kEAAkE;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;CAC3B;AAoBD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,uBAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,CA2BvF;AAED;;GAEG;AACH,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,MAAM,EAAiD,CAAC;AAE7E,eAAe,MAAM,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Shared ESLint flat configurations for the `textmode.js` ecosystem.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import js from '@eslint/js';
7
+ import { defineConfig } from 'eslint/config';
8
+ import jsdoc from 'eslint-plugin-jsdoc';
9
+ import globals from 'globals';
10
+ import tseslint from 'typescript-eslint';
11
+ const DEFAULT_IGNORES = ['dist', 'node_modules', 'coverage', 'docs', 'api'];
12
+ const SHARED_RULES = {
13
+ 'jsdoc/require-jsdoc': 'off',
14
+ 'jsdoc/require-description': 'warn',
15
+ 'jsdoc/check-values': 'error',
16
+ 'jsdoc/check-param-names': 'error',
17
+ 'jsdoc/check-tag-names': 'error',
18
+ 'jsdoc/check-types': 'off',
19
+ 'jsdoc/no-undefined-types': 'off',
20
+ 'jsdoc/require-returns': 'off',
21
+ 'jsdoc/require-param': 'off',
22
+ 'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
23
+ '@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],
24
+ '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
25
+ '@typescript-eslint/no-explicit-any': 'warn',
26
+ };
27
+ /**
28
+ * Create a composed ESLint flat configuration for browser libraries or Node.js tooling.
29
+ *
30
+ * @param options - Optional environment, glob, ignore, and rule overrides.
31
+ * @returns ESLint flat configuration array.
32
+ * @example
33
+ * ```ts
34
+ * import { createLintConfig } from '@textmode/lint';
35
+ *
36
+ * export default createLintConfig({ environment: 'node' });
37
+ * ```
38
+ */
39
+ export function createLintConfig(options = {}) {
40
+ const environment = options.environment ?? 'browser';
41
+ const files = options.files ?? (environment === 'node' ? ['**/*.{ts,mts,cts,js,mjs,cjs}'] : ['src/**/*.{ts,mts,js,mjs}']);
42
+ const ignores = [...new Set([...DEFAULT_IGNORES, ...(options.ignores ?? [])])];
43
+ return defineConfig({
44
+ ignores,
45
+ }, {
46
+ extends: [
47
+ js.configs.recommended,
48
+ ...tseslint.configs.recommended,
49
+ jsdoc.configs['flat/recommended-typescript'],
50
+ ],
51
+ files,
52
+ languageOptions: {
53
+ ecmaVersion: environment === 'node' ? 2022 : 2020,
54
+ globals: environment === 'node' ? globals.node : globals.browser,
55
+ },
56
+ rules: {
57
+ ...SHARED_RULES,
58
+ ...(options.rules ?? {}),
59
+ },
60
+ });
61
+ }
62
+ /**
63
+ * Default ESLint flat configuration for `textmode.js` browser libraries.
64
+ */
65
+ const config = createLintConfig({ environment: 'browser' });
66
+ export default config;
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,QAAQ,MAAM,mBAAmB,CAAC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;YAC/B,KAAK,CAAC,OAAO,CAAC,6BAA6B,CAAC;SAC5C;QACD,KAAK;QACL,eAAe,EAAE;YAChB,WAAW,EAAE,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;YACjD,OAAO,EAAE,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO;SAChE;QACD,KAAK,EAAE;YACN,GAAG,YAAY;YACf,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;SACxB;KACD,CACD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,MAAM,GAAoB,gBAAgB,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC;AAE7E,eAAe,MAAM,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type LintEngineName = 'eslint' | 'prettier' | 'markdownlint-cli2';
2
+ /** Run the package-owned engine with the supplied arguments and working directory. */
3
+ export declare function runEngine(name: LintEngineName, args: string[], { cwd }?: {
4
+ cwd?: string;
5
+ }): number;
6
+ //# sourceMappingURL=engines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engines.d.ts","sourceRoot":"","sources":["../../src/internal/engines.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,mBAAmB,CAAC;AAEzE,sFAAsF;AACtF,wBAAgB,SAAS,CACxB,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,GAAmB,EAAE,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5C,MAAM,CAiBR"}
@@ -0,0 +1,22 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import { findPackageJSON } from 'node:module';
4
+ import path from 'node:path';
5
+ /** Run the package-owned engine with the supplied arguments and working directory. */
6
+ export function runEngine(name, args, { cwd = process.cwd() } = {}) {
7
+ const manifestPath = findPackageJSON(name, import.meta.url);
8
+ if (!manifestPath)
9
+ throw new Error(`Cannot resolve ${name}.`);
10
+ const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
11
+ const bin = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin?.[name];
12
+ if (typeof bin !== 'string')
13
+ throw new Error(`Cannot resolve ${name} binary ${name}.`);
14
+ const entry = path.resolve(path.dirname(manifestPath), bin);
15
+ const result = spawnSync(process.execPath, [entry, ...args], { cwd, stdio: 'inherit' });
16
+ if (result.error) {
17
+ console.error(`Unable to run ${name}: ${result.error.message}`);
18
+ return 2;
19
+ }
20
+ return result.status ?? 1;
21
+ }
22
+ //# sourceMappingURL=engines.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engines.js","sourceRoot":"","sources":["../../src/internal/engines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,sFAAsF;AACtF,MAAM,UAAU,SAAS,CACxB,IAAoB,EACpB,IAAc,EACd,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,KAAuB,EAAE;IAE9C,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5D,IAAI,CAAC,YAAY;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,GAAG,CAAC,CAAC;IAE9D,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAEhE,CAAC;IACF,MAAM,GAAG,GAAG,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;IACnF,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,WAAW,IAAI,GAAG,CAAC,CAAC;IAEvF,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IACxF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAClB,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAChE,OAAO,CAAC,CAAC;IACV,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;AAC3B,CAAC"}
package/dist/node.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared ESLint flat configuration preset for Node.js tooling packages.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import type { Linter } from 'eslint';
7
+ /**
8
+ * Default ESLint flat configuration for Node.js tooling repositories.
9
+ */
10
+ declare const nodeConfig: Linter.Config[];
11
+ export default nodeConfig;
12
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIrC;;GAEG;AACH,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAA8C,CAAC;AAE9E,eAAe,UAAU,CAAC"}
package/dist/node.js ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared ESLint flat configuration preset for Node.js tooling packages.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ import { createLintConfig } from './index.js';
7
+ /**
8
+ * Default ESLint flat configuration for Node.js tooling repositories.
9
+ */
10
+ const nodeConfig = createLintConfig({ environment: 'node' });
11
+ export default nodeConfig;
12
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,MAAM,UAAU,GAAoB,gBAAgB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;AAE9E,eAAe,UAAU,CAAC"}
@@ -6,9 +6,12 @@
6
6
  "globs": ["**/*.md"],
7
7
  "ignores": [
8
8
  "node_modules/**",
9
+ "**/node_modules/**",
9
10
  ".output/**",
10
11
  ".wxt/**",
11
12
  "dist/**",
13
+ "**/dist/**",
14
+ "docs/api/**",
12
15
  "api/**",
13
16
  "coverage/**",
14
17
  "test-results/**",
@@ -17,7 +20,6 @@
17
20
  ],
18
21
  "noBanner": true,
19
22
  "noProgress": true,
20
- "outputFormatters": [["markdownlint-cli2-formatter-default"]],
21
23
  "config": {
22
24
  "default": true,
23
25
  "MD003": {
package/package.json CHANGED
@@ -1,76 +1,73 @@
1
1
  {
2
- "name": "@textmode/lint",
3
- "version": "0.1.3",
4
- "type": "module",
5
- "license": "CC0-1.0",
6
- "description": "Shared linting and formatting for the textmode.js ecosystem (ESLint, Prettier, markdownlint-cli2).",
7
- "keywords": [
8
- "textmode",
9
- "eslint",
10
- "prettier",
11
- "markdownlint",
12
- "lint",
13
- "format"
14
- ],
15
- "author": "humanbydefinition <hello@textmode.art> (https://code.textmode.art)",
16
- "homepage": "https://code.textmode.art",
17
- "repository": {
18
- "type": "git",
19
- "url": "git+https://github.com/textmode-art/tooling.git",
20
- "directory": "packages/lint"
21
- },
22
- "engines": {
23
- "node": ">=24 <25"
24
- },
25
- "bin": {
26
- "textmode-lint": "src/cli/textmode-lint.mjs"
27
- },
28
- "exports": {
29
- ".": {
30
- "types": "./index.d.ts",
31
- "import": "./index.js"
32
- },
33
- "./eslint": {
34
- "types": "./index.d.ts",
35
- "import": "./index.js"
36
- },
37
- "./prettier": "./prettier.json",
38
- "./markdownlint": "./markdownlint-cli2.jsonc",
39
- "./package.json": "./package.json"
40
- },
41
- "files": [
42
- "src",
43
- "index.js",
44
- "index.d.ts",
45
- "prettier.json",
46
- ".prettierignore",
47
- "markdownlint-cli2.jsonc",
48
- "README.md"
49
- ],
50
- "dependencies": {
51
- "@eslint/js": "^10.0.1",
52
- "eslint": "^10.14.0",
53
- "eslint-plugin-jsdoc": "^65.4.5",
54
- "globals": "^17.14.0",
55
- "markdownlint-cli2": "^0.24.0",
56
- "markdownlint-cli2-formatter-default": "^0.0.6",
57
- "prettier": "^3.9.10",
58
- "typescript-eslint": "^8.72.1"
59
- },
60
- "devDependencies": {
61
- "@types/node": "^26.6.6",
62
- "typescript": "^6.0.3",
63
- "vitest": "^5.1.0"
64
- },
65
- "scripts": {
66
- "check": "pnpm run check:format && pnpm run lint && pnpm run test && pnpm run check:package && pnpm run check:pack",
67
- "check:format": "prettier --check .",
68
- "check:package": "node scripts/check-package.mjs",
69
- "check:pack": "node scripts/pack-smoke.mjs",
70
- "lint": "node --check src/cli/textmode-lint.mjs && node --check src/internal/engines.mjs",
71
- "test": "vitest run"
72
- },
73
- "publishConfig": {
74
- "access": "public"
75
- }
76
- }
2
+ "name": "@textmode/lint",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Shared linting and formatting for the textmode.js ecosystem (ESLint, Prettier, markdownlint-cli2).",
7
+ "keywords": [
8
+ "textmode",
9
+ "eslint",
10
+ "prettier",
11
+ "markdownlint",
12
+ "lint",
13
+ "format"
14
+ ],
15
+ "author": "humanbydefinition <hello@textmode.art> (https://code.textmode.art)",
16
+ "homepage": "https://code.textmode.art",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/textmode-art/tooling.git",
20
+ "directory": "packages/lint"
21
+ },
22
+ "engines": {
23
+ "node": "^24.15.0 || >=26.0.0"
24
+ },
25
+ "bin": {
26
+ "textmode-lint": "dist/cli/textmode-lint.js"
27
+ },
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./eslint": {
34
+ "types": "./dist/index.d.ts",
35
+ "import": "./dist/index.js"
36
+ },
37
+ "./node": {
38
+ "types": "./dist/node.d.ts",
39
+ "import": "./dist/node.js"
40
+ },
41
+ "./prettier": "./prettier.json",
42
+ "./markdownlint": "./markdownlint-cli2.jsonc",
43
+ "./package.json": "./package.json"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "prettier.json",
48
+ ".prettierignore",
49
+ "markdownlint-cli2.jsonc",
50
+ "README.md"
51
+ ],
52
+ "dependencies": {
53
+ "@eslint/js": "^10.0.1",
54
+ "eslint": "^10.14.0",
55
+ "eslint-plugin-jsdoc": "^65.4.5",
56
+ "globals": "^17.14.0",
57
+ "markdownlint-cli2": "^0.24.0",
58
+ "prettier": "^3.9.10",
59
+ "typescript-eslint": "^8.72.1"
60
+ },
61
+ "devDependencies": {
62
+ "@types/node": "^24.0.0",
63
+ "typescript": "^6.0.3",
64
+ "vitest": "^5.1.0"
65
+ },
66
+ "publishConfig": {
67
+ "access": "public"
68
+ },
69
+ "scripts": {
70
+ "build": "tsc -b",
71
+ "test": "vitest run"
72
+ }
73
+ }
package/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { Linter } from 'eslint';
2
-
3
- declare const config: Linter.Config[];
4
- export default config;
package/index.js DELETED
@@ -1,41 +0,0 @@
1
- import { defineConfig } from 'eslint/config';
2
- import js from '@eslint/js';
3
- import globals from 'globals';
4
- import jsdoc from 'eslint-plugin-jsdoc';
5
- import tseslint from 'typescript-eslint';
6
-
7
- export default defineConfig(
8
- {
9
- ignores: ['dist', 'node_modules', 'coverage', 'docs', 'api'],
10
- },
11
- {
12
- extends: [
13
- js.configs.recommended,
14
- ...tseslint.configs.recommended,
15
- jsdoc.configs['flat/recommended-typescript'],
16
- ],
17
- files: ['src/**/*.{ts,js}'],
18
- languageOptions: {
19
- ecmaVersion: 2020,
20
- globals: globals.browser,
21
- },
22
- plugins: {
23
- jsdoc,
24
- },
25
- rules: {
26
- 'jsdoc/require-jsdoc': 'off',
27
- 'jsdoc/require-description': 'warn',
28
- 'jsdoc/check-values': 'error',
29
- 'jsdoc/check-param-names': 'error',
30
- 'jsdoc/check-tag-names': 'error',
31
- 'jsdoc/check-types': 'off',
32
- 'jsdoc/no-undefined-types': 'off',
33
- 'jsdoc/require-returns': 'off',
34
- 'jsdoc/require-param': 'off',
35
- 'jsdoc/tag-lines': ['warn', 'any', { startLines: 1 }],
36
- '@typescript-eslint/no-empty-object-type': ['error', { allowInterfaces: 'with-single-extends' }],
37
- '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
38
- '@typescript-eslint/no-explicit-any': 'warn',
39
- },
40
- }
41
- );
@@ -1,161 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'node:fs';
4
- import path from 'node:path';
5
- import process from 'node:process';
6
- import { fileURLToPath } from 'node:url';
7
-
8
- import { runEngine } from '../internal/engines.mjs';
9
-
10
- const PACKAGE_JSON = JSON.parse(fs.readFileSync(new URL('../../package.json', import.meta.url), 'utf8'));
11
- const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
12
-
13
- const COMMANDS = new Set(['lint', 'format', 'format:check', 'lint:markdown', 'check']);
14
-
15
- function printGeneralHelp() {
16
- console.log(`@textmode/lint ${PACKAGE_JSON.version}`);
17
- console.log('');
18
- console.log('Usage: textmode-lint <command> [options] [targets...]');
19
- console.log('');
20
- console.log('Commands:');
21
- console.log(' lint [targets...] Run ESLint (default target: .)');
22
- console.log(' format [targets...] Format files with Prettier in place (default target: .)');
23
- console.log(' format:check [targets...] Check files with Prettier (default target: .)');
24
- console.log(' lint:markdown [--fix] Lint Markdown with markdownlint-cli2');
25
- console.log(' check Run format:check, lint, and lint:markdown in order');
26
- console.log('');
27
- console.log('Common options:');
28
- console.log(' --cwd <directory> Directory to run the engine in');
29
- console.log(' --help, -h Show help');
30
- console.log(' --version, -v Show version');
31
- console.log('');
32
- console.log('Every argument after the command is forwarded to the underlying engine.');
33
- }
34
-
35
- function printCommandHelp(command) {
36
- const usage = {
37
- lint: 'textmode-lint lint [targets...]',
38
- format: 'textmode-lint format [targets...]',
39
- 'format:check': 'textmode-lint format:check [targets...]',
40
- 'lint:markdown': 'textmode-lint lint:markdown [--fix]',
41
- check: 'textmode-lint check',
42
- };
43
- console.log(`Usage: ${usage[command]}`);
44
- }
45
-
46
- function parseArgv(argv) {
47
- const values = { cwd: undefined, help: false, version: false };
48
- const rest = [];
49
-
50
- for (let index = 0; index < argv.length; index += 1) {
51
- const arg = argv[index];
52
- if (arg === '--cwd') {
53
- if (index + 1 >= argv.length || argv[index + 1].startsWith('-')) {
54
- throw new Error('--cwd requires a directory value.');
55
- }
56
- values.cwd = argv[index + 1];
57
- index += 1;
58
- continue;
59
- }
60
- if (arg === '--help' || arg === '-h') {
61
- values.help = true;
62
- continue;
63
- }
64
- if (arg === '--version' || arg === '-v') {
65
- values.version = true;
66
- continue;
67
- }
68
- rest.push(arg);
69
- }
70
-
71
- const [command, ...forwarded] = rest;
72
- if (command !== undefined && !COMMANDS.has(command)) {
73
- throw new Error(`Unknown command "${command}".`);
74
- }
75
- if (command === 'check' && forwarded.length > 0) {
76
- throw new Error('The check command does not accept arguments.');
77
- }
78
-
79
- return { command, forwarded, values };
80
- }
81
-
82
- function engineFor(command) {
83
- if (command === 'lint') return 'eslint';
84
- if (command === 'format' || command === 'format:check') return 'prettier';
85
- return 'markdownlint-cli2';
86
- }
87
-
88
- function prettierBaseArgs(cwd, check) {
89
- const args = [check ? '--check' : '--write', '--config', path.join(PACKAGE_ROOT, 'prettier.json')];
90
- if (!fs.existsSync(path.join(cwd, '.prettierignore'))) {
91
- args.push('--ignore-path', path.join(PACKAGE_ROOT, '.prettierignore'));
92
- }
93
- args.push('--ignore-unknown');
94
- return args;
95
- }
96
-
97
- function commandArgs(command, forwarded, cwd) {
98
- switch (command) {
99
- case 'lint':
100
- return forwarded.length > 0 ? forwarded : ['.'];
101
- case 'format':
102
- return [...prettierBaseArgs(cwd, false), ...(forwarded.length > 0 ? forwarded : ['.'])];
103
- case 'format:check':
104
- return [...prettierBaseArgs(cwd, true), ...(forwarded.length > 0 ? forwarded : ['.'])];
105
- case 'lint:markdown': {
106
- const hasTarget = forwarded.some((arg) => !arg.startsWith('-'));
107
- const args = ['--config', path.join(PACKAGE_ROOT, 'markdownlint-cli2.jsonc'), ...forwarded];
108
- if (!hasTarget) {
109
- args.push('**/*.md');
110
- }
111
- return args;
112
- }
113
- default:
114
- throw new Error(`Unsupported command "${command}".`);
115
- }
116
- }
117
-
118
- function main(argv) {
119
- let parsed;
120
- try {
121
- parsed = parseArgv(argv);
122
- } catch (error) {
123
- console.error(error instanceof Error ? error.message : String(error));
124
- return 2;
125
- }
126
-
127
- const { command, forwarded, values } = parsed;
128
- const cwd = values.cwd ? path.resolve(values.cwd) : process.cwd();
129
-
130
- if (values.version && command === undefined) {
131
- console.log(PACKAGE_JSON.version);
132
- return 0;
133
- }
134
- if (values.help && command === undefined) {
135
- printGeneralHelp();
136
- return 0;
137
- }
138
- if (command === undefined) {
139
- console.error('Missing command. Run textmode-lint --help for usage.');
140
- return 2;
141
- }
142
- if (values.help) {
143
- printCommandHelp(command);
144
- return 0;
145
- }
146
-
147
- if (command === 'check') {
148
- for (const step of ['format:check', 'lint', 'lint:markdown']) {
149
- console.log(`\n[textmode-lint] ${step}`);
150
- const status = runEngine(engineFor(step), commandArgs(step, [], cwd), { cwd });
151
- if (status !== 0) {
152
- return status;
153
- }
154
- }
155
- return 0;
156
- }
157
-
158
- return runEngine(engineFor(command), commandArgs(command, forwarded, cwd), { cwd });
159
- }
160
-
161
- process.exitCode = main(process.argv.slice(2));
@@ -1,44 +0,0 @@
1
- import { spawnSync } from 'node:child_process';
2
- import fs from 'node:fs';
3
- import { createRequire } from 'node:module';
4
- import path from 'node:path';
5
-
6
- const require = createRequire(import.meta.url);
7
-
8
- const ENGINE_BIN_NAME = {
9
- eslint: 'eslint',
10
- prettier: 'prettier',
11
- 'markdownlint-cli2': 'markdownlint-cli2',
12
- };
13
-
14
- function resolveEngineBinary(packageName, binName) {
15
- let manifestPath;
16
- try {
17
- manifestPath = require.resolve(`${packageName}/package.json`);
18
- } catch {
19
- manifestPath = path.join(path.dirname(require.resolve(packageName)), 'package.json');
20
- }
21
- const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
22
- const bin = typeof manifest.bin === 'string' ? manifest.bin : manifest.bin[binName];
23
- if (typeof bin !== 'string') {
24
- throw new Error(`Cannot resolve ${packageName} binary ${binName}.`);
25
- }
26
- return path.resolve(path.dirname(manifestPath), bin);
27
- }
28
-
29
- export function resolveEngine(name) {
30
- return resolveEngineBinary(name, ENGINE_BIN_NAME[name]);
31
- }
32
-
33
- export function runEngine(name, args, { cwd = process.cwd() } = {}) {
34
- const bin = resolveEngine(name);
35
- const result = spawnSync(process.execPath, [bin, ...args], {
36
- cwd,
37
- stdio: 'inherit',
38
- });
39
- if (result.error) {
40
- console.error(`Unable to run ${name}: ${result.error.message}`);
41
- return 2;
42
- }
43
- return result.status ?? 1;
44
- }