@app-compose/eslint-plugin 3.0.0-beta.10

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 The grlt-hub Authors
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,53 @@
1
+ # @app-compose/eslint-plugin
2
+
3
+ ESLint plugin that enforces [App-Compose](https://app-compose.dev) conventions in TypeScript code.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/%40app-compose%2Feslint-plugin?color=orange)](https://www.npmjs.com/package/@app-compose/eslint-plugin)
6
+ ![npm license](https://img.shields.io/npm/l/%40app-compose%2Feslint-plugin?color=blue)
7
+ [![npm provenance](https://img.shields.io/badge/provenance-yes-brightgreen?logo=npm)](https://www.npmjs.com/package/@app-compose/eslint-plugin)
8
+
9
+ [Docs](https://app-compose.dev/learn/linting/) | [App-Compose](https://app-compose.dev)
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install --save-dev --save-exact @app-compose/eslint-plugin
15
+ ```
16
+
17
+ Requires ESLint 9+ and TypeScript 5+.
18
+
19
+ ## Usage
20
+
21
+ Add the recommended preset to your flat config:
22
+
23
+ ```js
24
+ import appCompose from "@app-compose/eslint-plugin"
25
+ import tseslint from "typescript-eslint"
26
+
27
+ export default tseslint.config(appCompose.configs.recommended)
28
+ ```
29
+
30
+ Or wire the plugin manually:
31
+
32
+ ```js
33
+ {
34
+ plugins: { "app-compose": appCompose },
35
+ rules: {
36
+ "app-compose/task-options-order": "warn",
37
+ },
38
+ }
39
+ ```
40
+
41
+ ## Rules
42
+
43
+ - ⚠️ — set to `warn` in the `recommended` config
44
+ - ❗ — set to `error` in the `recommended` config
45
+ - 🔧 — auto-fixable
46
+
47
+ | Name | Description | ⚠️ | ❗ | 🔧 |
48
+ | ----------------------------------------------------------------------------------------- | ------------------------------------------------- | --- | --- | --- |
49
+ | [no-async-shape-callback](https://app-compose.dev/learn/linting/#no-async-shape-callback) | Disallow async callbacks in `shape()` | | ❗ | |
50
+ | [no-coda-debug](https://app-compose.dev/learn/linting/#no-coda-debug) | Disallow `debug()` calls from `@app-compose/coda` | | ❗ | |
51
+ | [no-scope-get](https://app-compose.dev/learn/linting/#no-scope-get) | Disallow `scope.get()` calls | | | |
52
+ | [task-options-order](https://app-compose.dev/learn/linting/#task-options-order) | Enforce options order for `createTask` | ⚠️ | | 🔧 |
53
+ | [wire-options-order](https://app-compose.dev/learn/linting/#wire-options-order) | Enforce options order for `createWire` | ⚠️ | | 🔧 |
package/dist/index.cjs ADDED
@@ -0,0 +1,303 @@
1
+ // \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+ let _typescript_eslint_type_utils = require("@typescript-eslint/type-utils");
23
+ let _typescript_eslint_utils = require("@typescript-eslint/utils");
24
+ let esquery = require("esquery");
25
+ esquery = __toESM(esquery, 1);
26
+ // package.json
27
+ var name = "@app-compose/eslint-plugin";
28
+ var version = "3.0.0-beta.10";
29
+ // src/shared/constants.ts
30
+ const PACKAGE_NAME = {
31
+ CORE: "@app-compose/core",
32
+ CODA: "@app-compose/coda"
33
+ };
34
+ const UNITS = {
35
+ CREATE_TASK: "createTask",
36
+ CREATE_WIRE: "createWire",
37
+ DEBUG: "debug",
38
+ SHAPE: "shape"
39
+ };
40
+ // src/shared/create.ts
41
+ const createRule = _typescript_eslint_utils.ESLintUtils.RuleCreator(() => "");
42
+ // src/rules/no-async-shape-callback/no-async-shape-callback.ts
43
+ const importSelector$3 = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`;
44
+ const specifierSelector$1 = `ImportSpecifier[imported.name=${UNITS.SHAPE}]`;
45
+ const callSelector$3 = `[callee.type="Identifier"][arguments.length=2]`;
46
+ var no_async_shape_callback_default = createRule({
47
+ name: "no-async-shape-callback",
48
+ meta: {
49
+ type: "problem",
50
+ docs: { description: `Disallow async callbacks in \`${UNITS.SHAPE}()\`` },
51
+ messages: { asyncCallback: `Unexpected async callback in \`${UNITS.SHAPE}()\` — async work runs outside the chain, and App-Compose cannot order it.` },
52
+ schema: [],
53
+ hasSuggestions: false
54
+ },
55
+ defaultOptions: [],
56
+ create: (context) => {
57
+ const services = _typescript_eslint_utils.ESLintUtils.getParserServices(context);
58
+ const imports = /* @__PURE__ */ new Set();
59
+ return {
60
+ [`${importSelector$3} > ${specifierSelector$1}`]: (node) => void imports.add(node.local.name),
61
+ [`CallExpression${callSelector$3}`]: (node) => {
62
+ if (!imports.has(node.callee.name)) return;
63
+ const [, fn] = node.arguments;
64
+ if (!services.getTypeAtLocation(fn).getCallSignatures().map((signature) => signature.getReturnType()).flatMap((returned) => returned.isUnion() ? returned.types : [returned]).some((type) => (0, _typescript_eslint_type_utils.isPromiseLike)(services.program, type))) return;
65
+ context.report({
66
+ node: fn,
67
+ messageId: "asyncCallback"
68
+ });
69
+ }
70
+ };
71
+ }
72
+ });
73
+ // src/rules/no-coda-debug/no-coda-debug.ts
74
+ const importSelector$2 = `ImportDeclaration[source.value=${PACKAGE_NAME.CODA}]`;
75
+ const specifierSelector = `ImportSpecifier[imported.name=${UNITS.DEBUG}]`;
76
+ const callSelector$2 = `[callee.type="Identifier"]`;
77
+ var no_coda_debug_default = createRule({
78
+ name: "no-coda-debug",
79
+ meta: {
80
+ type: "problem",
81
+ docs: { description: `Disallow \`${UNITS.DEBUG}()\` calls from ${PACKAGE_NAME.CODA} in committed code` },
82
+ messages: { unexpectedDebug: `Unexpected \`${UNITS.DEBUG}()\` call from ${PACKAGE_NAME.CODA}.` },
83
+ schema: [],
84
+ hasSuggestions: false
85
+ },
86
+ defaultOptions: [],
87
+ create: (context) => {
88
+ const imports = /* @__PURE__ */ new Set();
89
+ return {
90
+ [`${importSelector$2} > ${specifierSelector}`]: (node) => void imports.add(node.local.name),
91
+ [`CallExpression${callSelector$2}`]: (node) => {
92
+ if (!imports.has(node.callee.name)) return;
93
+ context.report({
94
+ node,
95
+ messageId: "unexpectedDebug"
96
+ });
97
+ }
98
+ };
99
+ }
100
+ });
101
+ // src/shared/is.ts
102
+ const isType = { scope: (type, program) => (0, _typescript_eslint_type_utils.typeMatchesSpecifier)(type, {
103
+ from: "package",
104
+ package: PACKAGE_NAME.CORE,
105
+ name: "Scope"
106
+ }, program) };
107
+ // src/rules/no-scope-get/no-scope-get.ts
108
+ var no_scope_get_default = createRule({
109
+ name: "no-scope-get",
110
+ meta: {
111
+ type: "suggestion",
112
+ docs: { description: "Disallow `scope.get()` calls" },
113
+ messages: { unexpectedScopeGet: "`scope.get()` can lead to imperative work outside the composition. Put the work in a Task and pass values through its context." },
114
+ schema: [],
115
+ hasSuggestions: false
116
+ },
117
+ defaultOptions: [],
118
+ create: (context) => {
119
+ const services = _typescript_eslint_utils.ESLintUtils.getParserServices(context);
120
+ return { [`CallExpression[callee.type="MemberExpression"][callee.property.type="Identifier"][callee.property.name="get"]`]: (node) => {
121
+ const type = services.getTypeAtLocation(node.callee.object);
122
+ if (!isType.scope(type, services.program)) return;
123
+ context.report({
124
+ node,
125
+ messageId: "unexpectedScopeGet"
126
+ });
127
+ } };
128
+ }
129
+ });
130
+ // src/shared/ast.ts
131
+ const PLAIN_PROP = esquery.default.parse(`Property[kind="init"][method=false][computed=false][key.type="Identifier"]`);
132
+ const isPlainProp = (prop) => esquery.default.matches(prop, PLAIN_PROP);
133
+ const isSpread = _typescript_eslint_utils.ASTUtils.isNodeOfType(_typescript_eslint_utils.AST_NODE_TYPES.SpreadElement);
134
+ // src/rules/task-options-order/task-options-order.ts
135
+ const ORDER = [
136
+ "name",
137
+ "run",
138
+ "run.context",
139
+ "run.fn",
140
+ "enabled",
141
+ "enabled.context",
142
+ "enabled.fn"
143
+ ];
144
+ const rankOf = (key) => {
145
+ const index = ORDER.indexOf(key);
146
+ return index === -1 ? Infinity : index;
147
+ };
148
+ const hasNested = (key) => ORDER.some((entry) => entry.startsWith(`${key}.`));
149
+ const importSelector$1 = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`;
150
+ const methodSelector$1 = `ImportSpecifier[imported.name=${UNITS.CREATE_TASK}]`;
151
+ const callSelector$1 = `[callee.type="Identifier"][arguments.length=1]`;
152
+ const argumentSelector$1 = `ObjectExpression.arguments`;
153
+ var task_options_order_default = createRule({
154
+ name: "task-options-order",
155
+ meta: {
156
+ type: "problem",
157
+ docs: { description: `Enforce options order for ${UNITS.CREATE_TASK}` },
158
+ messages: { invalidOrder: `Order of options should be \`{{ correctOrder }}\`, but found \`{{ currentOrder }}\`.` },
159
+ schema: [],
160
+ hasSuggestions: false,
161
+ fixable: "code"
162
+ },
163
+ defaultOptions: [],
164
+ create: (context) => {
165
+ const source = context.sourceCode;
166
+ const imports = /* @__PURE__ */ new Set();
167
+ return {
168
+ [`${importSelector$1} > ${methodSelector$1}`]: (node) => void imports.add(node.local.name),
169
+ [`CallExpression${callSelector$1}:has(> ${argumentSelector$1})`]: (node) => {
170
+ if (!imports.has(node.callee.name)) return;
171
+ const [config] = node.arguments;
172
+ if (!isReorderable(config)) return;
173
+ const keys = orderKeys(config);
174
+ if (isOrdered(keys)) return;
175
+ const data = {
176
+ correctOrder: keys.toSorted((a, b) => rankOf(a) - rankOf(b)).join(" -> "),
177
+ currentOrder: keys.join(" -> ")
178
+ };
179
+ const fixed = rebuild(config, null, source);
180
+ context.report({
181
+ node: config,
182
+ messageId: "invalidOrder",
183
+ data,
184
+ fix: fixed === null ? void 0 : (fixer) => fixer.replaceText(config, fixed)
185
+ });
186
+ }
187
+ };
188
+ }
189
+ });
190
+ const isLeadingSpread = (props, index) => props.slice(0, index).every(isSpread);
191
+ const isTrailingSpread = (props, index) => props.slice(index + 1).every(isSpread);
192
+ const isReorderable = (config) => config.properties.every((prop, index, props) => isSpread(prop) ? isLeadingSpread(props, index) || isTrailingSpread(props, index) : isPlainProp(prop));
193
+ const orderKeys = (config) => config.properties.flatMap((prop) => !isPlainProp(prop) ? [] : prop.value.type === _typescript_eslint_utils.AST_NODE_TYPES.ObjectExpression ? prop.value.properties.filter(isPlainProp).map((nested) => `${prop.key.name}.${nested.key.name}`) : [prop.key.name]);
194
+ const isOrdered = (keys) => {
195
+ const sorted = keys.toSorted((a, b) => rankOf(a) - rankOf(b));
196
+ return keys.every((key, index) => key === sorted[index]);
197
+ };
198
+ const entryOf = ({ prop, index, props, group, source }) => {
199
+ if (isSpread(prop)) {
200
+ if (isTrailingSpread(props, index)) return {
201
+ rank: Infinity,
202
+ text: source.getText(prop)
203
+ };
204
+ if (isLeadingSpread(props, index)) return {
205
+ rank: -Infinity,
206
+ text: source.getText(prop)
207
+ };
208
+ return null;
209
+ }
210
+ if (!isPlainProp(prop)) return null;
211
+ const key = group === null ? prop.key.name : `${group}.${prop.key.name}`;
212
+ if (group === null && hasNested(prop.key.name) && prop.value.type === _typescript_eslint_utils.AST_NODE_TYPES.ObjectExpression) {
213
+ const inner = rebuild(prop.value, prop.key.name, source);
214
+ return inner === null ? null : {
215
+ rank: rankOf(key),
216
+ text: `${prop.key.name}: ${inner}`
217
+ };
218
+ }
219
+ return {
220
+ rank: rankOf(key),
221
+ text: source.getText(prop)
222
+ };
223
+ };
224
+ const rebuild = (obj, group, source) => {
225
+ const entries = [];
226
+ for (const [index, prop] of obj.properties.entries()) {
227
+ const entry = entryOf({
228
+ prop,
229
+ index,
230
+ props: obj.properties,
231
+ group,
232
+ source
233
+ });
234
+ if (entry === null) return null;
235
+ entries.push(entry);
236
+ }
237
+ const texts = entries.toSorted((a, b) => a.rank - b.rank).map((entry) => entry.text);
238
+ return group === null ? `{\n${texts.join(",\n")}\n}` : `{ ${texts.join(", ")} }`;
239
+ };
240
+ // src/rules/wire-options-order/wire-options-order.ts
241
+ const importSelector = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`;
242
+ const methodSelector = `ImportSpecifier[imported.name=${UNITS.CREATE_WIRE}]`;
243
+ const callSelector = `[callee.type="Identifier"][arguments.length=1]`;
244
+ const argumentSelector = `ObjectExpression.arguments[properties.length=2]`;
245
+ var wire_options_order_default = createRule({
246
+ name: "wire-options-order",
247
+ meta: {
248
+ type: "problem",
249
+ docs: { description: `Enforce options order for ${UNITS.CREATE_WIRE}` },
250
+ messages: { invalidOrder: `Order of options should be \`from -> to\`, but found \`to -> from\`.` },
251
+ schema: [],
252
+ hasSuggestions: false,
253
+ fixable: "code"
254
+ },
255
+ defaultOptions: [],
256
+ create: (context) => {
257
+ const source = context.sourceCode;
258
+ const imports = /* @__PURE__ */ new Set();
259
+ return {
260
+ [`${importSelector} > ${methodSelector}`]: (node) => void imports.add(node.local.name),
261
+ [`CallExpression${callSelector}:has(> ${argumentSelector})`]: (node) => {
262
+ if (!imports.has(node.callee.name)) return;
263
+ const [config] = node.arguments;
264
+ const [first, second] = config.properties;
265
+ if (!first || !second || !isPlainProp(first) || !isPlainProp(second)) return;
266
+ if (first.key.name === "from") return;
267
+ context.report({
268
+ node: config,
269
+ messageId: "invalidOrder",
270
+ fix: (fixer) => fixer.replaceText(config, `{\nfrom: ${source.getText(second.value)},\nto: ${source.getText(first.value)}\n}`)
271
+ });
272
+ }
273
+ };
274
+ }
275
+ });
276
+ const ruleset = { recommended: {
277
+ "app-compose/no-async-shape-callback": "error",
278
+ "app-compose/no-coda-debug": "error",
279
+ "app-compose/task-options-order": "warn",
280
+ "app-compose/wire-options-order": "warn"
281
+ } };
282
+ // src/index.ts
283
+ const base = {
284
+ meta: {
285
+ name,
286
+ version,
287
+ namespace: "app-compose"
288
+ },
289
+ rules: {
290
+ "no-async-shape-callback": no_async_shape_callback_default,
291
+ "no-coda-debug": no_coda_debug_default,
292
+ "no-scope-get": no_scope_get_default,
293
+ "task-options-order": task_options_order_default,
294
+ "wire-options-order": wire_options_order_default
295
+ }
296
+ };
297
+ const configs = { recommended: {
298
+ plugins: { "app-compose": base },
299
+ rules: ruleset.recommended
300
+ } };
301
+ const plugin = base;
302
+ plugin.configs = configs;
303
+ module.exports = plugin;
@@ -0,0 +1,43 @@
1
+ import { TSESLint } from "@typescript-eslint/utils";
2
+ declare const base: {
3
+ meta: {
4
+ name: string;
5
+ version: string;
6
+ namespace: string;
7
+ };
8
+ rules: {
9
+ "no-async-shape-callback": TSESLint.RuleModule<"asyncCallback", [], unknown, TSESLint.RuleListener> & {
10
+ name: string;
11
+ };
12
+ "no-coda-debug": TSESLint.RuleModule<"unexpectedDebug", [], unknown, TSESLint.RuleListener> & {
13
+ name: string;
14
+ };
15
+ "no-scope-get": TSESLint.RuleModule<"unexpectedScopeGet", [], unknown, TSESLint.RuleListener> & {
16
+ name: string;
17
+ };
18
+ "task-options-order": TSESLint.RuleModule<"invalidOrder", [], unknown, TSESLint.RuleListener> & {
19
+ name: string;
20
+ };
21
+ "wire-options-order": TSESLint.RuleModule<"invalidOrder", [], unknown, TSESLint.RuleListener> & {
22
+ name: string;
23
+ };
24
+ };
25
+ };
26
+ declare const configs: {
27
+ recommended: {
28
+ plugins: {
29
+ "app-compose": TSESLint.FlatConfig.Plugin;
30
+ };
31
+ rules: {
32
+ "app-compose/no-async-shape-callback": "error";
33
+ "app-compose/no-coda-debug": "error";
34
+ "app-compose/task-options-order": "warn";
35
+ "app-compose/wire-options-order": "warn";
36
+ };
37
+ };
38
+ };
39
+ declare const plugin: typeof base & {
40
+ configs: typeof configs;
41
+ };
42
+ export = plugin;
43
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"mappings":";cASM;;;;;;;IAGF,2BAAyB,SAAA,yCAAA,SAAA;;;IACzB,iBAAe,SAAA,2CAAA,SAAA;;;IACf,gBAAc,SAAA,8CAAA,SAAA;;;IACd,sBAAoB,SAAA,wCAAA,SAAA;;;IACpB,sBAAoB,SAAA,wCAAA,SAAA;;;;;cAIlB;EACJ;IAAe;MAAW,eAAuB,SAAS,WAAW;;IAAU;;;;;;;;cAG3E,eAAwB;EAAS,gBAAgB"}
@@ -0,0 +1,43 @@
1
+ import { TSESLint } from "@typescript-eslint/utils";
2
+ declare const base: {
3
+ meta: {
4
+ name: string;
5
+ version: string;
6
+ namespace: string;
7
+ };
8
+ rules: {
9
+ "no-async-shape-callback": TSESLint.RuleModule<"asyncCallback", [], unknown, TSESLint.RuleListener> & {
10
+ name: string;
11
+ };
12
+ "no-coda-debug": TSESLint.RuleModule<"unexpectedDebug", [], unknown, TSESLint.RuleListener> & {
13
+ name: string;
14
+ };
15
+ "no-scope-get": TSESLint.RuleModule<"unexpectedScopeGet", [], unknown, TSESLint.RuleListener> & {
16
+ name: string;
17
+ };
18
+ "task-options-order": TSESLint.RuleModule<"invalidOrder", [], unknown, TSESLint.RuleListener> & {
19
+ name: string;
20
+ };
21
+ "wire-options-order": TSESLint.RuleModule<"invalidOrder", [], unknown, TSESLint.RuleListener> & {
22
+ name: string;
23
+ };
24
+ };
25
+ };
26
+ declare const configs: {
27
+ recommended: {
28
+ plugins: {
29
+ "app-compose": TSESLint.FlatConfig.Plugin;
30
+ };
31
+ rules: {
32
+ "app-compose/no-async-shape-callback": "error";
33
+ "app-compose/no-coda-debug": "error";
34
+ "app-compose/task-options-order": "warn";
35
+ "app-compose/wire-options-order": "warn";
36
+ };
37
+ };
38
+ };
39
+ declare const plugin: typeof base & {
40
+ configs: typeof configs;
41
+ };
42
+ export { plugin as default };
43
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";cASM;;;;;;;IAGF,2BAAyB,SAAA,yCAAA,SAAA;;;IACzB,iBAAe,SAAA,2CAAA,SAAA;;;IACf,gBAAc,SAAA,8CAAA,SAAA;;;IACd,sBAAoB,SAAA,wCAAA,SAAA;;;IACpB,sBAAoB,SAAA,wCAAA,SAAA;;;;;cAIlB;EACJ;IAAe;MAAW,eAAuB,SAAS,WAAW;;IAAU;;;;;;;;cAG3E,eAAwB;EAAS,gBAAgB"}
package/dist/index.mjs ADDED
@@ -0,0 +1,283 @@
1
+ import { isPromiseLike, typeMatchesSpecifier } from "@typescript-eslint/type-utils";
2
+ import { ASTUtils, AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
3
+ import esquery from "esquery";
4
+ // package.json
5
+ var name = "@app-compose/eslint-plugin";
6
+ var version = "3.0.0-beta.10";
7
+ // src/shared/constants.ts
8
+ const PACKAGE_NAME = {
9
+ CORE: "@app-compose/core",
10
+ CODA: "@app-compose/coda"
11
+ };
12
+ const UNITS = {
13
+ CREATE_TASK: "createTask",
14
+ CREATE_WIRE: "createWire",
15
+ DEBUG: "debug",
16
+ SHAPE: "shape"
17
+ };
18
+ // src/shared/create.ts
19
+ const createRule = ESLintUtils.RuleCreator(() => "");
20
+ // src/rules/no-async-shape-callback/no-async-shape-callback.ts
21
+ const importSelector$3 = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`;
22
+ const specifierSelector$1 = `ImportSpecifier[imported.name=${UNITS.SHAPE}]`;
23
+ const callSelector$3 = `[callee.type="Identifier"][arguments.length=2]`;
24
+ var no_async_shape_callback_default = createRule({
25
+ name: "no-async-shape-callback",
26
+ meta: {
27
+ type: "problem",
28
+ docs: { description: `Disallow async callbacks in \`${UNITS.SHAPE}()\`` },
29
+ messages: { asyncCallback: `Unexpected async callback in \`${UNITS.SHAPE}()\` — async work runs outside the chain, and App-Compose cannot order it.` },
30
+ schema: [],
31
+ hasSuggestions: false
32
+ },
33
+ defaultOptions: [],
34
+ create: (context) => {
35
+ const services = ESLintUtils.getParserServices(context);
36
+ const imports = /* @__PURE__ */ new Set();
37
+ return {
38
+ [`${importSelector$3} > ${specifierSelector$1}`]: (node) => void imports.add(node.local.name),
39
+ [`CallExpression${callSelector$3}`]: (node) => {
40
+ if (!imports.has(node.callee.name)) return;
41
+ const [, fn] = node.arguments;
42
+ if (!services.getTypeAtLocation(fn).getCallSignatures().map((signature) => signature.getReturnType()).flatMap((returned) => returned.isUnion() ? returned.types : [returned]).some((type) => isPromiseLike(services.program, type))) return;
43
+ context.report({
44
+ node: fn,
45
+ messageId: "asyncCallback"
46
+ });
47
+ }
48
+ };
49
+ }
50
+ });
51
+ // src/rules/no-coda-debug/no-coda-debug.ts
52
+ const importSelector$2 = `ImportDeclaration[source.value=${PACKAGE_NAME.CODA}]`;
53
+ const specifierSelector = `ImportSpecifier[imported.name=${UNITS.DEBUG}]`;
54
+ const callSelector$2 = `[callee.type="Identifier"]`;
55
+ var no_coda_debug_default = createRule({
56
+ name: "no-coda-debug",
57
+ meta: {
58
+ type: "problem",
59
+ docs: { description: `Disallow \`${UNITS.DEBUG}()\` calls from ${PACKAGE_NAME.CODA} in committed code` },
60
+ messages: { unexpectedDebug: `Unexpected \`${UNITS.DEBUG}()\` call from ${PACKAGE_NAME.CODA}.` },
61
+ schema: [],
62
+ hasSuggestions: false
63
+ },
64
+ defaultOptions: [],
65
+ create: (context) => {
66
+ const imports = /* @__PURE__ */ new Set();
67
+ return {
68
+ [`${importSelector$2} > ${specifierSelector}`]: (node) => void imports.add(node.local.name),
69
+ [`CallExpression${callSelector$2}`]: (node) => {
70
+ if (!imports.has(node.callee.name)) return;
71
+ context.report({
72
+ node,
73
+ messageId: "unexpectedDebug"
74
+ });
75
+ }
76
+ };
77
+ }
78
+ });
79
+ // src/shared/is.ts
80
+ const isType = { scope: (type, program) => typeMatchesSpecifier(type, {
81
+ from: "package",
82
+ package: PACKAGE_NAME.CORE,
83
+ name: "Scope"
84
+ }, program) };
85
+ // src/rules/no-scope-get/no-scope-get.ts
86
+ var no_scope_get_default = createRule({
87
+ name: "no-scope-get",
88
+ meta: {
89
+ type: "suggestion",
90
+ docs: { description: "Disallow `scope.get()` calls" },
91
+ messages: { unexpectedScopeGet: "`scope.get()` can lead to imperative work outside the composition. Put the work in a Task and pass values through its context." },
92
+ schema: [],
93
+ hasSuggestions: false
94
+ },
95
+ defaultOptions: [],
96
+ create: (context) => {
97
+ const services = ESLintUtils.getParserServices(context);
98
+ return { [`CallExpression[callee.type="MemberExpression"][callee.property.type="Identifier"][callee.property.name="get"]`]: (node) => {
99
+ const type = services.getTypeAtLocation(node.callee.object);
100
+ if (!isType.scope(type, services.program)) return;
101
+ context.report({
102
+ node,
103
+ messageId: "unexpectedScopeGet"
104
+ });
105
+ } };
106
+ }
107
+ });
108
+ // src/shared/ast.ts
109
+ const PLAIN_PROP = esquery.parse(`Property[kind="init"][method=false][computed=false][key.type="Identifier"]`);
110
+ const isPlainProp = (prop) => esquery.matches(prop, PLAIN_PROP);
111
+ const isSpread = ASTUtils.isNodeOfType(AST_NODE_TYPES.SpreadElement);
112
+ // src/rules/task-options-order/task-options-order.ts
113
+ const ORDER = [
114
+ "name",
115
+ "run",
116
+ "run.context",
117
+ "run.fn",
118
+ "enabled",
119
+ "enabled.context",
120
+ "enabled.fn"
121
+ ];
122
+ const rankOf = (key) => {
123
+ const index = ORDER.indexOf(key);
124
+ return index === -1 ? Infinity : index;
125
+ };
126
+ const hasNested = (key) => ORDER.some((entry) => entry.startsWith(`${key}.`));
127
+ const importSelector$1 = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`;
128
+ const methodSelector$1 = `ImportSpecifier[imported.name=${UNITS.CREATE_TASK}]`;
129
+ const callSelector$1 = `[callee.type="Identifier"][arguments.length=1]`;
130
+ const argumentSelector$1 = `ObjectExpression.arguments`;
131
+ var task_options_order_default = createRule({
132
+ name: "task-options-order",
133
+ meta: {
134
+ type: "problem",
135
+ docs: { description: `Enforce options order for ${UNITS.CREATE_TASK}` },
136
+ messages: { invalidOrder: `Order of options should be \`{{ correctOrder }}\`, but found \`{{ currentOrder }}\`.` },
137
+ schema: [],
138
+ hasSuggestions: false,
139
+ fixable: "code"
140
+ },
141
+ defaultOptions: [],
142
+ create: (context) => {
143
+ const source = context.sourceCode;
144
+ const imports = /* @__PURE__ */ new Set();
145
+ return {
146
+ [`${importSelector$1} > ${methodSelector$1}`]: (node) => void imports.add(node.local.name),
147
+ [`CallExpression${callSelector$1}:has(> ${argumentSelector$1})`]: (node) => {
148
+ if (!imports.has(node.callee.name)) return;
149
+ const [config] = node.arguments;
150
+ if (!isReorderable(config)) return;
151
+ const keys = orderKeys(config);
152
+ if (isOrdered(keys)) return;
153
+ const data = {
154
+ correctOrder: keys.toSorted((a, b) => rankOf(a) - rankOf(b)).join(" -> "),
155
+ currentOrder: keys.join(" -> ")
156
+ };
157
+ const fixed = rebuild(config, null, source);
158
+ context.report({
159
+ node: config,
160
+ messageId: "invalidOrder",
161
+ data,
162
+ fix: fixed === null ? void 0 : (fixer) => fixer.replaceText(config, fixed)
163
+ });
164
+ }
165
+ };
166
+ }
167
+ });
168
+ const isLeadingSpread = (props, index) => props.slice(0, index).every(isSpread);
169
+ const isTrailingSpread = (props, index) => props.slice(index + 1).every(isSpread);
170
+ const isReorderable = (config) => config.properties.every((prop, index, props) => isSpread(prop) ? isLeadingSpread(props, index) || isTrailingSpread(props, index) : isPlainProp(prop));
171
+ const orderKeys = (config) => config.properties.flatMap((prop) => !isPlainProp(prop) ? [] : prop.value.type === AST_NODE_TYPES.ObjectExpression ? prop.value.properties.filter(isPlainProp).map((nested) => `${prop.key.name}.${nested.key.name}`) : [prop.key.name]);
172
+ const isOrdered = (keys) => {
173
+ const sorted = keys.toSorted((a, b) => rankOf(a) - rankOf(b));
174
+ return keys.every((key, index) => key === sorted[index]);
175
+ };
176
+ const entryOf = ({ prop, index, props, group, source }) => {
177
+ if (isSpread(prop)) {
178
+ if (isTrailingSpread(props, index)) return {
179
+ rank: Infinity,
180
+ text: source.getText(prop)
181
+ };
182
+ if (isLeadingSpread(props, index)) return {
183
+ rank: -Infinity,
184
+ text: source.getText(prop)
185
+ };
186
+ return null;
187
+ }
188
+ if (!isPlainProp(prop)) return null;
189
+ const key = group === null ? prop.key.name : `${group}.${prop.key.name}`;
190
+ if (group === null && hasNested(prop.key.name) && prop.value.type === AST_NODE_TYPES.ObjectExpression) {
191
+ const inner = rebuild(prop.value, prop.key.name, source);
192
+ return inner === null ? null : {
193
+ rank: rankOf(key),
194
+ text: `${prop.key.name}: ${inner}`
195
+ };
196
+ }
197
+ return {
198
+ rank: rankOf(key),
199
+ text: source.getText(prop)
200
+ };
201
+ };
202
+ const rebuild = (obj, group, source) => {
203
+ const entries = [];
204
+ for (const [index, prop] of obj.properties.entries()) {
205
+ const entry = entryOf({
206
+ prop,
207
+ index,
208
+ props: obj.properties,
209
+ group,
210
+ source
211
+ });
212
+ if (entry === null) return null;
213
+ entries.push(entry);
214
+ }
215
+ const texts = entries.toSorted((a, b) => a.rank - b.rank).map((entry) => entry.text);
216
+ return group === null ? `{\n${texts.join(",\n")}\n}` : `{ ${texts.join(", ")} }`;
217
+ };
218
+ // src/rules/wire-options-order/wire-options-order.ts
219
+ const importSelector = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`;
220
+ const methodSelector = `ImportSpecifier[imported.name=${UNITS.CREATE_WIRE}]`;
221
+ const callSelector = `[callee.type="Identifier"][arguments.length=1]`;
222
+ const argumentSelector = `ObjectExpression.arguments[properties.length=2]`;
223
+ var wire_options_order_default = createRule({
224
+ name: "wire-options-order",
225
+ meta: {
226
+ type: "problem",
227
+ docs: { description: `Enforce options order for ${UNITS.CREATE_WIRE}` },
228
+ messages: { invalidOrder: `Order of options should be \`from -> to\`, but found \`to -> from\`.` },
229
+ schema: [],
230
+ hasSuggestions: false,
231
+ fixable: "code"
232
+ },
233
+ defaultOptions: [],
234
+ create: (context) => {
235
+ const source = context.sourceCode;
236
+ const imports = /* @__PURE__ */ new Set();
237
+ return {
238
+ [`${importSelector} > ${methodSelector}`]: (node) => void imports.add(node.local.name),
239
+ [`CallExpression${callSelector}:has(> ${argumentSelector})`]: (node) => {
240
+ if (!imports.has(node.callee.name)) return;
241
+ const [config] = node.arguments;
242
+ const [first, second] = config.properties;
243
+ if (!first || !second || !isPlainProp(first) || !isPlainProp(second)) return;
244
+ if (first.key.name === "from") return;
245
+ context.report({
246
+ node: config,
247
+ messageId: "invalidOrder",
248
+ fix: (fixer) => fixer.replaceText(config, `{\nfrom: ${source.getText(second.value)},\nto: ${source.getText(first.value)}\n}`)
249
+ });
250
+ }
251
+ };
252
+ }
253
+ });
254
+ const ruleset = { recommended: {
255
+ "app-compose/no-async-shape-callback": "error",
256
+ "app-compose/no-coda-debug": "error",
257
+ "app-compose/task-options-order": "warn",
258
+ "app-compose/wire-options-order": "warn"
259
+ } };
260
+ // src/index.ts
261
+ const base = {
262
+ meta: {
263
+ name,
264
+ version,
265
+ namespace: "app-compose"
266
+ },
267
+ rules: {
268
+ "no-async-shape-callback": no_async_shape_callback_default,
269
+ "no-coda-debug": no_coda_debug_default,
270
+ "no-scope-get": no_scope_get_default,
271
+ "task-options-order": task_options_order_default,
272
+ "wire-options-order": wire_options_order_default
273
+ }
274
+ };
275
+ const configs = { recommended: {
276
+ plugins: { "app-compose": base },
277
+ rules: ruleset.recommended
278
+ } };
279
+ const plugin = base;
280
+ plugin.configs = configs;
281
+ export { plugin as default };
282
+
283
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["importSelector","specifierSelector","callSelector","importSelector","callSelector","NodeType","importSelector","methodSelector","callSelector","argumentSelector","NodeType","noAsyncShapeCallback","noCodaDebug","noScopeGet","taskOptionsOrder","wireOptionsOrder"],"sources":["../package.json","../src/shared/constants.ts","../src/shared/create.ts","../src/rules/no-async-shape-callback/no-async-shape-callback.ts","../src/rules/no-coda-debug/no-coda-debug.ts","../src/shared/is.ts","../src/rules/no-scope-get/no-scope-get.ts","../src/shared/ast.ts","../src/rules/task-options-order/task-options-order.ts","../src/rules/wire-options-order/wire-options-order.ts","../src/ruleset.ts","../src/index.ts"],"sourcesContent":["","const PACKAGE_NAME = {\n CORE: \"@app-compose/core\",\n CODA: \"@app-compose/coda\",\n}\n\nconst UNITS = {\n CREATE_TASK: \"createTask\",\n CREATE_WIRE: \"createWire\",\n DEBUG: \"debug\",\n SHAPE: \"shape\",\n}\n\nexport { PACKAGE_NAME, UNITS }\n","import { ESLintUtils } from \"@typescript-eslint/utils\"\n\nexport const createRule = ESLintUtils.RuleCreator(() => \"\")\n","import { isPromiseLike } from \"@typescript-eslint/type-utils\"\nimport { ESLintUtils, type TSESTree as Node } from \"@typescript-eslint/utils\"\nimport { PACKAGE_NAME, UNITS } from \"@/shared/constants\"\nimport { createRule } from \"@/shared/create\"\n\nconst importSelector = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`\nconst specifierSelector = `ImportSpecifier[imported.name=${UNITS.SHAPE}]`\nconst callSelector = `[callee.type=\"Identifier\"][arguments.length=2]`\n\nexport default createRule({\n name: \"no-async-shape-callback\",\n meta: {\n type: \"problem\",\n docs: {\n description: `Disallow async callbacks in \\`${UNITS.SHAPE}()\\``,\n },\n messages: {\n asyncCallback: `Unexpected async callback in \\`${UNITS.SHAPE}()\\` — async work runs outside the chain, and App-Compose cannot order it.`,\n },\n schema: [],\n hasSuggestions: false,\n },\n defaultOptions: [],\n create: (context) => {\n const services = ESLintUtils.getParserServices(context)\n const imports = new Set<string>()\n\n type ShapeCall = Node.CallExpression & {\n callee: Node.Identifier\n arguments: [Node.CallExpressionArgument, Node.CallExpressionArgument]\n }\n\n return {\n [`${importSelector} > ${specifierSelector}`]: (node: Node.ImportSpecifier) => void imports.add(node.local.name),\n\n [`CallExpression${callSelector}`]: (node: ShapeCall) => {\n if (!imports.has(node.callee.name)) return\n\n const [, fn] = node.arguments\n const returnsPromise = services\n .getTypeAtLocation(fn)\n .getCallSignatures()\n .map((signature) => signature.getReturnType())\n .flatMap((returned) => (returned.isUnion() ? returned.types : [returned]))\n .some((type) => isPromiseLike(services.program, type))\n\n if (!returnsPromise) return\n\n context.report({ node: fn, messageId: \"asyncCallback\" })\n },\n }\n },\n})\n","import type { TSESTree as Node } from \"@typescript-eslint/utils\"\nimport { PACKAGE_NAME, UNITS } from \"@/shared/constants\"\nimport { createRule } from \"@/shared/create\"\n\nconst importSelector = `ImportDeclaration[source.value=${PACKAGE_NAME.CODA}]`\nconst specifierSelector = `ImportSpecifier[imported.name=${UNITS.DEBUG}]`\nconst callSelector = `[callee.type=\"Identifier\"]`\n\nexport default createRule({\n name: \"no-coda-debug\",\n meta: {\n type: \"problem\",\n docs: {\n description: `Disallow \\`${UNITS.DEBUG}()\\` calls from ${PACKAGE_NAME.CODA} in committed code`,\n },\n messages: {\n unexpectedDebug: `Unexpected \\`${UNITS.DEBUG}()\\` call from ${PACKAGE_NAME.CODA}.`,\n },\n schema: [],\n hasSuggestions: false,\n },\n defaultOptions: [],\n create: (context) => {\n const imports = new Set<string>()\n\n type DebugCall = Node.CallExpression & { callee: Node.Identifier }\n\n return {\n [`${importSelector} > ${specifierSelector}`]: (node: Node.ImportSpecifier) => void imports.add(node.local.name),\n\n [`CallExpression${callSelector}`]: (node: DebugCall) => {\n if (!imports.has(node.callee.name)) return\n context.report({ node, messageId: \"unexpectedDebug\" })\n },\n }\n },\n})\n","import type { Program, Type } from \"typescript\"\nimport { typeMatchesSpecifier } from \"@typescript-eslint/type-utils\"\nimport { PACKAGE_NAME } from \"@/shared/constants\"\n\nconst isType = {\n scope: (type: Type, program: Program) =>\n typeMatchesSpecifier(type, { from: \"package\", package: PACKAGE_NAME.CORE, name: \"Scope\" }, program),\n}\n\nexport { isType }\n","import { ESLintUtils, type TSESTree as Node } from \"@typescript-eslint/utils\"\nimport { createRule } from \"@/shared/create\"\nimport { isType } from \"@/shared/is\"\n\nexport default createRule({\n name: \"no-scope-get\",\n meta: {\n type: \"suggestion\",\n docs: {\n description: \"Disallow `scope.get()` calls\",\n },\n messages: {\n unexpectedScopeGet:\n \"`scope.get()` can lead to imperative work outside the composition. Put the work in a Task and pass values through its context.\",\n },\n schema: [],\n hasSuggestions: false,\n },\n defaultOptions: [],\n create: (context) => {\n const services = ESLintUtils.getParserServices(context)\n\n type ScopeGetCall = Node.CallExpression & { callee: Node.MemberExpression & { property: Node.Identifier } }\n\n return {\n [`CallExpression[callee.type=\"MemberExpression\"][callee.property.type=\"Identifier\"][callee.property.name=\"get\"]`]:\n (node: ScopeGetCall) => {\n const type = services.getTypeAtLocation(node.callee.object)\n\n const isScope = isType.scope(type, services.program)\n if (!isScope) return\n\n context.report({ node, messageId: \"unexpectedScopeGet\" })\n },\n }\n },\n})\n","import { AST_NODE_TYPES as NodeType, ASTUtils, type TSESTree as Node } from \"@typescript-eslint/utils\"\nimport esquery from \"esquery\"\n\ntype KeyedProp = Node.Property & { key: Node.Identifier }\n\n// A plain `key: value` (or shorthand) property — the shape the options-order rules relocate by name.\n// Matched with an esquery selector, like the rules' node matches; the `prop is KeyedProp` annotation\n// keeps `.filter`/`.find` callers narrowed. Spreads, getters/setters, methods and computed keys miss.\nconst PLAIN_PROP = esquery.parse(`Property[kind=\"init\"][method=false][computed=false][key.type=\"Identifier\"]`)\nconst isPlainProp = (prop: Node.ObjectLiteralElement): prop is KeyedProp =>\n esquery.matches(prop as unknown as Parameters<typeof esquery.matches>[0], PLAIN_PROP)\n\n// A spread element (`...rest`) inside an object literal. It carries no key of its own, so it anchors a\n// position rather than taking part in key ordering.\nconst isSpread = ASTUtils.isNodeOfType(NodeType.SpreadElement)\n\nexport { isPlainProp, isSpread }\n","import { type TSESTree as Node, AST_NODE_TYPES as NodeType, type TSESLint } from \"@typescript-eslint/utils\"\nimport { isPlainProp, isSpread } from \"@/shared/ast\"\nimport { PACKAGE_NAME, UNITS } from \"@/shared/constants\"\nimport { createRule } from \"@/shared/create\"\n\n// Canonical key order, flat: every option, top-level groups and their nested keys, in one list. A\n// `run`/`enabled` ranks at its group slot when opaque (shorthand, variable, …) and at its leaf slots\n// when inline; a config holds one form or the other, so the two never collide.\nconst ORDER = [\"name\", \"run\", \"run.context\", \"run.fn\", \"enabled\", \"enabled.context\", \"enabled.fn\"]\nconst rankOf = (key: string) => {\n const index = ORDER.indexOf(key)\n return index === -1 ? Infinity : index\n}\n// `run`/`enabled` carry nested keys; `name` does not. An inline group is rebuilt from its leaves, an\n// opaque one (shorthand, variable) ranks at its group slot and stays whole.\nconst hasNested = (key: string) => ORDER.some((entry) => entry.startsWith(`${key}.`))\n\nconst importSelector = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`\nconst methodSelector = `ImportSpecifier[imported.name=${UNITS.CREATE_TASK}]`\n\nconst callSelector = `[callee.type=\"Identifier\"][arguments.length=1]`\n// Direct child, not a descendant: matches `createTask({ … })` but not `createTask(factory({ … }))`,\n// where the object literal sits inside a nested call's arguments rather than createTask's own.\nconst argumentSelector = `ObjectExpression.arguments`\n\nexport default createRule({\n name: \"task-options-order\",\n meta: {\n type: \"problem\",\n docs: {\n description: `Enforce options order for ${UNITS.CREATE_TASK}`,\n },\n messages: {\n invalidOrder: `Order of options should be \\`{{ correctOrder }}\\`, but found \\`{{ currentOrder }}\\`.`,\n },\n schema: [],\n hasSuggestions: false,\n fixable: \"code\",\n },\n defaultOptions: [],\n create: (context) => {\n const source = context.sourceCode\n const imports = new Set<string>()\n\n // The selector guarantees a single object-literal argument, so `config` is an ObjectExpression.\n type MethodCall = Node.CallExpression & { callee: Node.Identifier; arguments: [Node.ObjectExpression] }\n\n return {\n [`${importSelector} > ${methodSelector}`]: (node: Node.ImportSpecifier) => void imports.add(node.local.name),\n\n [`CallExpression${callSelector}:has(> ${argumentSelector})`]: (node: MethodCall) => {\n if (!imports.has(node.callee.name)) return\n\n const [config] = node.arguments\n // The order is undeterminable when a spread sits between options (it could inject any key) or\n // an exotic entry (computed key, getter, method) hides a name — so we don't report. Unknown\n // plain keys are fine: they just sort to the end.\n if (!isReorderable(config)) return\n\n const keys = orderKeys(config)\n if (isOrdered(keys)) return\n\n const data = {\n correctOrder: keys.toSorted((a, b) => rankOf(a) - rankOf(b)).join(\" -> \"),\n currentOrder: keys.join(\" -> \"),\n }\n\n // One pass relocates the real nodes, so shorthand/spread/comments survive. `rebuild` returns\n // null when a nested key would have to cross a spread (position is load-bearing there): we\n // report the violation but leave the fix to a human.\n const fixed = rebuild(config, null, source)\n context.report({\n node: config,\n messageId: \"invalidOrder\",\n data,\n fix: fixed === null ? undefined : (fixer) => fixer.replaceText(config, fixed),\n })\n },\n }\n },\n})\n\ntype Element = Node.ObjectExpression[\"properties\"][number]\ntype Entry = { rank: number; text: string }\n\n// A spread anchors a boundary — keys never cross it — so it only fits at the head or tail of a config.\nconst isLeadingSpread = (props: Element[], index: number) => props.slice(0, index).every(isSpread)\nconst isTrailingSpread = (props: Element[], index: number) => props.slice(index + 1).every(isSpread)\n\n// Can we reason about the top-level order? Every entry must be a plain key (known or unknown) or a\n// spread anchored at the head/tail. An interior spread or an exotic entry hides where options sit.\nconst isReorderable = (config: Node.ObjectExpression) =>\n config.properties.every((prop, index, props) =>\n isSpread(prop) ? isLeadingSpread(props, index) || isTrailingSpread(props, index) : isPlainProp(prop),\n )\n\n// The visible dotted keys in source order, for the message and the ordered check. A `run`/`enabled`\n// object expands into its nested keys; every other plain key contributes its own; spreads carry none.\nconst orderKeys = (config: Node.ObjectExpression): string[] =>\n config.properties.flatMap((prop) =>\n !isPlainProp(prop)\n ? []\n : prop.value.type === NodeType.ObjectExpression\n ? prop.value.properties.filter(isPlainProp).map((nested) => `${prop.key.name}.${nested.key.name}`)\n : [prop.key.name],\n )\n\n// Already canonical? A stable sort leaves equal ranks (unknown keys, multiple spreads) in place, so an\n// ordered config sorts to itself.\nconst isOrdered = (keys: string[]) => {\n const sorted = keys.toSorted((a, b) => rankOf(a) - rankOf(b))\n return keys.every((key, index) => key === sorted[index])\n}\n\n// Sort rank and source text for one entry, or null when it can't be reordered safely. A spread anchors\n// at the head (-Infinity) or tail (Infinity); an unknown key sorts to the end (Infinity); an inline\n// `run`/`enabled` is rebuilt recursively (null if its own keys would cross a spread); the rest is\n// emitted verbatim, so shorthand and comments survive.\ntype EntryOfParams = {\n prop: Element\n index: number\n props: Element[]\n group: string | null\n source: Readonly<TSESLint.SourceCode>\n}\n\nconst entryOf = ({ prop, index, props, group, source }: EntryOfParams): Entry | null => {\n if (isSpread(prop)) {\n if (isTrailingSpread(props, index)) return { rank: Infinity, text: source.getText(prop) }\n if (isLeadingSpread(props, index)) return { rank: -Infinity, text: source.getText(prop) }\n return null\n }\n if (!isPlainProp(prop)) return null\n\n const key = group === null ? prop.key.name : `${group}.${prop.key.name}`\n\n if (group === null && hasNested(prop.key.name) && prop.value.type === NodeType.ObjectExpression) {\n const inner = rebuild(prop.value, prop.key.name, source)\n return inner === null ? null : { rank: rankOf(key), text: `${prop.key.name}: ${inner}` }\n }\n\n return { rank: rankOf(key), text: source.getText(prop) }\n}\n\n// Canonical source text for an object literal, or null when an entry can't be reordered safely. The top\n// level (group null) prints one entry per line; a nested `run`/`enabled` stays inline.\nconst rebuild = (\n obj: Node.ObjectExpression,\n group: string | null,\n source: Readonly<TSESLint.SourceCode>,\n): string | null => {\n const entries: Entry[] = []\n for (const [index, prop] of obj.properties.entries()) {\n const entry = entryOf({ prop, index, props: obj.properties, group, source })\n if (entry === null) return null\n entries.push(entry)\n }\n\n const texts = entries.toSorted((a, b) => a.rank - b.rank).map((entry) => entry.text)\n return group === null ? `{\\n${texts.join(\",\\n\")}\\n}` : `{ ${texts.join(\", \")} }`\n}\n","import type { TSESTree as Node } from \"@typescript-eslint/utils\"\nimport { isPlainProp } from \"@/shared/ast\"\nimport { PACKAGE_NAME, UNITS } from \"@/shared/constants\"\nimport { createRule } from \"@/shared/create\"\n\nconst importSelector = `ImportDeclaration[source.value=${PACKAGE_NAME.CORE}]`\nconst methodSelector = `ImportSpecifier[imported.name=${UNITS.CREATE_WIRE}]`\nconst callSelector = `[callee.type=\"Identifier\"][arguments.length=1]`\n// Direct child, not a descendant: matches `createWire({ … })` but not `createWire(buildWire({ … }))`,\n// where the object literal sits inside a nested call. The two-property count is a cheap structural\n// predicate, so it rides along in the selector; the shape of those two entries is narrowed in the body.\nconst argumentSelector = `ObjectExpression.arguments[properties.length=2]`\n\nexport default createRule({\n name: \"wire-options-order\",\n meta: {\n type: \"problem\",\n docs: {\n description: `Enforce options order for ${UNITS.CREATE_WIRE}`,\n },\n messages: {\n invalidOrder: `Order of options should be \\`from -> to\\`, but found \\`to -> from\\`.`,\n },\n schema: [],\n hasSuggestions: false,\n fixable: \"code\",\n },\n defaultOptions: [],\n create: (context) => {\n const source = context.sourceCode\n const imports = new Set<string>()\n\n // The selector guarantees a single object-literal argument with exactly two properties, so\n // `config` is an ObjectExpression; the shape of those two entries is still narrowed in the body.\n type MethodCall = Node.CallExpression & { callee: Node.Identifier; arguments: [Node.ObjectExpression] }\n\n return {\n [`${importSelector} > ${methodSelector}`]: (node: Node.ImportSpecifier) => void imports.add(node.local.name),\n\n [`CallExpression${callSelector}:has(> ${argumentSelector})`]: (node: MethodCall) => {\n if (!imports.has(node.callee.name)) return\n\n const [config] = node.arguments\n const [first, second] = config.properties\n\n if (!first || !second || !isPlainProp(first) || !isPlainProp(second)) return\n\n if (first.key.name === \"from\") return\n\n context.report({\n node: config,\n messageId: \"invalidOrder\",\n fix: (fixer) =>\n fixer.replaceText(\n config,\n `{\\nfrom: ${source.getText(second.value)},\\nto: ${source.getText(first.value)}\\n}`,\n ),\n })\n },\n }\n },\n})\n","import type { TSESLint } from \"@typescript-eslint/utils\"\n\nconst recommended = {\n \"app-compose/no-async-shape-callback\": \"error\",\n \"app-compose/no-coda-debug\": \"error\",\n \"app-compose/task-options-order\": \"warn\",\n \"app-compose/wire-options-order\": \"warn\",\n} satisfies TSESLint.Linter.RulesRecord\n\nexport const ruleset = { recommended }\n","import type { TSESLint } from \"@typescript-eslint/utils\"\nimport { name, version } from \"../package.json\"\nimport noAsyncShapeCallback from \"./rules/no-async-shape-callback/no-async-shape-callback\"\nimport noCodaDebug from \"./rules/no-coda-debug/no-coda-debug\"\nimport noScopeGet from \"./rules/no-scope-get/no-scope-get\"\nimport taskOptionsOrder from \"./rules/task-options-order/task-options-order\"\nimport wireOptionsOrder from \"./rules/wire-options-order/wire-options-order\"\nimport { ruleset } from \"./ruleset\"\n\nconst base = {\n meta: { name, version, namespace: \"app-compose\" },\n rules: {\n \"no-async-shape-callback\": noAsyncShapeCallback,\n \"no-coda-debug\": noCodaDebug,\n \"no-scope-get\": noScopeGet,\n \"task-options-order\": taskOptionsOrder,\n \"wire-options-order\": wireOptionsOrder,\n },\n}\n\nconst configs = {\n recommended: { plugins: { \"app-compose\": base as TSESLint.FlatConfig.Plugin }, rules: ruleset.recommended },\n}\n\nconst plugin = base as typeof base & { configs: typeof configs }\n\nplugin.configs = configs\n\nexport default plugin\n"],"mappings":";;;;;;;ACAA,MAAM,eAAe;CACnB,MAAM;CACN,MAAM;AACR;AAEA,MAAM,QAAQ;CACZ,aAAa;CACb,aAAa;CACb,OAAO;CACP,OAAO;AACT;;ACRA,MAAa,aAAa,YAAY,kBAAkB,EAAE;;ACG1D,MAAMA,mBAAiB,kCAAkC,aAAa,KAAK;AAC3E,MAAMC,sBAAoB,iCAAiC,MAAM,MAAM;AACvE,MAAMC,iBAAe;AAErB,IAAA,kCAAe,WAAW;CACxB,MAAM;CACN,MAAM;EACJ,MAAM;EACN,MAAM,EACJ,aAAa,iCAAiC,MAAM,MAAM,MAC5D;EACA,UAAU,EACR,eAAe,kCAAkC,MAAM,MAAM,4EAC/D;EACA,QAAQ,CAAC;EACT,gBAAgB;CAClB;CACA,gBAAgB,CAAC;CACjB,SAAS,YAAY;EACnB,MAAM,WAAW,YAAY,kBAAkB,OAAO;EACtD,MAAM,0BAAU,IAAI,IAAY;EAOhC,OAAO;IACJ,GAAGF,iBAAe,KAAKC,yBAAuB,SAA+B,KAAK,QAAQ,IAAI,KAAK,MAAM,IAAI;IAE7G,iBAAiBC,oBAAkB,SAAoB;IACtD,IAAI,CAAC,QAAQ,IAAI,KAAK,OAAO,IAAI,GAAG;IAEpC,MAAM,GAAG,MAAM,KAAK;IAQpB,IAAI,CAPmB,SACpB,kBAAkB,EAAE,CAAC,CACrB,kBAAkB,CAAC,CACnB,KAAK,cAAc,UAAU,cAAc,CAAC,CAAC,CAC7C,SAAS,aAAc,SAAS,QAAQ,IAAI,SAAS,QAAQ,CAAC,QAAQ,CAAE,C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AAM,SAAS;AAEf,OAAO,UAAU"}
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "@app-compose/eslint-plugin",
3
+ "version": "3.0.0-beta.10",
4
+ "private": false,
5
+ "description": "Enforcing best practices for @app-compose",
6
+ "keywords": [
7
+ "app-compose",
8
+ "eslint",
9
+ "eslint-plugin",
10
+ "eslintplugin",
11
+ "grlt",
12
+ "grlt-hub"
13
+ ],
14
+ "homepage": "https://app-compose.dev",
15
+ "license": "MIT",
16
+ "contributors": [
17
+ {
18
+ "name": "Mikhail Kireev",
19
+ "url": "https://github.com/kireevmp"
20
+ },
21
+ {
22
+ "name": "Viktor Pasynok",
23
+ "url": "https://github.com/binjospookie"
24
+ }
25
+ ],
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/grlt-hub/app-compose.git"
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "type": "module",
34
+ "main": "dist/index.cjs",
35
+ "module": "./dist/index.mjs",
36
+ "types": "./dist/index.d.cts",
37
+ "exports": {
38
+ ".": {
39
+ "import": {
40
+ "types": "./dist/index.d.mts",
41
+ "default": "./dist/index.mjs"
42
+ },
43
+ "require": {
44
+ "types": "./dist/index.d.cts",
45
+ "default": "./dist/index.cjs"
46
+ }
47
+ },
48
+ "./package.json": "./package.json"
49
+ },
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "dependencies": {
54
+ "@typescript-eslint/type-utils": "^8.58.0",
55
+ "@typescript-eslint/utils": "^8.58.0",
56
+ "esquery": "^1"
57
+ },
58
+ "devDependencies": {
59
+ "@types/esquery": "^1.5.4",
60
+ "@typescript-eslint/rule-tester": "8.70.1",
61
+ "eslint": "^10.13.0",
62
+ "@app-compose/coda": "3.0.0-beta.10",
63
+ "@app-compose/core": "3.0.0-beta.10"
64
+ },
65
+ "peerDependencies": {
66
+ "eslint": "^9.0.0 || ^10.0.0",
67
+ "typescript": "^5.0.0 || ^6.0.0"
68
+ },
69
+ "scripts": {
70
+ "build": "pnpm typecheck && tsdown",
71
+ "typecheck": "tsgo --noEmit -p tsconfig.json",
72
+ "dev": "tsdown --watch",
73
+ "test": "vitest run",
74
+ "lint": "knip && oxlint ./src",
75
+ "lint:fix": "oxlint --fix ./src"
76
+ }
77
+ }