@memberjunction/react-linter 6.2.0-edge.0 → 6.2.0-edge.2
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/dist/component-linter.d.ts +7 -0
- package/dist/component-linter.d.ts.map +1 -1
- package/dist/component-linter.js +10 -2
- package/dist/component-linter.js.map +1 -1
- package/dist/control-flow-analyzer.d.ts +8 -0
- package/dist/control-flow-analyzer.d.ts.map +1 -1
- package/dist/control-flow-analyzer.js +20 -4
- package/dist/control-flow-analyzer.js.map +1 -1
- package/dist/library-lint-cache.d.ts +12 -0
- package/dist/library-lint-cache.d.ts.map +1 -1
- package/dist/library-lint-cache.js +30 -6
- package/dist/library-lint-cache.js.map +1 -1
- package/dist/lint-rule.d.ts +2 -1
- package/dist/lint-rule.d.ts.map +1 -1
- package/dist/lint-utils.d.ts +76 -1
- package/dist/lint-utils.d.ts.map +1 -1
- package/dist/lint-utils.js +132 -34
- package/dist/lint-utils.js.map +1 -1
- package/dist/prop-value-extractor.d.ts +8 -0
- package/dist/prop-value-extractor.d.ts.map +1 -1
- package/dist/prop-value-extractor.js +29 -13
- package/dist/prop-value-extractor.js.map +1 -1
- package/dist/runtime-rules/ai-tools-availability-check.js +4 -4
- package/dist/runtime-rules/callback-event-validation.js +2 -2
- package/dist/runtime-rules/chart-field-validation.js +5 -5
- package/dist/runtime-rules/child-component-prop-validation.js +4 -4
- package/dist/runtime-rules/component-name-mismatch.js +2 -2
- package/dist/runtime-rules/component-not-in-dependencies.js +2 -2
- package/dist/runtime-rules/component-props-validation.js +2 -2
- package/dist/runtime-rules/component-usage-without-destructuring.js +2 -2
- package/dist/runtime-rules/data-result-validation.js +4 -4
- package/dist/runtime-rules/datagrid-field-validation.js +2 -2
- package/dist/runtime-rules/dependency-shadowing.js +2 -2
- package/dist/runtime-rules/entity-field-access-validation.js +9 -9
- package/dist/runtime-rules/event-parameter-validation.js +5 -5
- package/dist/runtime-rules/library-variable-names.js +2 -2
- package/dist/runtime-rules/no-child-implementation.js +2 -2
- package/dist/runtime-rules/no-data-prop.js +2 -2
- package/dist/runtime-rules/no-export-statements.js +6 -6
- package/dist/runtime-rules/no-iife-wrapper.js +5 -5
- package/dist/runtime-rules/no-import-statements.js +3 -3
- package/dist/runtime-rules/no-react-destructuring.js +3 -3
- package/dist/runtime-rules/no-require-statements.js +4 -4
- package/dist/runtime-rules/no-return-component.js +3 -3
- package/dist/runtime-rules/no-unwrap-utility-libs.js +3 -3
- package/dist/runtime-rules/no-use-reducer.js +2 -2
- package/dist/runtime-rules/no-window-access.js +2 -2
- package/dist/runtime-rules/noisy-settings-updates.js +2 -2
- package/dist/runtime-rules/overflow-hidden-on-layout-container.js +4 -4
- package/dist/runtime-rules/pass-standard-props.js +5 -5
- package/dist/runtime-rules/prefer-async-await.js +2 -2
- package/dist/runtime-rules/prefer-jsx-syntax.js +2 -2
- package/dist/runtime-rules/prop-state-sync.js +2 -2
- package/dist/runtime-rules/property-name-consistency.js +2 -2
- package/dist/runtime-rules/query-result-field-access-validation.js +10 -10
- package/dist/runtime-rules/react-component-naming.js +4 -4
- package/dist/runtime-rules/react-hooks-rules.js +2 -2
- package/dist/runtime-rules/required-queries-not-called.js +4 -4
- package/dist/runtime-rules/runquery-call-validation.js +8 -8
- package/dist/runtime-rules/runview-call-validation.js +5 -5
- package/dist/runtime-rules/saved-user-settings-pattern.js +2 -2
- package/dist/runtime-rules/search-availability-check.js +4 -4
- package/dist/runtime-rules/search-call-validation.js +2 -2
- package/dist/runtime-rules/server-reload-on-client-operation.js +2 -2
- package/dist/runtime-rules/single-function-only.js +8 -8
- package/dist/runtime-rules/string-replace-all-occurrences.js +2 -2
- package/dist/runtime-rules/string-template-validation.js +2 -2
- package/dist/runtime-rules/styles-validation.js +2 -2
- package/dist/runtime-rules/type-mismatch-operation.js +2 -2
- package/dist/runtime-rules/undefined-component-usage.js +2 -2
- package/dist/runtime-rules/undefined-jsx-component.js +2 -2
- package/dist/runtime-rules/unsafe-array-operations.js +2 -2
- package/dist/runtime-rules/unsafe-formatting-methods.js +2 -2
- package/dist/runtime-rules/unused-component-dependencies.js +2 -2
- package/dist/runtime-rules/unused-libraries.js +2 -2
- package/dist/runtime-rules/use-function-declaration.js +4 -4
- package/dist/runtime-rules/use-unwrap-components.js +2 -2
- package/dist/runtime-rules/useeffect-unstable-dependencies.js +2 -2
- package/dist/runtime-rules/utilities-api-validation.js +2 -2
- package/dist/runtime-rules/utilities-no-direct-instantiation.js +2 -2
- package/dist/runtime-rules/validate-component-references.js +3 -3
- package/dist/schema-validation/component-prop-rule.d.ts +12 -2
- package/dist/schema-validation/component-prop-rule.d.ts.map +1 -1
- package/dist/schema-validation/component-prop-rule.js +31 -11
- package/dist/schema-validation/component-prop-rule.js.map +1 -1
- package/dist/schema-validation/semantic-validators/semantic-validator-registry.d.ts +12 -0
- package/dist/schema-validation/semantic-validators/semantic-validator-registry.d.ts.map +1 -1
- package/dist/schema-validation/semantic-validators/semantic-validator-registry.js +33 -9
- package/dist/schema-validation/semantic-validators/semantic-validator-registry.js.map +1 -1
- package/dist/schema-validation/semantic-validators/semantic-validator.d.ts +4 -1
- package/dist/schema-validation/semantic-validators/semantic-validator.d.ts.map +1 -1
- package/dist/schema-validation/semantic-validators/semantic-validator.js +5 -1
- package/dist/schema-validation/semantic-validators/semantic-validator.js.map +1 -1
- package/dist/schema-validation/semantic-validators/sql-where-clause-validator.js +1 -1
- package/dist/schema-validation/semantic-validators/validation-context.d.ts +20 -20
- package/dist/styles-type-analyzer.d.ts +12 -0
- package/dist/styles-type-analyzer.d.ts.map +1 -1
- package/dist/styles-type-analyzer.js +21 -5
- package/dist/styles-type-analyzer.js.map +1 -1
- package/dist/type-context.d.ts +41 -0
- package/dist/type-context.d.ts.map +1 -1
- package/dist/type-context.js +99 -23
- package/dist/type-context.js.map +1 -1
- package/dist/type-inference-engine.d.ts +16 -2
- package/dist/type-inference-engine.d.ts.map +1 -1
- package/dist/type-inference-engine.js +64 -36
- package/dist/type-inference-engine.js.map +1 -1
- package/dist/type-rules/type-compatibility-rule.d.ts +12 -2
- package/dist/type-rules/type-compatibility-rule.d.ts.map +1 -1
- package/dist/type-rules/type-compatibility-rule.js +23 -3
- package/dist/type-rules/type-compatibility-rule.js.map +1 -1
- package/package.json +8 -8
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import * as t from '@babel/types';
|
|
9
9
|
import { RegisterClass } from '@memberjunction/global';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -126,7 +126,7 @@ function isUtilitiesSearchAccess(node) {
|
|
|
126
126
|
*/
|
|
127
127
|
function isInConsequent(targetNode, ifStatement) {
|
|
128
128
|
let found = false;
|
|
129
|
-
|
|
129
|
+
Traverse(ifStatement.consequent, {
|
|
130
130
|
enter(innerPath) {
|
|
131
131
|
if (innerPath.node === targetNode) {
|
|
132
132
|
found = true;
|
|
@@ -168,7 +168,7 @@ let SearchAvailabilityCheckRule = class SearchAvailabilityCheckRule extends Base
|
|
|
168
168
|
// First pass: count total utilities.search accesses (guarded and unguarded)
|
|
169
169
|
// If the component uses utilities.search extensively, it's designed for search environments
|
|
170
170
|
let totalSearchAccesses = 0;
|
|
171
|
-
|
|
171
|
+
Traverse(ast, {
|
|
172
172
|
MemberExpression(path) {
|
|
173
173
|
if (isUtilitiesSearchMethodAccess(path.node))
|
|
174
174
|
totalSearchAccesses++;
|
|
@@ -182,7 +182,7 @@ let SearchAvailabilityCheckRule = class SearchAvailabilityCheckRule extends Base
|
|
|
182
182
|
// If >=3 total accesses, the component is designed for search environments — skip
|
|
183
183
|
if (totalSearchAccesses >= 3)
|
|
184
184
|
return violations;
|
|
185
|
-
|
|
185
|
+
Traverse(ast, {
|
|
186
186
|
MemberExpression(path) {
|
|
187
187
|
// We want to find utilities.search.Search or utilities.search.PreviewSearch
|
|
188
188
|
if (!isUtilitiesSearchMethodAccess(path.node))
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -322,7 +322,7 @@ let SearchCallValidationRule = class SearchCallValidationRule extends BaseLintRu
|
|
|
322
322
|
validatePreviewSearchArgs(path.node.arguments, line, column, violations);
|
|
323
323
|
}
|
|
324
324
|
};
|
|
325
|
-
|
|
325
|
+
Traverse(ast, {
|
|
326
326
|
CallExpression(path) { visitCall(path); },
|
|
327
327
|
OptionalCallExpression(path) { visitCall(path); },
|
|
328
328
|
});
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -47,7 +47,7 @@ let ServerReloadOnClientOperationRule = class ServerReloadOnClientOperationRule
|
|
|
47
47
|
get AppliesTo() { return 'all'; }
|
|
48
48
|
Test(ast, componentName) {
|
|
49
49
|
const violations = [];
|
|
50
|
-
|
|
50
|
+
Traverse(ast, {
|
|
51
51
|
CallExpression(path) {
|
|
52
52
|
const callee = path.node.callee;
|
|
53
53
|
// Look for data loading functions
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { RegisterClass } from '@memberjunction/global';
|
|
8
8
|
import * as t from '@babel/types';
|
|
9
9
|
import { BaseLintRule } from '../lint-rule.js';
|
|
10
|
-
import {
|
|
10
|
+
import { Traverse, CreateViolation } from '../lint-utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* Rule: single-function-only
|
|
13
13
|
*
|
|
@@ -26,12 +26,12 @@ let SingleFunctionOnlyRule = class SingleFunctionOnlyRule extends BaseLintRule {
|
|
|
26
26
|
const programBody = ast.program.body;
|
|
27
27
|
// First, check if there's anything other than a single function declaration
|
|
28
28
|
if (programBody.length === 0) {
|
|
29
|
-
violations.push(
|
|
29
|
+
violations.push(CreateViolation('single-function-only', 'critical', null, `Component code must contain exactly one function declaration named "${componentName}". No code found.`, `Add: function ${componentName}({ utilities, styles, components, callbacks, savedUserSettings, onSaveUserSettings }) { ... }`));
|
|
30
30
|
return violations;
|
|
31
31
|
}
|
|
32
32
|
if (programBody.length > 1) {
|
|
33
33
|
// Multiple top-level statements - not allowed
|
|
34
|
-
violations.push(
|
|
34
|
+
violations.push(CreateViolation('single-function-only', 'critical', programBody[1], `Component code must contain ONLY a single function declaration. Found ${programBody.length} top-level statements. No code should exist before or after the function.`, `Remove all code except: function ${componentName}(...) { ... }`));
|
|
35
35
|
// Report each extra statement
|
|
36
36
|
for (let i = 1; i < programBody.length; i++) {
|
|
37
37
|
const stmt = programBody[i];
|
|
@@ -45,7 +45,7 @@ let SingleFunctionOnlyRule = class SingleFunctionOnlyRule extends BaseLintRule {
|
|
|
45
45
|
else if (t.isExpressionStatement(stmt)) {
|
|
46
46
|
stmtType = 'expression';
|
|
47
47
|
}
|
|
48
|
-
violations.push(
|
|
48
|
+
violations.push(CreateViolation('single-function-only', 'critical', stmt, `Extra ${stmtType} not allowed. Only the component function should exist.`, ''));
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
// Check that the single statement is a function declaration (not arrow function or other)
|
|
@@ -71,24 +71,24 @@ let SingleFunctionOnlyRule = class SingleFunctionOnlyRule extends BaseLintRule {
|
|
|
71
71
|
actualType = 'expression statement';
|
|
72
72
|
suggestion = 'Remove this expression and add the component function';
|
|
73
73
|
}
|
|
74
|
-
violations.push(
|
|
74
|
+
violations.push(CreateViolation('single-function-only', 'critical', firstStatement, `Component must be a function declaration, not ${actualType}. ${suggestion}`, ''));
|
|
75
75
|
// Don't check name if it's not a function declaration
|
|
76
76
|
return violations;
|
|
77
77
|
}
|
|
78
78
|
// Check that the function name matches the component name
|
|
79
79
|
const functionName = firstStatement.id?.name;
|
|
80
80
|
if (functionName !== componentName) {
|
|
81
|
-
violations.push(
|
|
81
|
+
violations.push(CreateViolation('single-function-only', 'critical', firstStatement, `Component function name "${functionName}" does not match component name "${componentName}". The function must be named exactly as specified.`, `Rename to: function ${componentName}(...)`));
|
|
82
82
|
}
|
|
83
83
|
// Additional check: look for any code before the function that might have been missed
|
|
84
84
|
// (e.g., leading variable declarations that destructure from React)
|
|
85
85
|
if (programBody.length === 1 && t.isFunctionDeclaration(firstStatement)) {
|
|
86
86
|
// Use traverse to find any problematic patterns inside
|
|
87
|
-
|
|
87
|
+
Traverse(ast, {
|
|
88
88
|
Program(path) {
|
|
89
89
|
// Check if there are any directives or other non-obvious code
|
|
90
90
|
if (path.node.directives && path.node.directives.length > 0) {
|
|
91
|
-
violations.push(
|
|
91
|
+
violations.push(CreateViolation('single-function-only', 'high', null, 'Component should not have directives like "use strict". These are added automatically.', ''));
|
|
92
92
|
}
|
|
93
93
|
},
|
|
94
94
|
});
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -30,7 +30,7 @@ let StringReplaceAllOccurrencesRule = class StringReplaceAllOccurrencesRule exte
|
|
|
30
30
|
{ pattern: /<<[^>]+>>/, example: '<<field>>', desc: 'double angle brackets' },
|
|
31
31
|
{ pattern: /<[^>]+>/, example: '<field>', desc: 'single angle brackets' },
|
|
32
32
|
];
|
|
33
|
-
|
|
33
|
+
Traverse(ast, {
|
|
34
34
|
CallExpression(path) {
|
|
35
35
|
const callee = path.node.callee;
|
|
36
36
|
// Check if it's a .replace() method call
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -26,7 +26,7 @@ let StringTemplateValidationRule = class StringTemplateValidationRule extends Ba
|
|
|
26
26
|
get AppliesTo() { return 'all'; }
|
|
27
27
|
Test(ast, _componentName) {
|
|
28
28
|
const violations = [];
|
|
29
|
-
|
|
29
|
+
Traverse(ast, {
|
|
30
30
|
// Check for malformed template literals
|
|
31
31
|
TemplateLiteral(path) {
|
|
32
32
|
// Template literals are parsed correctly by Babel, so if we're here it's valid
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -41,7 +41,7 @@ let StylesValidationRule = class StylesValidationRule extends BaseLintRule {
|
|
|
41
41
|
Test(ast, componentName, componentSpec) {
|
|
42
42
|
const violations = [];
|
|
43
43
|
const analyzer = getStylesAnalyzer();
|
|
44
|
-
|
|
44
|
+
Traverse(ast, {
|
|
45
45
|
MemberExpression(path) {
|
|
46
46
|
// Build the complete property chain first
|
|
47
47
|
const propertyChain = [];
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -34,7 +34,7 @@ let TypeMismatchOperationRule = class TypeMismatchOperationRule extends BaseLint
|
|
|
34
34
|
const cfa = new ControlFlowAnalyzer(ast, componentSpec);
|
|
35
35
|
// Run analysis synchronously (the async part is not needed for basic inference)
|
|
36
36
|
typeEngine.analyze(ast);
|
|
37
|
-
|
|
37
|
+
Traverse(ast, {
|
|
38
38
|
// Check binary operations for type mismatches
|
|
39
39
|
BinaryExpression(path) {
|
|
40
40
|
const node = path.node;
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -26,7 +26,7 @@ let UndefinedComponentUsageRule = class UndefinedComponentUsageRule extends Base
|
|
|
26
26
|
const componentsFromProps = new Set();
|
|
27
27
|
const componentsUsedInJSX = new Set();
|
|
28
28
|
let hasComponentsProp = false;
|
|
29
|
-
|
|
29
|
+
Traverse(ast, {
|
|
30
30
|
// First, find what's destructured from the components prop
|
|
31
31
|
VariableDeclarator(path) {
|
|
32
32
|
if (t.isObjectPattern(path.node.id) && t.isIdentifier(path.node.init)) {
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -85,7 +85,7 @@ let UndefinedJsxComponentRule = class UndefinedJsxComponentRule extends BaseLint
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
Traverse(ast, {
|
|
89
89
|
// Track variable declarations
|
|
90
90
|
VariableDeclarator(path) {
|
|
91
91
|
if (t.isIdentifier(path.node.id)) {
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -33,7 +33,7 @@ let UnsafeArrayOperationsRule = class UnsafeArrayOperationsRule extends BaseLint
|
|
|
33
33
|
const cfa = new ControlFlowAnalyzer(ast, componentSpec);
|
|
34
34
|
// Track which parameters are from props (likely from queries/RunView)
|
|
35
35
|
const propsParams = new Set();
|
|
36
|
-
|
|
36
|
+
Traverse(ast, {
|
|
37
37
|
// Find the main component function to identify props
|
|
38
38
|
FunctionDeclaration(path) {
|
|
39
39
|
if (path.node.id?.name === componentName) {
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -116,7 +116,7 @@ let UnsafeFormattingMethodsRule = class UnsafeFormattingMethodsRule extends Base
|
|
|
116
116
|
}
|
|
117
117
|
return { found: false, nullable: false };
|
|
118
118
|
};
|
|
119
|
-
|
|
119
|
+
Traverse(ast, {
|
|
120
120
|
// Check JSX expressions
|
|
121
121
|
JSXExpressionContainer(path) {
|
|
122
122
|
const expr = path.node.expression;
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import { BaseLintRule } from '../lint-rule.js';
|
|
10
10
|
/**
|
|
@@ -32,7 +32,7 @@ let UnusedComponentDependenciesRule = class UnusedComponentDependenciesRule exte
|
|
|
32
32
|
}
|
|
33
33
|
// Get the function body to search within
|
|
34
34
|
let functionBody = '';
|
|
35
|
-
|
|
35
|
+
Traverse(ast, {
|
|
36
36
|
FunctionDeclaration(path) {
|
|
37
37
|
if (path.node.id && path.node.id.name === componentName) {
|
|
38
38
|
functionBody = path.toString();
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import { BaseLintRule } from '../lint-rule.js';
|
|
10
10
|
/**
|
|
@@ -27,7 +27,7 @@ let UnusedLibrariesRule = class UnusedLibrariesRule extends BaseLintRule {
|
|
|
27
27
|
}
|
|
28
28
|
// Get the function body to search within — include root AND child component code
|
|
29
29
|
let functionBody = '';
|
|
30
|
-
|
|
30
|
+
Traverse(ast, {
|
|
31
31
|
FunctionDeclaration(path) {
|
|
32
32
|
if (path.node.id && path.node.id.name === componentName) {
|
|
33
33
|
functionBody = path.toString();
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { RegisterClass } from '@memberjunction/global';
|
|
8
8
|
import * as t from '@babel/types';
|
|
9
9
|
import { BaseLintRule } from '../lint-rule.js';
|
|
10
|
-
import {
|
|
10
|
+
import { Traverse, CreateViolation, TruncateCode } from '../lint-utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* Rule: use-function-declaration
|
|
13
13
|
*
|
|
@@ -22,7 +22,7 @@ let UseFunctionDeclarationRule = class UseFunctionDeclarationRule extends BaseLi
|
|
|
22
22
|
get AppliesTo() { return 'all'; }
|
|
23
23
|
Test(ast, componentName) {
|
|
24
24
|
const violations = [];
|
|
25
|
-
|
|
25
|
+
Traverse(ast, {
|
|
26
26
|
VariableDeclarator(path) {
|
|
27
27
|
// Only check TOP-LEVEL declarations (not nested inside functions)
|
|
28
28
|
// This prevents flagging arrow functions inside the component
|
|
@@ -35,7 +35,7 @@ let UseFunctionDeclarationRule = class UseFunctionDeclarationRule extends BaseLi
|
|
|
35
35
|
const init = path.node.init;
|
|
36
36
|
// Check if it's an arrow function
|
|
37
37
|
if (t.isArrowFunctionExpression(init)) {
|
|
38
|
-
violations.push(
|
|
38
|
+
violations.push(CreateViolation('use-function-declaration', 'critical', path.node, `Component "${componentName}" must be defined using function declaration syntax, not arrow function.`, TruncateCode(path.toString(), 150), {
|
|
39
39
|
text: 'Use function declaration syntax for TOP-LEVEL component definitions. Arrow functions are fine inside components.',
|
|
40
40
|
example: `// ❌ WRONG - Top-level arrow function component:
|
|
41
41
|
const MyComponent = ({ utilities, styles, components }) => {
|
|
@@ -78,7 +78,7 @@ function ChildComponent() {
|
|
|
78
78
|
const init = path.node.init;
|
|
79
79
|
if (t.isArrowFunctionExpression(init)) {
|
|
80
80
|
// Only flag if it's at the top level (parallel to main component)
|
|
81
|
-
violations.push(
|
|
81
|
+
violations.push(CreateViolation('use-function-declaration', 'high', path.node, `Top-level component "${path.node.id.name}" should use function declaration syntax.`, TruncateCode(path.toString(), 150), {
|
|
82
82
|
text: 'Use function declaration syntax for TOP-LEVEL component definitions. Arrow functions are fine inside components.',
|
|
83
83
|
example: `// ❌ WRONG - Top-level arrow function component:
|
|
84
84
|
const MyComponent = ({ utilities, styles, components }) => {
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -31,7 +31,7 @@ let UseUnwrapComponentsRule = class UseUnwrapComponentsRule extends BaseLintRule
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
Traverse(ast, {
|
|
35
35
|
VariableDeclarator(path) {
|
|
36
36
|
// Check for direct destructuring from library globals
|
|
37
37
|
if (t.isObjectPattern(path.node.id) && t.isIdentifier(path.node.init)) {
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -101,7 +101,7 @@ let UseeffectUnstableDependenciesRule = class UseeffectUnstableDependenciesRule
|
|
|
101
101
|
}
|
|
102
102
|
return paramsWithObjectDefaults;
|
|
103
103
|
};
|
|
104
|
-
|
|
104
|
+
Traverse(ast, {
|
|
105
105
|
CallExpression(path) {
|
|
106
106
|
// Check for useEffect calls
|
|
107
107
|
if (t.isIdentifier(path.node.callee) && path.node.callee.name === 'useEffect') {
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -36,7 +36,7 @@ let UtilitiesApiValidationRule = class UtilitiesApiValidationRule extends BaseLi
|
|
|
36
36
|
ai: { methods: new Set(['ExecutePrompt', 'EmbedText']), properties: new Set(['VectorService']) },
|
|
37
37
|
};
|
|
38
38
|
const validUtilityProps = new Set(Object.keys(utilitiesAPI));
|
|
39
|
-
|
|
39
|
+
Traverse(ast, {
|
|
40
40
|
// Check for utilities.* property access
|
|
41
41
|
MemberExpression(path) {
|
|
42
42
|
// Check for direct utilities.* access
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -29,7 +29,7 @@ let UtilitiesNoDirectInstantiationRule = class UtilitiesNoDirectInstantiationRul
|
|
|
29
29
|
['Metadata', 'utilities.md'],
|
|
30
30
|
['SimpleVectorService', 'utilities.ai.VectorService'],
|
|
31
31
|
]);
|
|
32
|
-
|
|
32
|
+
Traverse(ast, {
|
|
33
33
|
NewExpression(path) {
|
|
34
34
|
// Check if instantiating a restricted class
|
|
35
35
|
if (t.isIdentifier(path.node.callee)) {
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { Traverse } from '../lint-utils.js';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import * as t from '@babel/types';
|
|
10
10
|
import { BaseLintRule } from '../lint-rule.js';
|
|
@@ -41,7 +41,7 @@ let ValidateComponentReferencesRule = class ValidateComponentReferencesRule exte
|
|
|
41
41
|
const definedVariables = new Set();
|
|
42
42
|
const referencedComponents = new Set();
|
|
43
43
|
// First pass: collect all variable declarations and destructuring
|
|
44
|
-
|
|
44
|
+
Traverse(ast, {
|
|
45
45
|
// Track variable declarations (const x = ...)
|
|
46
46
|
VariableDeclarator(path) {
|
|
47
47
|
if (t.isIdentifier(path.node.id)) {
|
|
@@ -113,7 +113,7 @@ let ValidateComponentReferencesRule = class ValidateComponentReferencesRule exte
|
|
|
113
113
|
},
|
|
114
114
|
});
|
|
115
115
|
// Second pass: check component usage
|
|
116
|
-
|
|
116
|
+
Traverse(ast, {
|
|
117
117
|
// Look for React.createElement calls
|
|
118
118
|
CallExpression(path) {
|
|
119
119
|
const callee = path.node.callee;
|
|
@@ -69,8 +69,16 @@ export interface LintContext {
|
|
|
69
69
|
* 5. Unknown props warning
|
|
70
70
|
*/
|
|
71
71
|
export declare class ComponentPropRule {
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
Name: string;
|
|
73
|
+
/** @deprecated Use {@link Name}. */
|
|
74
|
+
get name(): string;
|
|
75
|
+
/** @deprecated Use {@link Name}. */
|
|
76
|
+
set name(value: string);
|
|
77
|
+
AppliesTo: 'all' | 'child' | 'root';
|
|
78
|
+
/** @deprecated Use {@link AppliesTo}. */
|
|
79
|
+
get appliesTo(): 'all' | 'child' | 'root';
|
|
80
|
+
/** @deprecated Use {@link AppliesTo}. */
|
|
81
|
+
set appliesTo(value: 'all' | 'child' | 'root');
|
|
74
82
|
private readonly standardProps;
|
|
75
83
|
private readonly reactSpecialProps;
|
|
76
84
|
/** SQL dialect for semantic validators, set from LintContext during validate() */
|
|
@@ -78,6 +86,8 @@ export declare class ComponentPropRule {
|
|
|
78
86
|
/**
|
|
79
87
|
* Validate component props
|
|
80
88
|
*/
|
|
89
|
+
Validate(ast: t.File, context: LintContext): Violation[];
|
|
90
|
+
/** @deprecated Use {@link Validate}. */
|
|
81
91
|
validate(ast: t.File, context: LintContext): Violation[];
|
|
82
92
|
/**
|
|
83
93
|
* Build map of dependency components to their full specs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-prop-rule.d.ts","sourceRoot":"","sources":["../../src/schema-validation/component-prop-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,aAAa,EAAsB,MAAM,6CAA6C,CAAC;AAOhG,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,cAAc,CAAC;IACnF,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,EAAE,GAAG,CAAC;IACjB,UAAU,EAAE,GAAG,CAAC;IAChB,mBAAmB,EAAE,GAAG,CAAC;IACzB,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,6BAA6B,EAAE,gBAAgB,CAAC;IACpE;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;CACxG;AAED;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IAC5B,IAAI,SAAqB;
|
|
1
|
+
{"version":3,"file":"component-prop-rule.d.ts","sourceRoot":"","sources":["../../src/schema-validation/component-prop-rule.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAKH,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,aAAa,EAAsB,MAAM,6CAA6C,CAAC;AAOhG,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,gBAAgB,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,cAAc,CAAC;IACnF,UAAU,CAAC,EAAE;QACX,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,EAAE,GAAG,CAAC;IACjB,UAAU,EAAE,GAAG,CAAC;IAChB,mBAAmB,EAAE,GAAG,CAAC;IACzB,kEAAkE;IAClE,UAAU,CAAC,EAAE,OAAO,6BAA6B,EAAE,gBAAgB,CAAC;IACpE;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,aAAa,GAAG,SAAS,CAAC;CACxG;AAED;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IAC5B,IAAI,SAAqB;IAEzB,oCAAoC;IACpC,IAAI,IAAI,WAEP;IACD,oCAAoC;IACpC,IAAI,IAAI,CAAC,KAAK,QAAA,EAEb;IACD,SAAS,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAS;IAE5C,yCAAyC;IACzC,IAAI,SAAS,IAAI,KAAK,GAAG,OAAO,GAAG,MAAM,CAExC;IACD,yCAAyC;IACzC,IAAI,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,EAE5C;IAGD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAiB3B;IAGH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoD;IAEtF,kFAAkF;IAClF,OAAO,CAAC,WAAW,CAAC,CAAyD;IAE7E;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE;IA8DxD,wCAAwC;IACxC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,SAAS,EAAE;IAIxD;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+B5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAyF9B;;OAEG;IACH,OAAO,CAAC,cAAc;IAUtB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAUxB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAgE7B;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAyDzB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAsCzB;;OAEG;IACH,OAAO,CAAC,sBAAsB;IA4B9B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAkE5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA2CxB;;OAEG;IACH,OAAO,CAAC,2BAA2B;CAsGpC"}
|
|
@@ -45,8 +45,8 @@ import { SemanticValidatorRegistry } from './semantic-validators/semantic-valida
|
|
|
45
45
|
*/
|
|
46
46
|
export class ComponentPropRule {
|
|
47
47
|
constructor() {
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
48
|
+
this.Name = 'component-props';
|
|
49
|
+
this.AppliesTo = 'all';
|
|
50
50
|
// Standard props that are always allowed on any component
|
|
51
51
|
this.standardProps = new Set([
|
|
52
52
|
'key',
|
|
@@ -69,10 +69,26 @@ export class ComponentPropRule {
|
|
|
69
69
|
// React special props
|
|
70
70
|
this.reactSpecialProps = new Set(['children', 'dangerouslySetInnerHTML']);
|
|
71
71
|
}
|
|
72
|
+
/** @deprecated Use {@link Name}. */
|
|
73
|
+
get name() {
|
|
74
|
+
return this.Name;
|
|
75
|
+
}
|
|
76
|
+
/** @deprecated Use {@link Name}. */
|
|
77
|
+
set name(value) {
|
|
78
|
+
this.Name = value;
|
|
79
|
+
}
|
|
80
|
+
/** @deprecated Use {@link AppliesTo}. */
|
|
81
|
+
get appliesTo() {
|
|
82
|
+
return this.AppliesTo;
|
|
83
|
+
}
|
|
84
|
+
/** @deprecated Use {@link AppliesTo}. */
|
|
85
|
+
set appliesTo(value) {
|
|
86
|
+
this.AppliesTo = value;
|
|
87
|
+
}
|
|
72
88
|
/**
|
|
73
89
|
* Validate component props
|
|
74
90
|
*/
|
|
75
|
-
|
|
91
|
+
Validate(ast, context) {
|
|
76
92
|
this._sqlDialect = context.sqlDialect;
|
|
77
93
|
const violations = [];
|
|
78
94
|
// Skip if no dependencies
|
|
@@ -109,6 +125,10 @@ export class ComponentPropRule {
|
|
|
109
125
|
});
|
|
110
126
|
return violations;
|
|
111
127
|
}
|
|
128
|
+
/** @deprecated Use {@link Validate}. */
|
|
129
|
+
validate(ast, context) {
|
|
130
|
+
return this.Validate(ast, context);
|
|
131
|
+
}
|
|
112
132
|
/**
|
|
113
133
|
* Build map of dependency components to their full specs
|
|
114
134
|
*/
|
|
@@ -582,17 +602,17 @@ export class ComponentPropRule {
|
|
|
582
602
|
}
|
|
583
603
|
// Build ValidationContext
|
|
584
604
|
const validationCtx = {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
605
|
+
Node: propAttr,
|
|
606
|
+
Path: path,
|
|
607
|
+
ComponentName: elementName,
|
|
608
|
+
ComponentSpec: depSpec,
|
|
589
609
|
propertyName: property.name,
|
|
590
610
|
propertyValue: propValue,
|
|
591
611
|
siblingProps,
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
612
|
+
Entities: new Map(),
|
|
613
|
+
Queries: new Map(),
|
|
614
|
+
TypeEngine: null,
|
|
615
|
+
Dialect: this._sqlDialect,
|
|
596
616
|
getEntityFields: validationHelpers.getEntityFields,
|
|
597
617
|
getEntityFieldType: validationHelpers.getEntityFieldType,
|
|
598
618
|
findSimilarFieldNames: validationHelpers.findSimilarFieldNames,
|