untodo 0.0.1-alpha.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 +21 -0
- package/README.md +78 -0
- package/dist/cli.cjs +81 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.mts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.mjs +79 -0
- package/dist/eslint.cjs +124 -0
- package/dist/eslint.d.cts +101 -0
- package/dist/eslint.d.mts +101 -0
- package/dist/eslint.d.ts +101 -0
- package/dist/eslint.mjs +122 -0
- package/dist/index.cjs +77 -0
- package/dist/index.d.cts +176 -0
- package/dist/index.d.mts +176 -0
- package/dist/index.d.ts +176 -0
- package/dist/index.mjs +66 -0
- package/package.json +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kanon
|
|
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
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# untodo
|
|
2
|
+
|
|
3
|
+
Type-safe replacement for `// TODO:` comments.
|
|
4
|
+
Trackable in your IDE, enforceable by lint, surfaced by the type system.
|
|
5
|
+
|
|
6
|
+
> Status: **scaffold** — APIs are placeholders. See `Project Planning` in the repo for the design.
|
|
7
|
+
|
|
8
|
+
## Why
|
|
9
|
+
|
|
10
|
+
| Problem | Solution |
|
|
11
|
+
|---|---|
|
|
12
|
+
| `// TODO:` comments are easy to ignore | Function calls — lint can fail the build |
|
|
13
|
+
| Comments don't reach the type system | Returns `never` so callers detect it |
|
|
14
|
+
| No structure | Pass an object with `reason`, `issue`, etc. |
|
|
15
|
+
| Hard to track in an IDE | "Find references" works on a function |
|
|
16
|
+
|
|
17
|
+
Inspired by [Kotlin's `TODO()`](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-t-o-d-o.html).
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install untodo
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { TODO, FIXME, HACK, defineConfig } from "untodo";
|
|
29
|
+
|
|
30
|
+
function fetchUser(): User {
|
|
31
|
+
return TODO({ reason: "未実装" });
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`untodo.config.ts`:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { defineConfig } from "untodo";
|
|
39
|
+
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
repo: "org/repo",
|
|
42
|
+
onTodo: (meta) => console.warn(`TODO: ${meta.reason}`),
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## ESLint plugin
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
// eslint.config.ts
|
|
50
|
+
import untodoPlugin from "untodo/eslint";
|
|
51
|
+
|
|
52
|
+
export default [
|
|
53
|
+
{
|
|
54
|
+
plugins: { untodo: untodoPlugin },
|
|
55
|
+
rules: {
|
|
56
|
+
"untodo/no-todo": "error",
|
|
57
|
+
"untodo/no-fixme": "error",
|
|
58
|
+
"untodo/no-hack": "warn",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The same plugin works with [oxlint](https://oxc.rs/docs/guide/usage/linter.html)'s JS plugin support.
|
|
65
|
+
|
|
66
|
+
## Scripts
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm run build # unbuild
|
|
70
|
+
npm test # vitest run
|
|
71
|
+
npm run test:coverage # vitest run --coverage
|
|
72
|
+
npm run lint # eslint .
|
|
73
|
+
npm run lint:fix # eslint . --fix
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const node_fs = require('node:fs');
|
|
5
|
+
const node_path = require('node:path');
|
|
6
|
+
|
|
7
|
+
const untodoConfigTemplate = `import { defineConfig } from 'untodo';
|
|
8
|
+
|
|
9
|
+
export default defineConfig({
|
|
10
|
+
// repo: 'org/repo',
|
|
11
|
+
// onTodo: (meta) => console.warn(\`TODO: \${meta.reason}\`),
|
|
12
|
+
// onFixme: (meta) => console.error(\`FIXME: \${meta.reason}\`),
|
|
13
|
+
// onHack: (meta) => console.warn(\`HACK: \${meta.reason}\`),
|
|
14
|
+
});
|
|
15
|
+
`;
|
|
16
|
+
const globalDtsTemplate = `declare module 'untodo' {
|
|
17
|
+
interface TodoMeta {
|
|
18
|
+
// issue?: number | string;
|
|
19
|
+
// assignee?: string;
|
|
20
|
+
}
|
|
21
|
+
interface FixmeMeta {
|
|
22
|
+
// issue?: number | string;
|
|
23
|
+
}
|
|
24
|
+
interface HackMeta {
|
|
25
|
+
// issue?: number | string;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {};
|
|
30
|
+
`;
|
|
31
|
+
const eslintGuidance = `Add the plugin to your eslint.config.ts:
|
|
32
|
+
|
|
33
|
+
import untodoPlugin from 'untodo/eslint';
|
|
34
|
+
|
|
35
|
+
export default [
|
|
36
|
+
{
|
|
37
|
+
plugins: { untodo: untodoPlugin },
|
|
38
|
+
rules: {
|
|
39
|
+
'untodo/no-todo': 'error',
|
|
40
|
+
'untodo/no-fixme': 'error',
|
|
41
|
+
'untodo/no-hack': 'warn',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
function runInit(options = {}) {
|
|
48
|
+
const cwd = options.cwd ?? process.cwd();
|
|
49
|
+
const log = options.log ?? console.log;
|
|
50
|
+
writeIfMissing(
|
|
51
|
+
node_path.resolve(cwd, "untodo.config.ts"),
|
|
52
|
+
untodoConfigTemplate,
|
|
53
|
+
options.force,
|
|
54
|
+
log
|
|
55
|
+
);
|
|
56
|
+
writeIfMissing(
|
|
57
|
+
node_path.resolve(cwd, "global.d.ts"),
|
|
58
|
+
globalDtsTemplate,
|
|
59
|
+
options.force,
|
|
60
|
+
log
|
|
61
|
+
);
|
|
62
|
+
log("");
|
|
63
|
+
log(eslintGuidance);
|
|
64
|
+
}
|
|
65
|
+
function writeIfMissing(path, content, force, log) {
|
|
66
|
+
if (!force && node_fs.existsSync(path)) {
|
|
67
|
+
log(`skip: ${path} (already exists)`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
node_fs.writeFileSync(path, content, "utf8");
|
|
71
|
+
log(`wrote: ${path}`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const [, , command, ...rest] = process.argv;
|
|
75
|
+
if (command === "init") {
|
|
76
|
+
const force = rest.includes("--force") || rest.includes("-f");
|
|
77
|
+
runInit({ force });
|
|
78
|
+
process.exit(0);
|
|
79
|
+
}
|
|
80
|
+
console.log("Usage: untodo init [--force]");
|
|
81
|
+
process.exit(command ? 1 : 0);
|
package/dist/cli.d.cts
ADDED
package/dist/cli.d.mts
ADDED
package/dist/cli.d.ts
ADDED
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
|
|
5
|
+
const untodoConfigTemplate = `import { defineConfig } from 'untodo';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
// repo: 'org/repo',
|
|
9
|
+
// onTodo: (meta) => console.warn(\`TODO: \${meta.reason}\`),
|
|
10
|
+
// onFixme: (meta) => console.error(\`FIXME: \${meta.reason}\`),
|
|
11
|
+
// onHack: (meta) => console.warn(\`HACK: \${meta.reason}\`),
|
|
12
|
+
});
|
|
13
|
+
`;
|
|
14
|
+
const globalDtsTemplate = `declare module 'untodo' {
|
|
15
|
+
interface TodoMeta {
|
|
16
|
+
// issue?: number | string;
|
|
17
|
+
// assignee?: string;
|
|
18
|
+
}
|
|
19
|
+
interface FixmeMeta {
|
|
20
|
+
// issue?: number | string;
|
|
21
|
+
}
|
|
22
|
+
interface HackMeta {
|
|
23
|
+
// issue?: number | string;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {};
|
|
28
|
+
`;
|
|
29
|
+
const eslintGuidance = `Add the plugin to your eslint.config.ts:
|
|
30
|
+
|
|
31
|
+
import untodoPlugin from 'untodo/eslint';
|
|
32
|
+
|
|
33
|
+
export default [
|
|
34
|
+
{
|
|
35
|
+
plugins: { untodo: untodoPlugin },
|
|
36
|
+
rules: {
|
|
37
|
+
'untodo/no-todo': 'error',
|
|
38
|
+
'untodo/no-fixme': 'error',
|
|
39
|
+
'untodo/no-hack': 'warn',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
function runInit(options = {}) {
|
|
46
|
+
const cwd = options.cwd ?? process.cwd();
|
|
47
|
+
const log = options.log ?? console.log;
|
|
48
|
+
writeIfMissing(
|
|
49
|
+
resolve(cwd, "untodo.config.ts"),
|
|
50
|
+
untodoConfigTemplate,
|
|
51
|
+
options.force,
|
|
52
|
+
log
|
|
53
|
+
);
|
|
54
|
+
writeIfMissing(
|
|
55
|
+
resolve(cwd, "global.d.ts"),
|
|
56
|
+
globalDtsTemplate,
|
|
57
|
+
options.force,
|
|
58
|
+
log
|
|
59
|
+
);
|
|
60
|
+
log("");
|
|
61
|
+
log(eslintGuidance);
|
|
62
|
+
}
|
|
63
|
+
function writeIfMissing(path, content, force, log) {
|
|
64
|
+
if (!force && existsSync(path)) {
|
|
65
|
+
log(`skip: ${path} (already exists)`);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
writeFileSync(path, content, "utf8");
|
|
69
|
+
log(`wrote: ${path}`);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const [, , command, ...rest] = process.argv;
|
|
73
|
+
if (command === "init") {
|
|
74
|
+
const force = rest.includes("--force") || rest.includes("-f");
|
|
75
|
+
runInit({ force });
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}
|
|
78
|
+
console.log("Usage: untodo init [--force]");
|
|
79
|
+
process.exit(command ? 1 : 0);
|
package/dist/eslint.cjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const utils = require('@typescript-eslint/utils');
|
|
4
|
+
|
|
5
|
+
const createRule = utils.ESLintUtils.RuleCreator(
|
|
6
|
+
(name) => `https://github.com/ysknsid25/untodo/blob/main/docs/rules/${name}.md`
|
|
7
|
+
);
|
|
8
|
+
|
|
9
|
+
const noTodo = createRule({
|
|
10
|
+
name: "no-todo",
|
|
11
|
+
meta: {
|
|
12
|
+
type: "problem",
|
|
13
|
+
docs: {
|
|
14
|
+
description: "Disallow leftover `TODO()` calls."
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
messages: {
|
|
18
|
+
noTodo: "Unresolved TODO: {{reason}}"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
defaultOptions: [],
|
|
22
|
+
create(context) {
|
|
23
|
+
return {
|
|
24
|
+
CallExpression(node) {
|
|
25
|
+
if (node.callee.type !== "Identifier" || node.callee.name !== "TODO") {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const reason = extractReason(node.arguments[0]);
|
|
29
|
+
context.report({
|
|
30
|
+
node,
|
|
31
|
+
messageId: "noTodo",
|
|
32
|
+
data: { reason: reason ?? "(no reason)" }
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
function extractReason(arg) {
|
|
39
|
+
if (typeof arg !== "object" || arg === null || arg.type !== "ObjectExpression") {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
const props = arg.properties;
|
|
43
|
+
for (const prop of props) {
|
|
44
|
+
const p = prop;
|
|
45
|
+
if (p.type !== "Property")
|
|
46
|
+
continue;
|
|
47
|
+
const keyName = p.key?.type === "Identifier" ? p.key.name : p.key?.type === "Literal" ? String(p.key.value) : void 0;
|
|
48
|
+
if (keyName === "reason" && p.value?.type === "Literal") {
|
|
49
|
+
return String(p.value.value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return void 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const noFixme = createRule({
|
|
56
|
+
name: "no-fixme",
|
|
57
|
+
meta: {
|
|
58
|
+
type: "problem",
|
|
59
|
+
docs: {
|
|
60
|
+
description: "Disallow leftover `FIXME()` calls."
|
|
61
|
+
},
|
|
62
|
+
schema: [],
|
|
63
|
+
messages: {
|
|
64
|
+
noFixme: "Unresolved FIXME call."
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
defaultOptions: [],
|
|
68
|
+
create(context) {
|
|
69
|
+
return {
|
|
70
|
+
CallExpression(node) {
|
|
71
|
+
if (node.callee.type === "Identifier" && node.callee.name === "FIXME") {
|
|
72
|
+
context.report({ node, messageId: "noFixme" });
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const noHack = createRule({
|
|
80
|
+
name: "no-hack",
|
|
81
|
+
meta: {
|
|
82
|
+
type: "suggestion",
|
|
83
|
+
docs: {
|
|
84
|
+
description: "Warn on `HACK()` calls."
|
|
85
|
+
},
|
|
86
|
+
schema: [],
|
|
87
|
+
messages: {
|
|
88
|
+
noHack: "HACK call detected \u2014 please justify or remove."
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
defaultOptions: [],
|
|
92
|
+
create(context) {
|
|
93
|
+
return {
|
|
94
|
+
CallExpression(node) {
|
|
95
|
+
if (node.callee.type === "Identifier" && node.callee.name === "HACK") {
|
|
96
|
+
context.report({ node, messageId: "noHack" });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const rules = {
|
|
104
|
+
"no-todo": noTodo,
|
|
105
|
+
"no-fixme": noFixme,
|
|
106
|
+
"no-hack": noHack
|
|
107
|
+
};
|
|
108
|
+
const configs = {
|
|
109
|
+
recommended: [
|
|
110
|
+
{
|
|
111
|
+
rules: {
|
|
112
|
+
"untodo/no-todo": "warn",
|
|
113
|
+
"untodo/no-fixme": "warn",
|
|
114
|
+
"untodo/no-hack": "warn"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
};
|
|
119
|
+
const untodoPlugin = {
|
|
120
|
+
rules,
|
|
121
|
+
configs
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
module.exports = untodoPlugin;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rule factory used by every untodo lint rule.
|
|
5
|
+
*
|
|
6
|
+
* Wraps `ESLintUtils.RuleCreator` so each rule's `meta.docs.url` resolves to
|
|
7
|
+
* `https://github.com/ysknsid25/untodo/blob/main/docs/rules/<name>.md`.
|
|
8
|
+
*/
|
|
9
|
+
declare const createRule: ReturnType<typeof ESLintUtils.RuleCreator>;
|
|
10
|
+
|
|
11
|
+
type Options$2 = [];
|
|
12
|
+
type MessageIds$2 = 'noTodo';
|
|
13
|
+
/**
|
|
14
|
+
* `untodo/no-todo` — flags every call to the `TODO()` function exported by
|
|
15
|
+
* `untodo`. Intended to fail CI once an unimplemented code path is in main.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Reported:
|
|
20
|
+
* function fetchUser() { return TODO({ reason: 'unimplemented' }); }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const noTodo: ReturnType<typeof createRule<Options$2, MessageIds$2>>;
|
|
24
|
+
|
|
25
|
+
type Options$1 = [];
|
|
26
|
+
type MessageIds$1 = 'noFixme';
|
|
27
|
+
/**
|
|
28
|
+
* `untodo/no-fixme` — flags every call to the `FIXME()` function exported by
|
|
29
|
+
* `untodo`. Intended to surface known defects that have escaped main.
|
|
30
|
+
*/
|
|
31
|
+
declare const noFixme: ReturnType<typeof createRule<Options$1, MessageIds$1>>;
|
|
32
|
+
|
|
33
|
+
type Options = [];
|
|
34
|
+
type MessageIds = 'noHack';
|
|
35
|
+
/**
|
|
36
|
+
* `untodo/no-hack` — flags every call to the `HACK()` function exported by
|
|
37
|
+
* `untodo`. Typically configured as a `warn` to nudge revisits without
|
|
38
|
+
* blocking merges.
|
|
39
|
+
*/
|
|
40
|
+
declare const noHack: ReturnType<typeof createRule<Options, MessageIds>>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* untodo ESLint / oxlint plugin.
|
|
44
|
+
*
|
|
45
|
+
* Ships three rules that flag leftover `TODO()`, `FIXME()` and `HACK()`
|
|
46
|
+
* calls from the `untodo` runtime. Compatible with ESLint v9 flat config
|
|
47
|
+
* and oxlint's JS plugin support.
|
|
48
|
+
*
|
|
49
|
+
* @example ESLint flat config
|
|
50
|
+
* ```ts
|
|
51
|
+
* import untodoPlugin from 'untodo/eslint';
|
|
52
|
+
*
|
|
53
|
+
* export default [
|
|
54
|
+
* {
|
|
55
|
+
* plugins: { untodo: untodoPlugin },
|
|
56
|
+
* rules: {
|
|
57
|
+
* 'untodo/no-todo': 'error',
|
|
58
|
+
* 'untodo/no-fixme': 'error',
|
|
59
|
+
* 'untodo/no-hack': 'warn',
|
|
60
|
+
* },
|
|
61
|
+
* },
|
|
62
|
+
* ];
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @module
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Map of rule name → rule definition exposed by the plugin.
|
|
70
|
+
*/
|
|
71
|
+
interface UntodoPluginRules {
|
|
72
|
+
'no-todo': typeof noTodo;
|
|
73
|
+
'no-fixme': typeof noFixme;
|
|
74
|
+
'no-hack': typeof noHack;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Single entry inside `configs.recommended` — an ESLint flat config block
|
|
78
|
+
* containing only rule severities.
|
|
79
|
+
*/
|
|
80
|
+
interface UntodoRecommendedConfig {
|
|
81
|
+
rules: Record<string, 'off' | 'warn' | 'error'>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Shape of the default-exported plugin object.
|
|
85
|
+
*/
|
|
86
|
+
interface UntodoPlugin {
|
|
87
|
+
rules: UntodoPluginRules;
|
|
88
|
+
configs: {
|
|
89
|
+
recommended: UntodoRecommendedConfig[];
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The plugin object consumed by ESLint / oxlint.
|
|
94
|
+
*
|
|
95
|
+
* Register it under the `untodo` namespace so rule IDs resolve to
|
|
96
|
+
* `untodo/no-todo`, `untodo/no-fixme`, `untodo/no-hack`.
|
|
97
|
+
*/
|
|
98
|
+
declare const untodoPlugin: UntodoPlugin;
|
|
99
|
+
|
|
100
|
+
export { untodoPlugin as default };
|
|
101
|
+
export type { UntodoPlugin, UntodoPluginRules, UntodoRecommendedConfig };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rule factory used by every untodo lint rule.
|
|
5
|
+
*
|
|
6
|
+
* Wraps `ESLintUtils.RuleCreator` so each rule's `meta.docs.url` resolves to
|
|
7
|
+
* `https://github.com/ysknsid25/untodo/blob/main/docs/rules/<name>.md`.
|
|
8
|
+
*/
|
|
9
|
+
declare const createRule: ReturnType<typeof ESLintUtils.RuleCreator>;
|
|
10
|
+
|
|
11
|
+
type Options$2 = [];
|
|
12
|
+
type MessageIds$2 = 'noTodo';
|
|
13
|
+
/**
|
|
14
|
+
* `untodo/no-todo` — flags every call to the `TODO()` function exported by
|
|
15
|
+
* `untodo`. Intended to fail CI once an unimplemented code path is in main.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Reported:
|
|
20
|
+
* function fetchUser() { return TODO({ reason: 'unimplemented' }); }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const noTodo: ReturnType<typeof createRule<Options$2, MessageIds$2>>;
|
|
24
|
+
|
|
25
|
+
type Options$1 = [];
|
|
26
|
+
type MessageIds$1 = 'noFixme';
|
|
27
|
+
/**
|
|
28
|
+
* `untodo/no-fixme` — flags every call to the `FIXME()` function exported by
|
|
29
|
+
* `untodo`. Intended to surface known defects that have escaped main.
|
|
30
|
+
*/
|
|
31
|
+
declare const noFixme: ReturnType<typeof createRule<Options$1, MessageIds$1>>;
|
|
32
|
+
|
|
33
|
+
type Options = [];
|
|
34
|
+
type MessageIds = 'noHack';
|
|
35
|
+
/**
|
|
36
|
+
* `untodo/no-hack` — flags every call to the `HACK()` function exported by
|
|
37
|
+
* `untodo`. Typically configured as a `warn` to nudge revisits without
|
|
38
|
+
* blocking merges.
|
|
39
|
+
*/
|
|
40
|
+
declare const noHack: ReturnType<typeof createRule<Options, MessageIds>>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* untodo ESLint / oxlint plugin.
|
|
44
|
+
*
|
|
45
|
+
* Ships three rules that flag leftover `TODO()`, `FIXME()` and `HACK()`
|
|
46
|
+
* calls from the `untodo` runtime. Compatible with ESLint v9 flat config
|
|
47
|
+
* and oxlint's JS plugin support.
|
|
48
|
+
*
|
|
49
|
+
* @example ESLint flat config
|
|
50
|
+
* ```ts
|
|
51
|
+
* import untodoPlugin from 'untodo/eslint';
|
|
52
|
+
*
|
|
53
|
+
* export default [
|
|
54
|
+
* {
|
|
55
|
+
* plugins: { untodo: untodoPlugin },
|
|
56
|
+
* rules: {
|
|
57
|
+
* 'untodo/no-todo': 'error',
|
|
58
|
+
* 'untodo/no-fixme': 'error',
|
|
59
|
+
* 'untodo/no-hack': 'warn',
|
|
60
|
+
* },
|
|
61
|
+
* },
|
|
62
|
+
* ];
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @module
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Map of rule name → rule definition exposed by the plugin.
|
|
70
|
+
*/
|
|
71
|
+
interface UntodoPluginRules {
|
|
72
|
+
'no-todo': typeof noTodo;
|
|
73
|
+
'no-fixme': typeof noFixme;
|
|
74
|
+
'no-hack': typeof noHack;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Single entry inside `configs.recommended` — an ESLint flat config block
|
|
78
|
+
* containing only rule severities.
|
|
79
|
+
*/
|
|
80
|
+
interface UntodoRecommendedConfig {
|
|
81
|
+
rules: Record<string, 'off' | 'warn' | 'error'>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Shape of the default-exported plugin object.
|
|
85
|
+
*/
|
|
86
|
+
interface UntodoPlugin {
|
|
87
|
+
rules: UntodoPluginRules;
|
|
88
|
+
configs: {
|
|
89
|
+
recommended: UntodoRecommendedConfig[];
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The plugin object consumed by ESLint / oxlint.
|
|
94
|
+
*
|
|
95
|
+
* Register it under the `untodo` namespace so rule IDs resolve to
|
|
96
|
+
* `untodo/no-todo`, `untodo/no-fixme`, `untodo/no-hack`.
|
|
97
|
+
*/
|
|
98
|
+
declare const untodoPlugin: UntodoPlugin;
|
|
99
|
+
|
|
100
|
+
export { untodoPlugin as default };
|
|
101
|
+
export type { UntodoPlugin, UntodoPluginRules, UntodoRecommendedConfig };
|
package/dist/eslint.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Rule factory used by every untodo lint rule.
|
|
5
|
+
*
|
|
6
|
+
* Wraps `ESLintUtils.RuleCreator` so each rule's `meta.docs.url` resolves to
|
|
7
|
+
* `https://github.com/ysknsid25/untodo/blob/main/docs/rules/<name>.md`.
|
|
8
|
+
*/
|
|
9
|
+
declare const createRule: ReturnType<typeof ESLintUtils.RuleCreator>;
|
|
10
|
+
|
|
11
|
+
type Options$2 = [];
|
|
12
|
+
type MessageIds$2 = 'noTodo';
|
|
13
|
+
/**
|
|
14
|
+
* `untodo/no-todo` — flags every call to the `TODO()` function exported by
|
|
15
|
+
* `untodo`. Intended to fail CI once an unimplemented code path is in main.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // Reported:
|
|
20
|
+
* function fetchUser() { return TODO({ reason: 'unimplemented' }); }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
declare const noTodo: ReturnType<typeof createRule<Options$2, MessageIds$2>>;
|
|
24
|
+
|
|
25
|
+
type Options$1 = [];
|
|
26
|
+
type MessageIds$1 = 'noFixme';
|
|
27
|
+
/**
|
|
28
|
+
* `untodo/no-fixme` — flags every call to the `FIXME()` function exported by
|
|
29
|
+
* `untodo`. Intended to surface known defects that have escaped main.
|
|
30
|
+
*/
|
|
31
|
+
declare const noFixme: ReturnType<typeof createRule<Options$1, MessageIds$1>>;
|
|
32
|
+
|
|
33
|
+
type Options = [];
|
|
34
|
+
type MessageIds = 'noHack';
|
|
35
|
+
/**
|
|
36
|
+
* `untodo/no-hack` — flags every call to the `HACK()` function exported by
|
|
37
|
+
* `untodo`. Typically configured as a `warn` to nudge revisits without
|
|
38
|
+
* blocking merges.
|
|
39
|
+
*/
|
|
40
|
+
declare const noHack: ReturnType<typeof createRule<Options, MessageIds>>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* untodo ESLint / oxlint plugin.
|
|
44
|
+
*
|
|
45
|
+
* Ships three rules that flag leftover `TODO()`, `FIXME()` and `HACK()`
|
|
46
|
+
* calls from the `untodo` runtime. Compatible with ESLint v9 flat config
|
|
47
|
+
* and oxlint's JS plugin support.
|
|
48
|
+
*
|
|
49
|
+
* @example ESLint flat config
|
|
50
|
+
* ```ts
|
|
51
|
+
* import untodoPlugin from 'untodo/eslint';
|
|
52
|
+
*
|
|
53
|
+
* export default [
|
|
54
|
+
* {
|
|
55
|
+
* plugins: { untodo: untodoPlugin },
|
|
56
|
+
* rules: {
|
|
57
|
+
* 'untodo/no-todo': 'error',
|
|
58
|
+
* 'untodo/no-fixme': 'error',
|
|
59
|
+
* 'untodo/no-hack': 'warn',
|
|
60
|
+
* },
|
|
61
|
+
* },
|
|
62
|
+
* ];
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @module
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Map of rule name → rule definition exposed by the plugin.
|
|
70
|
+
*/
|
|
71
|
+
interface UntodoPluginRules {
|
|
72
|
+
'no-todo': typeof noTodo;
|
|
73
|
+
'no-fixme': typeof noFixme;
|
|
74
|
+
'no-hack': typeof noHack;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Single entry inside `configs.recommended` — an ESLint flat config block
|
|
78
|
+
* containing only rule severities.
|
|
79
|
+
*/
|
|
80
|
+
interface UntodoRecommendedConfig {
|
|
81
|
+
rules: Record<string, 'off' | 'warn' | 'error'>;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Shape of the default-exported plugin object.
|
|
85
|
+
*/
|
|
86
|
+
interface UntodoPlugin {
|
|
87
|
+
rules: UntodoPluginRules;
|
|
88
|
+
configs: {
|
|
89
|
+
recommended: UntodoRecommendedConfig[];
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The plugin object consumed by ESLint / oxlint.
|
|
94
|
+
*
|
|
95
|
+
* Register it under the `untodo` namespace so rule IDs resolve to
|
|
96
|
+
* `untodo/no-todo`, `untodo/no-fixme`, `untodo/no-hack`.
|
|
97
|
+
*/
|
|
98
|
+
declare const untodoPlugin: UntodoPlugin;
|
|
99
|
+
|
|
100
|
+
export { untodoPlugin as default };
|
|
101
|
+
export type { UntodoPlugin, UntodoPluginRules, UntodoRecommendedConfig };
|