@ripple-ts/eslint-plugin 0.2.178 → 0.2.179

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.
@@ -13,9 +13,10 @@ declare const plugin: {
13
13
  'unbox-tracked-values': eslint0.Rule.RuleModule;
14
14
  'control-flow-jsx': eslint0.Rule.RuleModule;
15
15
  'no-introspect-in-modules': eslint0.Rule.RuleModule;
16
+ 'valid-for-of-key': eslint0.Rule.RuleModule;
16
17
  };
17
18
  configs: any;
18
19
  };
19
20
  //#endregion
20
21
  export { plugin as default };
21
- //# sourceMappingURL=index-BjnSX0QC.d.ts.map
22
+ //# sourceMappingURL=index-DcKta1tZ.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DcKta1tZ.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;cASM;;;IAAA,OAeL,EAAA,MAAA;EAAA,CAAA"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from "module";
2
2
 
3
3
  //#region src/rules/no-module-scope-track.ts
4
- const rule$5 = {
4
+ const rule$6 = {
5
5
  meta: {
6
6
  type: "problem",
7
7
  docs: {
@@ -37,11 +37,11 @@ const rule$5 = {
37
37
  };
38
38
  }
39
39
  };
40
- var no_module_scope_track_default = rule$5;
40
+ var no_module_scope_track_default = rule$6;
41
41
 
42
42
  //#endregion
43
43
  //#region src/rules/prefer-oninput.ts
44
- const rule$4 = {
44
+ const rule$5 = {
45
45
  meta: {
46
46
  type: "suggestion",
47
47
  docs: {
@@ -85,11 +85,11 @@ const rule$4 = {
85
85
  };
86
86
  }
87
87
  };
88
- var prefer_oninput_default = rule$4;
88
+ var prefer_oninput_default = rule$5;
89
89
 
90
90
  //#endregion
91
91
  //#region src/rules/no-return-in-component.ts
92
- const rule$3 = {
92
+ const rule$4 = {
93
93
  meta: {
94
94
  type: "problem",
95
95
  docs: {
@@ -126,11 +126,11 @@ const rule$3 = {
126
126
  };
127
127
  }
128
128
  };
129
- var no_return_in_component_default = rule$3;
129
+ var no_return_in_component_default = rule$4;
130
130
 
131
131
  //#endregion
132
132
  //#region src/rules/unbox-tracked-values.ts
133
- const rule$2 = {
133
+ const rule$3 = {
134
134
  meta: {
135
135
  type: "problem",
136
136
  docs: {
@@ -174,11 +174,11 @@ const rule$2 = {
174
174
  };
175
175
  }
176
176
  };
177
- var unbox_tracked_values_default = rule$2;
177
+ var unbox_tracked_values_default = rule$3;
178
178
 
179
179
  //#endregion
180
180
  //#region src/rules/control-flow-jsx.ts
181
- const rule$1 = {
181
+ const rule$2 = {
182
182
  meta: {
183
183
  type: "problem",
184
184
  docs: {
@@ -241,11 +241,11 @@ const rule$1 = {
241
241
  };
242
242
  }
243
243
  };
244
- var control_flow_jsx_default = rule$1;
244
+ var control_flow_jsx_default = rule$2;
245
245
 
246
246
  //#endregion
247
247
  //#region src/rules/no-introspect-in-modules.ts
248
- const rule = {
248
+ const rule$1 = {
249
249
  meta: {
250
250
  type: "problem",
251
251
  docs: {
@@ -267,7 +267,87 @@ const rule = {
267
267
  } };
268
268
  }
269
269
  };
270
- var no_introspect_in_modules_default = rule;
270
+ var no_introspect_in_modules_default = rule$1;
271
+
272
+ //#endregion
273
+ //#region src/rules/valid-for-of-key.ts
274
+ const rule = {
275
+ meta: {
276
+ type: "problem",
277
+ docs: {
278
+ description: "Ensure variables used in for..of key expression are defined",
279
+ recommended: true
280
+ },
281
+ messages: { undefinedVariable: "Variable '{{name}}' is not defined." },
282
+ schema: []
283
+ },
284
+ create(context) {
285
+ return { ForOfStatement(node) {
286
+ if (!node.key) return;
287
+ const checkIdentifier = (identifier) => {
288
+ if (!findVariable(context.sourceCode.getScope(node), identifier.name)) context.report({
289
+ node: identifier,
290
+ messageId: "undefinedVariable",
291
+ data: { name: identifier.name }
292
+ });
293
+ };
294
+ const traverse = (node$1) => {
295
+ if (!node$1) return;
296
+ switch (node$1.type) {
297
+ case "Identifier":
298
+ checkIdentifier(node$1);
299
+ break;
300
+ case "MemberExpression":
301
+ traverse(node$1.object);
302
+ if (node$1.computed) traverse(node$1.property);
303
+ break;
304
+ case "BinaryExpression":
305
+ case "LogicalExpression":
306
+ traverse(node$1.left);
307
+ traverse(node$1.right);
308
+ break;
309
+ case "UnaryExpression":
310
+ traverse(node$1.argument);
311
+ break;
312
+ case "CallExpression":
313
+ traverse(node$1.callee);
314
+ node$1.arguments.forEach(traverse);
315
+ break;
316
+ case "ArrayExpression":
317
+ node$1.elements.forEach(traverse);
318
+ break;
319
+ case "ObjectExpression":
320
+ node$1.properties.forEach((prop) => {
321
+ if (prop.type === "Property") {
322
+ if (prop.computed) traverse(prop.key);
323
+ traverse(prop.value);
324
+ } else if (prop.type === "SpreadElement") traverse(prop.argument);
325
+ });
326
+ break;
327
+ case "ConditionalExpression":
328
+ traverse(node$1.test);
329
+ traverse(node$1.consequent);
330
+ traverse(node$1.alternate);
331
+ break;
332
+ case "TemplateLiteral":
333
+ node$1.expressions.forEach(traverse);
334
+ break;
335
+ }
336
+ };
337
+ traverse(node.key);
338
+ } };
339
+ }
340
+ };
341
+ function findVariable(scope, name) {
342
+ let currentScope = scope;
343
+ while (currentScope) {
344
+ const variable = currentScope.variables.find((v) => v.name === name);
345
+ if (variable) return variable;
346
+ currentScope = currentScope.upper;
347
+ }
348
+ return null;
349
+ }
350
+ var valid_for_of_key_default = rule;
271
351
 
272
352
  //#endregion
273
353
  //#region src/index.ts
@@ -282,7 +362,8 @@ const plugin = {
282
362
  "no-return-in-component": no_return_in_component_default,
283
363
  "unbox-tracked-values": unbox_tracked_values_default,
284
364
  "control-flow-jsx": control_flow_jsx_default,
285
- "no-introspect-in-modules": no_introspect_in_modules_default
365
+ "no-introspect-in-modules": no_introspect_in_modules_default,
366
+ "valid-for-of-key": valid_for_of_key_default
286
367
  },
287
368
  configs: {}
288
369
  };
@@ -310,7 +391,8 @@ function createConfig(name, files, parser) {
310
391
  "ripple/no-return-in-component": "error",
311
392
  "ripple/unbox-tracked-values": "error",
312
393
  "ripple/control-flow-jsx": "error",
313
- "ripple/no-introspect-in-modules": "error"
394
+ "ripple/no-introspect-in-modules": "error",
395
+ "ripple/valid-for-of-key": "error"
314
396
  }
315
397
  };
316
398
  if (parser) config.languageOptions = {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","noModuleScopeTrack","preferOnInput","noReturnInComponent","unboxTrackedValues","controlFlowJsx","noIntrospectInModules","rippleParser: any","tsParser: any","config: any"],"sources":["../src/rules/no-module-scope-track.ts","../src/rules/prefer-oninput.ts","../src/rules/no-return-in-component.ts","../src/rules/unbox-tracked-values.ts","../src/rules/control-flow-jsx.ts","../src/rules/no-introspect-in-modules.ts","../src/index.ts"],"sourcesContent":["import type { Rule } from 'eslint';\nimport type { CallExpression } from 'estree';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow calling track() at module scope',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n moduleScope: 'track() cannot be called at module scope. It must be called within a component context.',\n },\n schema: [],\n },\n create(context) {\n let componentDepth = 0;\n let functionDepth = 0;\n\n const incrementComponentDepth = () => componentDepth++;\n const decrementComponentDepth = () => componentDepth--;\n const incrementFunctionDepth = () => functionDepth++;\n const decrementFunctionDepth = () => functionDepth--;\n\n return {\n // Only track when we enter a Ripple component\n // Ripple's parser returns \"Component\" nodes for component declarations\n 'Component': incrementComponentDepth,\n 'Component:exit': decrementComponentDepth,\n\n // Track regular functions and arrow functions\n 'FunctionDeclaration': incrementFunctionDepth,\n 'FunctionDeclaration:exit': decrementFunctionDepth,\n 'FunctionExpression': incrementFunctionDepth,\n 'FunctionExpression:exit': decrementFunctionDepth,\n 'ArrowFunctionExpression': incrementFunctionDepth,\n 'ArrowFunctionExpression:exit': decrementFunctionDepth,\n\n // Check track() calls\n CallExpression(node: CallExpression) {\n if (\n node.callee.type === 'Identifier' &&\n node.callee.name === 'track' &&\n componentDepth === 0 &&\n functionDepth === 0\n ) {\n context.report({\n node,\n messageId: 'moduleScope',\n });\n }\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Prefer onInput over onChange for form inputs in Ripple',\n category: 'Best Practices',\n recommended: true,\n },\n messages: {\n preferOnInput: 'Use \"onInput\" instead of \"onChange\". Ripple does not have synthetic events like React.',\n },\n fixable: 'code',\n schema: [],\n },\n create(context) {\n return {\n // Check JSX attributes (standard JSX)\n 'JSXAttribute[name.name=\"onChange\"]'(node: any) {\n context.report({\n node,\n messageId: 'preferOnInput',\n fix(fixer) {\n return fixer.replaceText(node.name, 'onInput');\n },\n });\n },\n // Check Attribute nodes (Ripple parser)\n 'Attribute[name.name=\"onChange\"]'(node: any) {\n context.report({\n node,\n messageId: 'preferOnInput',\n fix(fixer) {\n return fixer.replaceText(node.name, 'onInput');\n },\n });\n },\n // Check object properties (for spread props)\n 'Property[key.name=\"onChange\"]'(node: any) {\n // Only report if this looks like it's in a props object\n const ancestors = context.sourceCode.getAncestors(node);\n const inObjectExpression = ancestors.some(\n (ancestor) => ancestor.type === 'ObjectExpression'\n );\n\n if (inObjectExpression) {\n context.report({\n node,\n messageId: 'preferOnInput',\n fix(fixer) {\n return fixer.replaceText(node.key, 'onInput');\n },\n });\n }\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\nimport type { ReturnStatement } from 'estree';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow return statements with JSX in Ripple components',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n noReturn: 'Do not return JSX from Ripple components. Use JSX as statements instead.',\n },\n schema: [],\n },\n create(context) {\n let insideComponent = 0;\n\n return {\n // Track component boundaries\n \"ExpressionStatement > CallExpression[callee.name='component']\"() {\n insideComponent++;\n },\n \"ExpressionStatement > CallExpression[callee.name='component']:exit\"() {\n insideComponent--;\n },\n // Also track arrow functions and regular functions that might be components\n 'VariableDeclarator[init.callee.name=\"component\"]'() {\n insideComponent++;\n },\n 'VariableDeclarator[init.callee.name=\"component\"]:exit'() {\n insideComponent--;\n },\n // Check return statements\n ReturnStatement(node: ReturnStatement) {\n if (insideComponent > 0 && node.argument) {\n // Check if returning JSX (JSXElement, JSXFragment)\n if (\n node.argument.type === 'JSXElement' ||\n node.argument.type === 'JSXFragment'\n ) {\n context.report({\n node,\n messageId: 'noReturn',\n });\n }\n }\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Ensure tracked values are unboxed with @ operator',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n needsUnbox: 'Tracked value should be unboxed with @ operator. Did you mean \"@{{name}}\"?',\n },\n schema: [],\n },\n create(context) {\n const trackedVariables = new Set<string>();\n\n function isInJSXContext(node: any): boolean {\n let parent = node.parent;\n\n // Walk up the AST to find if we're inside JSX/Element\n while (parent) {\n const parentType = parent.type;\n // Check for JSX context\n if (\n parentType === 'JSXExpressionContainer' ||\n parentType === 'JSXElement' ||\n parentType === 'JSXFragment' ||\n // Check for Ripple Element context\n parentType === 'ExpressionContainer' ||\n parentType === 'Element'\n ) {\n return true;\n }\n parent = parent.parent;\n }\n\n return false;\n }\n\n function checkTrackedIdentifier(node: any) {\n if (trackedVariables.has(node.name) && isInJSXContext(node)) {\n // Check if it's not already unboxed (preceded by @)\n // The @ operator in Ripple creates a UnaryExpression node\n const parent = node.parent;\n let isUnboxed = parent &&\n parent.type === 'UnaryExpression' &&\n parent.operator === '@';\n\n // Fallback: check source code for @ character before the identifier\n if (!isUnboxed) {\n const sourceCode = context.getSourceCode();\n const textBefore = sourceCode.text.substring(\n Math.max(0, node.range![0] - 1),\n node.range![0]\n );\n isUnboxed = textBefore === '@';\n }\n\n if (!isUnboxed) {\n context.report({\n node,\n messageId: 'needsUnbox',\n data: { name: node.name },\n });\n }\n }\n }\n\n return {\n // Track variables that are assigned from track()\n 'VariableDeclarator[init.callee.name=\"track\"]'(node: any) {\n if (node.id.type === 'Identifier') {\n trackedVariables.add(node.id.name);\n }\n },\n // Check all identifiers\n Identifier(node: any) {\n checkTrackedIdentifier(node);\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\nimport type { ForOfStatement, Node } from 'estree';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Require JSX in for...of loops within components, but disallow JSX in for...of loops within effects',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n requireJsxInLoop:\n 'For...of loops in component bodies should contain JSX elements. Use JSX to render items.',\n noJsxInEffectLoop:\n 'For...of loops inside effect() should not contain JSX. Effects are for side effects, not rendering.',\n },\n schema: [],\n },\n create(context) {\n let insideComponent = 0;\n let insideEffect = 0;\n\n function containsJSX(node: Node, visited: Set<Node> = new Set()): boolean {\n if (!node) return false;\n\n // Avoid infinite loops from circular references\n if (visited.has(node)) return false;\n visited.add(node);\n\n // Check if current node is JSX/Element (Ripple uses 'Element' type instead of 'JSXElement')\n if (node.type === 'JSXElement' as string || node.type === 'JSXFragment' as string || node.type === 'Element' as string) {\n return true;\n }\n\n const keys = Object.keys(node);\n for (const key of keys) {\n if (key === 'parent' || key === 'loc' || key === 'range') {\n continue;\n }\n\n const value = (node as any)[key];\n if (value && typeof value === 'object') {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === 'object' && containsJSX(item, visited)) {\n return true;\n }\n }\n } else if (value.type && containsJSX(value, visited)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n return {\n Component() {\n insideComponent++;\n },\n 'Component:exit'() {\n insideComponent--;\n },\n\n \"CallExpression[callee.name='effect']\"() {\n insideEffect++;\n },\n \"CallExpression[callee.name='effect']:exit\"() {\n insideEffect--;\n },\n\n ForOfStatement(node: ForOfStatement) {\n if (insideComponent === 0) return;\n\n const hasJSX = containsJSX(node.body);\n\n if (insideEffect > 0) {\n if (hasJSX) {\n context.report({\n node,\n messageId: 'noJsxInEffectLoop',\n });\n }\n } else {\n if (!hasJSX) {\n context.report({\n node,\n messageId: 'requireJsxInLoop',\n });\n }\n }\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow @ introspection operator in TypeScript/JavaScript modules',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n noIntrospect: 'The @ operator cannot be used in TypeScript/JavaScript modules. Use get() to read tracked values and set() to update them instead.',\n },\n schema: [],\n },\n create(context) {\n const filename = context.filename || context.getFilename();\n \n // Skip .ripple files where @ operator is valid\n if (filename && filename.endsWith('.ripple')) {\n return {};\n }\n\n return {\n // Check for identifiers with the 'tracked' property\n // The @ operator is parsed by Ripple as an identifier with tracked=true\n Identifier(node: any) {\n if (node.tracked === true) {\n context.report({\n node,\n messageId: 'noIntrospect',\n });\n }\n },\n };\n },\n};\n\nexport default rule;\n\n","import { createRequire } from 'module';\nimport noModuleScopeTrack from './rules/no-module-scope-track.js';\nimport preferOnInput from './rules/prefer-oninput.js';\nimport noReturnInComponent from './rules/no-return-in-component.js';\nimport unboxTrackedValues from './rules/unbox-tracked-values.js';\nimport controlFlowJsx from './rules/control-flow-jsx.js';\nimport noIntrospectInModules from './rules/no-introspect-in-modules.js';\n\nconst plugin = {\n\tmeta: {\n\t\tname: '@ripple-ts/eslint-plugin',\n\t\tversion: '0.1.3',\n\t},\n\trules: {\n\t\t'no-module-scope-track': noModuleScopeTrack,\n\t\t'prefer-oninput': preferOnInput,\n\t\t'no-return-in-component': noReturnInComponent,\n\t\t'unbox-tracked-values': unboxTrackedValues,\n\t\t'control-flow-jsx': controlFlowJsx,\n\t\t'no-introspect-in-modules': noIntrospectInModules,\n\t},\n\tconfigs: {} as any,\n};\n\n// Try to load optional parsers\nconst require = createRequire(import.meta.url);\n\nlet rippleParser: any;\nlet tsParser: any;\n\ntry {\n\trippleParser = require('@ripple-ts/eslint-parser');\n} catch {\n\t// @ripple-ts/eslint-parser is optional\n\trippleParser = null;\n}\n\ntry {\n\ttsParser = require('@typescript-eslint/parser');\n} catch {\n\t// @typescript-eslint/parser is optional\n\ttsParser = null;\n}\n\n// Helper to create config objects\nfunction createConfig(name: string, files: string[], parser: any) {\n\tconst config: any = {\n\t\tname,\n\t\tfiles,\n\t\tplugins: {\n\t\t\tripple: plugin,\n\t\t},\n\t\trules: {\n\t\t\t'ripple/no-module-scope-track': 'error',\n\t\t\t'ripple/prefer-oninput': 'warn',\n\t\t\t'ripple/no-return-in-component': 'error',\n\t\t\t'ripple/unbox-tracked-values': 'error',\n\t\t\t'ripple/control-flow-jsx': 'error',\n\t\t\t'ripple/no-introspect-in-modules': 'error',\n\t\t},\n\t};\n\n\t// Only add parser if it's available\n\tif (parser) {\n\t\tconfig.languageOptions = {\n\t\t\tparser,\n\t\t\tparserOptions: {\n\t\t\t\tecmaVersion: 'latest',\n\t\t\t\tsourceType: 'module',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn config;\n}\n\n// Recommended configuration (flat config format)\nplugin.configs.recommended = [\n\tcreateConfig('ripple/recommended-ripple-files', ['**/*.ripple'], rippleParser),\n\tcreateConfig('ripple/recommended-typescript-files', ['**/*.ts', '**/*.tsx'], tsParser),\n\t{\n\t\tname: 'ripple/ignores',\n\t\tignores: ['**/*.d.ts', '**/node_modules/**', '**/dist/**', '**/build/**'],\n\t},\n];\n\n// Strict configuration (flat config format)\nplugin.configs.strict = [\n\tcreateConfig('ripple/strict-ripple-files', ['**/*.ripple'], rippleParser),\n\tcreateConfig('ripple/strict-typescript-files', ['**/*.ts', '**/*.tsx'], tsParser),\n\t{\n\t\tname: 'ripple/ignores',\n\t\tignores: ['**/*.d.ts', '**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C;GACnC;EACD;AAGD,KAAI,OACH,QAAO,kBAAkB;EACxB;EACA,eAAe;GACd,aAAa;GACb,YAAY;GACZ;EACD;AAGF,QAAO;;AAIR,OAAO,QAAQ,cAAc;CAC5B,aAAa,mCAAmC,CAAC,cAAc,EAAE,aAAa;CAC9E,aAAa,uCAAuC,CAAC,WAAW,WAAW,EAAE,SAAS;CACtF;EACC,MAAM;EACN,SAAS;GAAC;GAAa;GAAsB;GAAc;GAAc;EACzE;CACD;AAGD,OAAO,QAAQ,SAAS;CACvB,aAAa,8BAA8B,CAAC,cAAc,EAAE,aAAa;CACzE,aAAa,kCAAkC,CAAC,WAAW,WAAW,EAAE,SAAS;CACjF;EACC,MAAM;EACN,SAAS;GAAC;GAAa;GAAsB;GAAc;GAAc;EACzE;CACD;AAED,kBAAe"}
1
+ {"version":3,"file":"index.js","names":["rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","rule","rule: Rule.RuleModule","node","noModuleScopeTrack","preferOnInput","noReturnInComponent","unboxTrackedValues","controlFlowJsx","noIntrospectInModules","validForOfKey","rippleParser: any","tsParser: any","config: any"],"sources":["../src/rules/no-module-scope-track.ts","../src/rules/prefer-oninput.ts","../src/rules/no-return-in-component.ts","../src/rules/unbox-tracked-values.ts","../src/rules/control-flow-jsx.ts","../src/rules/no-introspect-in-modules.ts","../src/rules/valid-for-of-key.ts","../src/index.ts"],"sourcesContent":["import type { Rule } from 'eslint';\nimport type { CallExpression } from 'estree';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow calling track() at module scope',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n moduleScope: 'track() cannot be called at module scope. It must be called within a component context.',\n },\n schema: [],\n },\n create(context) {\n let componentDepth = 0;\n let functionDepth = 0;\n\n const incrementComponentDepth = () => componentDepth++;\n const decrementComponentDepth = () => componentDepth--;\n const incrementFunctionDepth = () => functionDepth++;\n const decrementFunctionDepth = () => functionDepth--;\n\n return {\n // Only track when we enter a Ripple component\n // Ripple's parser returns \"Component\" nodes for component declarations\n 'Component': incrementComponentDepth,\n 'Component:exit': decrementComponentDepth,\n\n // Track regular functions and arrow functions\n 'FunctionDeclaration': incrementFunctionDepth,\n 'FunctionDeclaration:exit': decrementFunctionDepth,\n 'FunctionExpression': incrementFunctionDepth,\n 'FunctionExpression:exit': decrementFunctionDepth,\n 'ArrowFunctionExpression': incrementFunctionDepth,\n 'ArrowFunctionExpression:exit': decrementFunctionDepth,\n\n // Check track() calls\n CallExpression(node: CallExpression) {\n if (\n node.callee.type === 'Identifier' &&\n node.callee.name === 'track' &&\n componentDepth === 0 &&\n functionDepth === 0\n ) {\n context.report({\n node,\n messageId: 'moduleScope',\n });\n }\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Prefer onInput over onChange for form inputs in Ripple',\n category: 'Best Practices',\n recommended: true,\n },\n messages: {\n preferOnInput: 'Use \"onInput\" instead of \"onChange\". Ripple does not have synthetic events like React.',\n },\n fixable: 'code',\n schema: [],\n },\n create(context) {\n return {\n // Check JSX attributes (standard JSX)\n 'JSXAttribute[name.name=\"onChange\"]'(node: any) {\n context.report({\n node,\n messageId: 'preferOnInput',\n fix(fixer) {\n return fixer.replaceText(node.name, 'onInput');\n },\n });\n },\n // Check Attribute nodes (Ripple parser)\n 'Attribute[name.name=\"onChange\"]'(node: any) {\n context.report({\n node,\n messageId: 'preferOnInput',\n fix(fixer) {\n return fixer.replaceText(node.name, 'onInput');\n },\n });\n },\n // Check object properties (for spread props)\n 'Property[key.name=\"onChange\"]'(node: any) {\n // Only report if this looks like it's in a props object\n const ancestors = context.sourceCode.getAncestors(node);\n const inObjectExpression = ancestors.some(\n (ancestor) => ancestor.type === 'ObjectExpression'\n );\n\n if (inObjectExpression) {\n context.report({\n node,\n messageId: 'preferOnInput',\n fix(fixer) {\n return fixer.replaceText(node.key, 'onInput');\n },\n });\n }\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\nimport type { ReturnStatement } from 'estree';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow return statements with JSX in Ripple components',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n noReturn: 'Do not return JSX from Ripple components. Use JSX as statements instead.',\n },\n schema: [],\n },\n create(context) {\n let insideComponent = 0;\n\n return {\n // Track component boundaries\n \"ExpressionStatement > CallExpression[callee.name='component']\"() {\n insideComponent++;\n },\n \"ExpressionStatement > CallExpression[callee.name='component']:exit\"() {\n insideComponent--;\n },\n // Also track arrow functions and regular functions that might be components\n 'VariableDeclarator[init.callee.name=\"component\"]'() {\n insideComponent++;\n },\n 'VariableDeclarator[init.callee.name=\"component\"]:exit'() {\n insideComponent--;\n },\n // Check return statements\n ReturnStatement(node: ReturnStatement) {\n if (insideComponent > 0 && node.argument) {\n // Check if returning JSX (JSXElement, JSXFragment)\n if (\n node.argument.type === 'JSXElement' ||\n node.argument.type === 'JSXFragment'\n ) {\n context.report({\n node,\n messageId: 'noReturn',\n });\n }\n }\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Ensure tracked values are unboxed with @ operator',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n needsUnbox: 'Tracked value should be unboxed with @ operator. Did you mean \"@{{name}}\"?',\n },\n schema: [],\n },\n create(context) {\n const trackedVariables = new Set<string>();\n\n function isInJSXContext(node: any): boolean {\n let parent = node.parent;\n\n // Walk up the AST to find if we're inside JSX/Element\n while (parent) {\n const parentType = parent.type;\n // Check for JSX context\n if (\n parentType === 'JSXExpressionContainer' ||\n parentType === 'JSXElement' ||\n parentType === 'JSXFragment' ||\n // Check for Ripple Element context\n parentType === 'ExpressionContainer' ||\n parentType === 'Element'\n ) {\n return true;\n }\n parent = parent.parent;\n }\n\n return false;\n }\n\n function checkTrackedIdentifier(node: any) {\n if (trackedVariables.has(node.name) && isInJSXContext(node)) {\n // Check if it's not already unboxed (preceded by @)\n // The @ operator in Ripple creates a UnaryExpression node\n const parent = node.parent;\n let isUnboxed = parent &&\n parent.type === 'UnaryExpression' &&\n parent.operator === '@';\n\n // Fallback: check source code for @ character before the identifier\n if (!isUnboxed) {\n const sourceCode = context.getSourceCode();\n const textBefore = sourceCode.text.substring(\n Math.max(0, node.range![0] - 1),\n node.range![0]\n );\n isUnboxed = textBefore === '@';\n }\n\n if (!isUnboxed) {\n context.report({\n node,\n messageId: 'needsUnbox',\n data: { name: node.name },\n });\n }\n }\n }\n\n return {\n // Track variables that are assigned from track()\n 'VariableDeclarator[init.callee.name=\"track\"]'(node: any) {\n if (node.id.type === 'Identifier') {\n trackedVariables.add(node.id.name);\n }\n },\n // Check all identifiers\n Identifier(node: any) {\n checkTrackedIdentifier(node);\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\nimport type { ForOfStatement, Node } from 'estree';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description:\n 'Require JSX in for...of loops within components, but disallow JSX in for...of loops within effects',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n requireJsxInLoop:\n 'For...of loops in component bodies should contain JSX elements. Use JSX to render items.',\n noJsxInEffectLoop:\n 'For...of loops inside effect() should not contain JSX. Effects are for side effects, not rendering.',\n },\n schema: [],\n },\n create(context) {\n let insideComponent = 0;\n let insideEffect = 0;\n\n function containsJSX(node: Node, visited: Set<Node> = new Set()): boolean {\n if (!node) return false;\n\n // Avoid infinite loops from circular references\n if (visited.has(node)) return false;\n visited.add(node);\n\n // Check if current node is JSX/Element (Ripple uses 'Element' type instead of 'JSXElement')\n if (node.type === 'JSXElement' as string || node.type === 'JSXFragment' as string || node.type === 'Element' as string) {\n return true;\n }\n\n const keys = Object.keys(node);\n for (const key of keys) {\n if (key === 'parent' || key === 'loc' || key === 'range') {\n continue;\n }\n\n const value = (node as any)[key];\n if (value && typeof value === 'object') {\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === 'object' && containsJSX(item, visited)) {\n return true;\n }\n }\n } else if (value.type && containsJSX(value, visited)) {\n return true;\n }\n }\n }\n\n return false;\n }\n\n return {\n Component() {\n insideComponent++;\n },\n 'Component:exit'() {\n insideComponent--;\n },\n\n \"CallExpression[callee.name='effect']\"() {\n insideEffect++;\n },\n \"CallExpression[callee.name='effect']:exit\"() {\n insideEffect--;\n },\n\n ForOfStatement(node: ForOfStatement) {\n if (insideComponent === 0) return;\n\n const hasJSX = containsJSX(node.body);\n\n if (insideEffect > 0) {\n if (hasJSX) {\n context.report({\n node,\n messageId: 'noJsxInEffectLoop',\n });\n }\n } else {\n if (!hasJSX) {\n context.report({\n node,\n messageId: 'requireJsxInLoop',\n });\n }\n }\n },\n };\n },\n};\n\nexport default rule;\n","import type { Rule } from 'eslint';\n\nconst rule: Rule.RuleModule = {\n meta: {\n type: 'problem',\n docs: {\n description: 'Disallow @ introspection operator in TypeScript/JavaScript modules',\n category: 'Possible Errors',\n recommended: true,\n },\n messages: {\n noIntrospect: 'The @ operator cannot be used in TypeScript/JavaScript modules. Use get() to read tracked values and set() to update them instead.',\n },\n schema: [],\n },\n create(context) {\n const filename = context.filename || context.getFilename();\n \n // Skip .ripple files where @ operator is valid\n if (filename && filename.endsWith('.ripple')) {\n return {};\n }\n\n return {\n // Check for identifiers with the 'tracked' property\n // The @ operator is parsed by Ripple as an identifier with tracked=true\n Identifier(node: any) {\n if (node.tracked === true) {\n context.report({\n node,\n messageId: 'noIntrospect',\n });\n }\n },\n };\n },\n};\n\nexport default rule;\n\n","import type { Rule } from 'eslint';\n\nconst rule: Rule.RuleModule = {\n\tmeta: {\n\t\ttype: 'problem',\n\t\tdocs: {\n\t\t\tdescription: 'Ensure variables used in for..of key expression are defined',\n\t\t\trecommended: true,\n\t\t},\n\t\tmessages: {\n\t\t\tundefinedVariable: \"Variable '{{name}}' is not defined.\",\n\t\t},\n\t\tschema: [],\n\t},\n\tcreate(context) {\n\t\treturn {\n\t\t\tForOfStatement(node: any) {\n\t\t\t\tif (!node.key) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst checkIdentifier = (identifier: any) => {\n\t\t\t\t\tconst scope = context.sourceCode.getScope(node);\n\t\t\t\t\tconst variable = findVariable(scope, identifier.name);\n\n\t\t\t\t\tif (!variable) {\n\t\t\t\t\t\tcontext.report({\n\t\t\t\t\t\t\tnode: identifier,\n\t\t\t\t\t\t\tmessageId: 'undefinedVariable',\n\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\tname: identifier.name,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tconst traverse = (node: any) => {\n\t\t\t\t\tif (!node) return;\n\n\t\t\t\t\tswitch (node.type) {\n\t\t\t\t\t\tcase 'Identifier':\n\t\t\t\t\t\t\tcheckIdentifier(node);\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'MemberExpression':\n\t\t\t\t\t\t\ttraverse(node.object);\n\n\t\t\t\t\t\t\tif (node.computed) {\n\t\t\t\t\t\t\t\ttraverse(node.property);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'BinaryExpression':\n\t\t\t\t\t\tcase 'LogicalExpression':\n\t\t\t\t\t\t\ttraverse(node.left);\n\t\t\t\t\t\t\ttraverse(node.right);\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'UnaryExpression':\n\t\t\t\t\t\t\ttraverse(node.argument);\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'CallExpression':\n\t\t\t\t\t\t\ttraverse(node.callee);\n\t\t\t\t\t\t\tnode.arguments.forEach(traverse);\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'ArrayExpression':\n\t\t\t\t\t\t\tnode.elements.forEach(traverse);\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'ObjectExpression':\n\t\t\t\t\t\t\tnode.properties.forEach((prop: any) => {\n\t\t\t\t\t\t\t\tif (prop.type === 'Property') {\n\t\t\t\t\t\t\t\t\tif (prop.computed) {\n\t\t\t\t\t\t\t\t\t\ttraverse(prop.key);\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\ttraverse(prop.value);\n\t\t\t\t\t\t\t\t} else if (prop.type === 'SpreadElement') {\n\t\t\t\t\t\t\t\t\ttraverse(prop.argument);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'ConditionalExpression':\n\t\t\t\t\t\t\ttraverse(node.test);\n\t\t\t\t\t\t\ttraverse(node.consequent);\n\t\t\t\t\t\t\ttraverse(node.alternate);\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\tcase 'TemplateLiteral':\n\t\t\t\t\t\t\tnode.expressions.forEach(traverse);\n\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\ttraverse(node.key);\n\t\t\t},\n\t\t};\n\t},\n};\n\nfunction findVariable(scope: any, name: string) {\n\tlet currentScope = scope;\n\n\twhile (currentScope) {\n\t\tconst variable = currentScope.variables.find((v: { name: string }) => v.name === name);\n\n\t\tif (variable) {\n\t\t\treturn variable;\n\t\t}\n\n\t\t// Also check references for global variables or variables defined in the loop itself (like the loop variable)\n\t\t// The loop variable might not be in the 'variables' list of the surrounding scope yet if we are inside the loop statement\n\t\t// But for 'for-of', the loop variable is in a special scope or the upper scope.\n\t\t// Let's rely on standard scope analysis.\n\n\t\t// Special case: check if the variable is the loop variable itself (left side of for-of)\n\t\t// The scope analysis might handle this, but let's be sure.\n\n\t\tcurrentScope = currentScope.upper;\n\t}\n\n\t// If not found in scopes, it might be a global variable.\n\t// ESLint scope analysis usually includes globals in the global scope.\n\t// However, if we are in a module, we might need to check if it's an implicit global or defined elsewhere.\n\t// For now, let's assume standard scope resolution works.\n\n\treturn null;\n}\n\nexport default rule;\n","import { createRequire } from 'module';\nimport noModuleScopeTrack from './rules/no-module-scope-track.js';\nimport preferOnInput from './rules/prefer-oninput.js';\nimport noReturnInComponent from './rules/no-return-in-component.js';\nimport unboxTrackedValues from './rules/unbox-tracked-values.js';\nimport controlFlowJsx from './rules/control-flow-jsx.js';\nimport noIntrospectInModules from './rules/no-introspect-in-modules.js';\nimport validForOfKey from './rules/valid-for-of-key.js';\n\nconst plugin = {\n\tmeta: {\n\t\tname: '@ripple-ts/eslint-plugin',\n\t\tversion: '0.1.3',\n\t},\n\trules: {\n\t\t'no-module-scope-track': noModuleScopeTrack,\n\t\t'prefer-oninput': preferOnInput,\n\t\t'no-return-in-component': noReturnInComponent,\n\t\t'unbox-tracked-values': unboxTrackedValues,\n\t\t'control-flow-jsx': controlFlowJsx,\n\t\t'no-introspect-in-modules': noIntrospectInModules,\n\t\t'valid-for-of-key': validForOfKey,\n\t},\n\tconfigs: {} as any,\n};\n\n// Try to load optional parsers\nconst require = createRequire(import.meta.url);\n\nlet rippleParser: any;\nlet tsParser: any;\n\ntry {\n\trippleParser = require('@ripple-ts/eslint-parser');\n} catch {\n\t// @ripple-ts/eslint-parser is optional\n\trippleParser = null;\n}\n\ntry {\n\ttsParser = require('@typescript-eslint/parser');\n} catch {\n\t// @typescript-eslint/parser is optional\n\ttsParser = null;\n}\n\n// Helper to create config objects\nfunction createConfig(name: string, files: string[], parser: any) {\n\tconst config: any = {\n\t\tname,\n\t\tfiles,\n\t\tplugins: {\n\t\t\tripple: plugin,\n\t\t},\n\t\trules: {\n\t\t\t'ripple/no-module-scope-track': 'error',\n\t\t\t'ripple/prefer-oninput': 'warn',\n\t\t\t'ripple/no-return-in-component': 'error',\n\t\t\t'ripple/unbox-tracked-values': 'error',\n\t\t\t'ripple/control-flow-jsx': 'error',\n\t\t\t'ripple/no-introspect-in-modules': 'error',\n\t\t\t'ripple/valid-for-of-key': 'error',\n\t\t},\n\t};\n\n\t// Only add parser if it's available\n\tif (parser) {\n\t\tconfig.languageOptions = {\n\t\t\tparser,\n\t\t\tparserOptions: {\n\t\t\t\tecmaVersion: 'latest',\n\t\t\t\tsourceType: 'module',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn config;\n}\n\n// Recommended configuration (flat config format)\nplugin.configs.recommended = [\n\tcreateConfig('ripple/recommended-ripple-files', ['**/*.ripple'], rippleParser),\n\tcreateConfig('ripple/recommended-typescript-files', ['**/*.ts', '**/*.tsx'], tsParser),\n\t{\n\t\tname: 'ripple/ignores',\n\t\tignores: ['**/*.d.ts', '**/node_modules/**', '**/dist/**', '**/build/**'],\n\t},\n];\n\n// Strict configuration (flat config format)\nplugin.configs.strict = [\n\tcreateConfig('ripple/strict-ripple-files', ['**/*.ripple'], rippleParser),\n\tcreateConfig('ripple/strict-typescript-files', ['**/*.ts', '**/*.tsx'], tsParser),\n\t{\n\t\tname: 'ripple/ignores',\n\t\tignores: ['**/*.d.ts', '**/node_modules/**', '**/dist/**', '**/build/**'],\n\t},\n];\n\nexport default plugin;\n"],"mappings":";;;AAGA,MAAMA,SAAwB;CAC5B,MAAM;EACJ,MAAM;EACN,MAAM;GACJ,aAAa;GACb,UAAU;GACV,aAAa;GACd;EACD,UAAU,EACR,aAAa,2FACd;EACD,QAAQ,EAAE;EACX;CACD,OAAO,SAAS;EACd,IAAI,iBAAiB;EACrB,IAAI,gBAAgB;EAEpB,MAAM,gCAAgC;EACtC,MAAM,gCAAgC;EACtC,MAAM,+BAA+B;EACrC,MAAM,+BAA+B;AAErC,SAAO;GAGL,aAAa;GACb,kBAAkB;GAGlB,uBAAuB;GACvB,4BAA4B;GAC5B,sBAAsB;GACtB,2BAA2B;GAC3B,2BAA2B;GAC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S;GAAC;GAAa;GAAsB;GAAc;GAAc;EACzE;CACD;AAGD,OAAO,QAAQ,SAAS;CACvB,aAAa,8BAA8B,CAAC,cAAc,EAAE,aAAa;CACzE,aAAa,kCAAkC,CAAC,WAAW,WAAW,EAAE,SAAS;CACjF;EACC,MAAM;EACN,SAAS;GAAC;GAAa;GAAsB;GAAc;GAAc;EACzE;CACD;AAED,kBAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ripple-ts/eslint-plugin",
3
- "version": "0.2.178",
3
+ "version": "0.2.179",
4
4
  "description": "ESLint plugin for Ripple",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -30,7 +30,7 @@
30
30
  "peerDependencies": {
31
31
  "eslint": ">=9.0.0",
32
32
  "@typescript-eslint/parser": "^8.20.0",
33
- "@ripple-ts/eslint-parser": "0.2.178"
33
+ "@ripple-ts/eslint-parser": "0.2.179"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/eslint": "^9.6.1",
@@ -41,7 +41,7 @@
41
41
  "tsdown": "^0.15.4",
42
42
  "typescript": "^5.9.2",
43
43
  "vitest": "^3.2.4",
44
- "@ripple-ts/eslint-parser": "0.2.178"
44
+ "@ripple-ts/eslint-parser": "0.2.179"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=20.0.0"
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import noReturnInComponent from './rules/no-return-in-component.js';
5
5
  import unboxTrackedValues from './rules/unbox-tracked-values.js';
6
6
  import controlFlowJsx from './rules/control-flow-jsx.js';
7
7
  import noIntrospectInModules from './rules/no-introspect-in-modules.js';
8
+ import validForOfKey from './rules/valid-for-of-key.js';
8
9
 
9
10
  const plugin = {
10
11
  meta: {
@@ -18,6 +19,7 @@ const plugin = {
18
19
  'unbox-tracked-values': unboxTrackedValues,
19
20
  'control-flow-jsx': controlFlowJsx,
20
21
  'no-introspect-in-modules': noIntrospectInModules,
22
+ 'valid-for-of-key': validForOfKey,
21
23
  },
22
24
  configs: {} as any,
23
25
  };
@@ -57,6 +59,7 @@ function createConfig(name: string, files: string[], parser: any) {
57
59
  'ripple/unbox-tracked-values': 'error',
58
60
  'ripple/control-flow-jsx': 'error',
59
61
  'ripple/no-introspect-in-modules': 'error',
62
+ 'ripple/valid-for-of-key': 'error',
60
63
  },
61
64
  };
62
65
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BjnSX0QC.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;cAQM;;;IAAA,OAcL,EAAA,MAAA;EAAA,CAAA"}