@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
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import * as t from '@babel/types';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import { BaseLintRule } from '../lint-rule.js';
|
|
10
|
-
import {
|
|
10
|
+
import { Traverse, TruncateCode } from '../lint-utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* Rule: no-react-destructuring
|
|
13
13
|
*
|
|
@@ -22,7 +22,7 @@ let NoReactDestructuringRule = class NoReactDestructuringRule extends BaseLintRu
|
|
|
22
22
|
get AppliesTo() { return 'all'; }
|
|
23
23
|
Test(ast) {
|
|
24
24
|
const violations = [];
|
|
25
|
-
|
|
25
|
+
Traverse(ast, {
|
|
26
26
|
VariableDeclarator(path) {
|
|
27
27
|
// Check for destructuring from React
|
|
28
28
|
if (t.isObjectPattern(path.node.id) && t.isIdentifier(path.node.init) && path.node.init.name === 'React') {
|
|
@@ -37,7 +37,7 @@ let NoReactDestructuringRule = class NoReactDestructuringRule extends BaseLintRu
|
|
|
37
37
|
line: path.node.loc?.start.line || 0,
|
|
38
38
|
column: path.node.loc?.start.column || 0,
|
|
39
39
|
message: `Cannot destructure from React. The hooks (${destructuredProps.join(', ')}) are already available as global functions in the React runtime.`,
|
|
40
|
-
code:
|
|
40
|
+
code: TruncateCode(path.toString()),
|
|
41
41
|
suggestion: {
|
|
42
42
|
text: `Remove the destructuring statement. React hooks like ${destructuredProps.join(', ')} are already available globally and don't need to be imported or destructured.`,
|
|
43
43
|
example: `// Remove this line entirely:
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import * as t from '@babel/types';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import { BaseLintRule } from '../lint-rule.js';
|
|
10
|
-
import {
|
|
10
|
+
import { Traverse, CreateViolation, TruncateCode } from '../lint-utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* Rule: no-require-statements
|
|
13
13
|
*
|
|
@@ -22,12 +22,12 @@ let NoRequireStatementsRule = class NoRequireStatementsRule extends BaseLintRule
|
|
|
22
22
|
get AppliesTo() { return 'all'; }
|
|
23
23
|
Test(ast, componentName) {
|
|
24
24
|
const violations = [];
|
|
25
|
-
|
|
25
|
+
Traverse(ast, {
|
|
26
26
|
CallExpression(path) {
|
|
27
27
|
const callee = path.node.callee;
|
|
28
28
|
// Check for require() calls
|
|
29
29
|
if (t.isIdentifier(callee) && callee.name === 'require') {
|
|
30
|
-
violations.push(
|
|
30
|
+
violations.push(CreateViolation('no-require-statements', 'critical', path.node, `Component "${componentName}" contains a require() statement. Interactive components cannot use require - all dependencies must be passed as props.`, TruncateCode(path.toString()), {
|
|
31
31
|
text: 'Remove all require() and dynamic import() statements. Use props instead.',
|
|
32
32
|
example: `// ❌ WRONG - Using require or dynamic import:
|
|
33
33
|
function MyComponent({ utilities }) {
|
|
@@ -63,7 +63,7 @@ function MyComponent({ utilities, styles, components }) {
|
|
|
63
63
|
}
|
|
64
64
|
// Also check for dynamic import() calls
|
|
65
65
|
if (t.isImport(callee)) {
|
|
66
|
-
violations.push(
|
|
66
|
+
violations.push(CreateViolation('no-require-statements', 'critical', path.node, `Component "${componentName}" contains a dynamic import() statement. Interactive components cannot use dynamic imports - all dependencies must be passed as props.`, TruncateCode(path.toString()), {
|
|
67
67
|
text: 'Remove all require() and dynamic import() statements. Use props instead.',
|
|
68
68
|
example: `// ❌ WRONG - Using require or dynamic import:
|
|
69
69
|
function MyComponent({ utilities }) {
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import * as t from '@babel/types';
|
|
8
8
|
import { RegisterClass } from '@memberjunction/global';
|
|
9
9
|
import { BaseLintRule } from '../lint-rule.js';
|
|
10
|
-
import {
|
|
10
|
+
import { CreateViolation } from '../lint-utils.js';
|
|
11
11
|
/**
|
|
12
12
|
* Rule: no-return-component
|
|
13
13
|
*
|
|
@@ -31,7 +31,7 @@ let NoReturnComponentRule = class NoReturnComponentRule extends BaseLintRule {
|
|
|
31
31
|
// Check if it's returning the component identifier or any identifier
|
|
32
32
|
if (argument && t.isIdentifier(argument)) {
|
|
33
33
|
// If it's returning the component name or any identifier at top level
|
|
34
|
-
violations.push(
|
|
34
|
+
violations.push(CreateViolation('no-return-component', 'critical', statement, `Do not return the component at the end of the file. The component function should stand alone.`, `return ${argument.name};`, {
|
|
35
35
|
text: 'Remove the return statement at the end of the file. The component function should stand alone.',
|
|
36
36
|
example: `// ❌ WRONG - Returning the component:
|
|
37
37
|
function MyComponent({ utilities, styles, components }) {
|
|
@@ -64,7 +64,7 @@ function MyComponent({ utilities, styles, components }) {
|
|
|
64
64
|
}
|
|
65
65
|
// Also check for expression statements that might be standalone identifiers
|
|
66
66
|
if (t.isExpressionStatement(statement) && t.isIdentifier(statement.expression) && statement.expression.name === componentName) {
|
|
67
|
-
violations.push(
|
|
67
|
+
violations.push(CreateViolation('no-return-component', 'critical', statement, `Do not reference the component "${componentName}" at the end of the file. The component function should stand alone.`, statement.expression.name, {
|
|
68
68
|
text: 'Remove the return statement at the end of the file. The component function should stand alone.',
|
|
69
69
|
example: `// ❌ WRONG - Returning the component:
|
|
70
70
|
function 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, CreateViolation, TruncateCode } 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';
|
|
@@ -39,7 +39,7 @@ let NoUnwrapUtilityLibsRule = class NoUnwrapUtilityLibsRule extends BaseLintRule
|
|
|
39
39
|
get AppliesTo() { return 'all'; }
|
|
40
40
|
Test(ast, componentName) {
|
|
41
41
|
const violations = [];
|
|
42
|
-
|
|
42
|
+
Traverse(ast, {
|
|
43
43
|
CallExpression(path) {
|
|
44
44
|
if (!t.isIdentifier(path.node.callee) || path.node.callee.name !== 'unwrapLibraryComponents') {
|
|
45
45
|
return;
|
|
@@ -56,7 +56,7 @@ let NoUnwrapUtilityLibsRule = class NoUnwrapUtilityLibsRule extends BaseLintRule
|
|
|
56
56
|
const message = `Do not use unwrapLibraryComponents() with utility library "${globalName}" (${libInfo.library}). ` +
|
|
57
57
|
`Utility libraries expose their API as methods on the global variable — call them directly ` +
|
|
58
58
|
`(e.g., ${libInfo.example}). unwrapLibraryComponents() is only for UI component libraries like antd.`;
|
|
59
|
-
violations.push(
|
|
59
|
+
violations.push(CreateViolation('no-unwrap-utility-libs', 'critical', path.node, message, TruncateCode(path.toString()), {
|
|
60
60
|
text: 'Remove the unwrapLibraryComponents() call and use the library global directly.',
|
|
61
61
|
example: '// Instead of:\n' +
|
|
62
62
|
`const { debounce } = unwrapLibraryComponents(${globalName}, 'debounce');\n` +
|
|
@@ -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';
|
|
@@ -23,7 +23,7 @@ let NoUseReducerRule = class NoUseReducerRule extends BaseLintRule {
|
|
|
23
23
|
get AppliesTo() { return 'all'; }
|
|
24
24
|
Test(ast, componentName) {
|
|
25
25
|
const violations = [];
|
|
26
|
-
|
|
26
|
+
Traverse(ast, {
|
|
27
27
|
CallExpression(path) {
|
|
28
28
|
const callee = path.node.callee;
|
|
29
29
|
if ((t.isIdentifier(callee) && callee.name === 'useReducer') ||
|
|
@@ -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';
|
|
@@ -38,7 +38,7 @@ let NoWindowAccessRule = class NoWindowAccessRule extends BaseLintRule {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
Traverse(ast, {
|
|
42
42
|
MemberExpression(path) {
|
|
43
43
|
// Check if accessing window object
|
|
44
44
|
if (t.isIdentifier(path.node.object) && path.node.object.name === 'window') {
|
|
@@ -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';
|
|
@@ -47,7 +47,7 @@ let NoisySettingsUpdatesRule = class NoisySettingsUpdatesRule extends BaseLintRu
|
|
|
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
|
// Check for onSaveUserSettings calls
|
|
53
53
|
if (t.isOptionalCallExpression(path.node) || t.isCallExpression(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, CreateViolation, TruncateCode } 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';
|
|
@@ -34,7 +34,7 @@ let OverflowHiddenOnLayoutContainerRule = class OverflowHiddenOnLayoutContainerR
|
|
|
34
34
|
get AppliesTo() { return 'all'; }
|
|
35
35
|
Test(ast, componentName) {
|
|
36
36
|
const violations = [];
|
|
37
|
-
|
|
37
|
+
Traverse(ast, {
|
|
38
38
|
ObjectExpression(path) {
|
|
39
39
|
if (!isInlineStyleObject(path)) {
|
|
40
40
|
return;
|
|
@@ -54,10 +54,10 @@ let OverflowHiddenOnLayoutContainerRule = class OverflowHiddenOnLayoutContainerR
|
|
|
54
54
|
if (!isLayoutContainer(props)) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
|
-
violations.push(
|
|
57
|
+
violations.push(CreateViolation('overflow-hidden-on-layout-container', 'medium', path.node, `Component "${componentName}" uses overflow: 'hidden' on a layout container ` +
|
|
58
58
|
`(with ${describeLayoutIndicator(props)}). This creates an invisible clipping ` +
|
|
59
59
|
`boundary that blocks scrolling for child content like DataGrid, tables, and ` +
|
|
60
|
-
`lists. The Angular host already manages scrolling via overflow: auto.`,
|
|
60
|
+
`lists. The Angular host already manages scrolling via overflow: auto.`, TruncateCode(formatStyleSnippet(props), 100), {
|
|
61
61
|
text: `Use overflow: 'auto' to allow child scrolling, or remove the overflow property entirely.`,
|
|
62
62
|
example: `// Before (blocks scrolling):\n` +
|
|
63
63
|
`style={{ flex: 1, overflow: 'hidden' }}\n\n` +
|
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { RegisterClass } from '@memberjunction/global';
|
|
8
8
|
import { BaseLintRule } from '../lint-rule.js';
|
|
9
|
-
import {
|
|
9
|
+
import { Traverse, CreateViolation, GetJSXElementName, HasJSXAttribute } from '../lint-utils.js';
|
|
10
10
|
/**
|
|
11
11
|
* Rule: pass-standard-props
|
|
12
12
|
*
|
|
@@ -37,21 +37,21 @@ let PassStandardPropsRule = class PassStandardPropsRule extends BaseLintRule {
|
|
|
37
37
|
if (ourComponentNames.size === 0) {
|
|
38
38
|
return violations;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
Traverse(ast, {
|
|
41
41
|
JSXElement(path) {
|
|
42
42
|
const openingElement = path.node.openingElement;
|
|
43
|
-
const elementName =
|
|
43
|
+
const elementName = GetJSXElementName(openingElement);
|
|
44
44
|
// Only check if this is one of our dependency components
|
|
45
45
|
if (elementName && ourComponentNames.has(elementName)) {
|
|
46
46
|
// Check for required props
|
|
47
47
|
const missingProps = [];
|
|
48
48
|
for (const propName of requiredProps) {
|
|
49
|
-
if (!
|
|
49
|
+
if (!HasJSXAttribute(openingElement, propName)) {
|
|
50
50
|
missingProps.push(propName);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
if (missingProps.length > 0) {
|
|
54
|
-
violations.push(
|
|
54
|
+
violations.push(CreateViolation('pass-standard-props', 'critical', openingElement, `Dependency component "${elementName}" is missing required props: ${missingProps.join(', ')}. Components from dependencies must receive styles, utilities, and components props.`, `<${elementName} ... />`, {
|
|
55
55
|
text: 'Always pass standard props to all components',
|
|
56
56
|
example: `// Always include these props when calling components:
|
|
57
57
|
<ChildComponent
|
|
@@ -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';
|
|
@@ -21,7 +21,7 @@ let PreferAsyncAwaitRule = class PreferAsyncAwaitRule extends BaseLintRule {
|
|
|
21
21
|
get AppliesTo() { return 'all'; }
|
|
22
22
|
Test(ast, _componentName) {
|
|
23
23
|
const violations = [];
|
|
24
|
-
|
|
24
|
+
Traverse(ast, {
|
|
25
25
|
CallExpression(path) {
|
|
26
26
|
const callee = path.node.callee;
|
|
27
27
|
// Check for .then() chains
|
|
@@ -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';
|
|
@@ -21,7 +21,7 @@ let PreferJsxSyntaxRule = class PreferJsxSyntaxRule extends BaseLintRule {
|
|
|
21
21
|
get AppliesTo() { return 'all'; }
|
|
22
22
|
Test(ast, _componentName) {
|
|
23
23
|
const violations = [];
|
|
24
|
-
|
|
24
|
+
Traverse(ast, {
|
|
25
25
|
CallExpression(path) {
|
|
26
26
|
const callee = path.node.callee;
|
|
27
27
|
// Check for React.createElement
|
|
@@ -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';
|
|
@@ -23,7 +23,7 @@ let PropStateSyncRule = class PropStateSyncRule extends BaseLintRule {
|
|
|
23
23
|
get AppliesTo() { return 'all'; }
|
|
24
24
|
Test(ast, _componentName) {
|
|
25
25
|
const violations = [];
|
|
26
|
-
|
|
26
|
+
Traverse(ast, {
|
|
27
27
|
CallExpression(path) {
|
|
28
28
|
if (t.isIdentifier(path.node.callee) && path.node.callee.name === 'useEffect') {
|
|
29
29
|
const effectBody = path.node.arguments[0];
|
|
@@ -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';
|
|
@@ -27,7 +27,7 @@ let PropertyNameConsistencyRule = class PropertyNameConsistencyRule extends Base
|
|
|
27
27
|
const dataTransformations = new Map();
|
|
28
28
|
const propertyAccesses = new Map(); // variable -> accessed properties
|
|
29
29
|
// Track data transformations (especially in map functions)
|
|
30
|
-
|
|
30
|
+
Traverse(ast, {
|
|
31
31
|
CallExpression(path) {
|
|
32
32
|
// Look for array.map transformations
|
|
33
33
|
if (t.isMemberExpression(path.node.callee) && t.isIdentifier(path.node.callee.property) && path.node.callee.property.name === 'map') {
|
|
@@ -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, CreateViolation, TruncateCode, FindClosestMatch, FindCaseMismatch, NUMERIC_COERCION_FUNCTIONS } 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';
|
|
@@ -109,7 +109,7 @@ let QueryResultFieldAccessValidationRule = class QueryResultFieldAccessValidatio
|
|
|
109
109
|
// Emit skip-with-warning for queries that were declared but have no field metadata
|
|
110
110
|
for (const queryReq of componentSpec.dataRequirements.queries) {
|
|
111
111
|
if (!queryFieldsMap.has(queryReq.name)) {
|
|
112
|
-
violations.push(
|
|
112
|
+
violations.push(CreateViolation('query-result-field-access-validation', 'low', null, `Unable to validate field access on query '${queryReq.name}' results — query field metadata not available. Add fields to dataRequirements.queries for accurate validation.`, queryReq.name));
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
// If we couldn't load any query field metadata, skip further validation
|
|
@@ -135,26 +135,26 @@ let QueryResultFieldAccessValidationRule = class QueryResultFieldAccessValidatio
|
|
|
135
135
|
if (validFields.has(propertyName))
|
|
136
136
|
return;
|
|
137
137
|
// Check for case mismatch first (medium severity)
|
|
138
|
-
const caseFix =
|
|
138
|
+
const caseFix = FindCaseMismatch(propertyName, validFields);
|
|
139
139
|
if (caseFix) {
|
|
140
|
-
violations.push(
|
|
140
|
+
violations.push(CreateViolation('query-result-field-access-validation', 'medium', node, `Field "${propertyName}" on query "${queryName}" has incorrect casing. Did you mean "${caseFix}"?`, `${paramName}.${propertyName}`, {
|
|
141
141
|
text: `Use the correct casing: "${caseFix}".`,
|
|
142
142
|
example: `// Change:\n${paramName}.${propertyName}\n// To:\n${paramName}.${caseFix}`,
|
|
143
143
|
}));
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
// Check for close typo via Levenshtein (high severity)
|
|
147
|
-
const closest =
|
|
147
|
+
const closest = FindClosestMatch(propertyName, validFields);
|
|
148
148
|
const availableFields = Array.from(validFields).slice(0, 10);
|
|
149
149
|
const moreText = validFields.size > 10 ? ` and ${validFields.size - 10} more` : '';
|
|
150
150
|
if (closest) {
|
|
151
|
-
violations.push(
|
|
151
|
+
violations.push(CreateViolation('query-result-field-access-validation', 'high', node, `Field "${propertyName}" does not exist on query "${queryName}". Did you mean "${closest}"? Available fields: ${availableFields.join(', ')}${moreText}`, `${paramName}.${propertyName}`, {
|
|
152
152
|
text: `Replace "${propertyName}" with "${closest}".`,
|
|
153
153
|
example: `// Change:\n${paramName}.${propertyName}\n// To:\n${paramName}.${closest}`,
|
|
154
154
|
}));
|
|
155
155
|
}
|
|
156
156
|
else {
|
|
157
|
-
violations.push(
|
|
157
|
+
violations.push(CreateViolation('query-result-field-access-validation', 'high', node, `Field "${propertyName}" does not exist on query "${queryName}". Available fields: ${availableFields.join(', ')}${moreText}`, `${paramName}.${propertyName}`, {
|
|
158
158
|
text: `Use one of the valid fields from the "${queryName}" query.`,
|
|
159
159
|
}));
|
|
160
160
|
}
|
|
@@ -181,7 +181,7 @@ let QueryResultFieldAccessValidationRule = class QueryResultFieldAccessValidatio
|
|
|
181
181
|
const typeMap = queryFieldTypesMap.get(queryName);
|
|
182
182
|
const sqlType = typeMap?.get(access.propertyName);
|
|
183
183
|
if (typeof sqlType === 'string' && sqlType.toLowerCase() === 'uniqueidentifier') {
|
|
184
|
-
violations.push(
|
|
184
|
+
violations.push(CreateViolation('query-result-field-access-validation', 'medium', callNode, `${callNode.callee.name}(${access.objectName}.${access.propertyName}) coerces a uniqueidentifier (GUID) to a number. GUIDs are strings, not numeric values.`, TruncateCode(`${callNode.callee.name}(${access.objectName}.${access.propertyName})`), {
|
|
185
185
|
text: `"${access.propertyName}" is a uniqueidentifier field. Use it as a string directly.`,
|
|
186
186
|
example: `// Instead of:\n${callNode.callee.name}(${access.objectName}.${access.propertyName})\n// Use:\n${access.objectName}.${access.propertyName} // Already a string`,
|
|
187
187
|
}));
|
|
@@ -195,7 +195,7 @@ let QueryResultFieldAccessValidationRule = class QueryResultFieldAccessValidatio
|
|
|
195
195
|
for (const p of paramNames) {
|
|
196
196
|
queryRowParams.set(p, queryName);
|
|
197
197
|
}
|
|
198
|
-
|
|
198
|
+
Traverse(body, {
|
|
199
199
|
MemberExpression(innerPath) {
|
|
200
200
|
const objName = t.isIdentifier(innerPath.node.object) ? innerPath.node.object.name : null;
|
|
201
201
|
if (objName && queryRowParams.has(objName)) {
|
|
@@ -215,7 +215,7 @@ let QueryResultFieldAccessValidationRule = class QueryResultFieldAccessValidatio
|
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
217
|
// Main traversal
|
|
218
|
-
|
|
218
|
+
Traverse(ast, {
|
|
219
219
|
VariableDeclarator(path) {
|
|
220
220
|
if (!t.isIdentifier(path.node.id))
|
|
221
221
|
return;
|
|
@@ -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: react-component-naming
|
|
13
13
|
*
|
|
@@ -23,7 +23,7 @@ let ReactComponentNamingRule = class ReactComponentNamingRule extends BaseLintRu
|
|
|
23
23
|
get AppliesTo() { return 'all'; }
|
|
24
24
|
Test(ast, componentName) {
|
|
25
25
|
const violations = [];
|
|
26
|
-
|
|
26
|
+
Traverse(ast, {
|
|
27
27
|
FunctionDeclaration(path) {
|
|
28
28
|
if (path.node.id && path.node.id.name === componentName) {
|
|
29
29
|
// Check if it's the main component function
|
|
@@ -32,7 +32,7 @@ let ReactComponentNamingRule = class ReactComponentNamingRule extends BaseLintRu
|
|
|
32
32
|
const firstParam = path.node.params[0];
|
|
33
33
|
const hasComponentProps = firstParam && (t.isObjectPattern(firstParam) || t.isIdentifier(firstParam));
|
|
34
34
|
if (hasComponentProps && funcName[0] !== funcName[0].toUpperCase()) {
|
|
35
|
-
violations.push(
|
|
35
|
+
violations.push(CreateViolation('react-component-naming', 'critical', path.node.id, `React component "${funcName}" must start with uppercase. JSX treats lowercase as HTML elements.`, `function ${funcName[0].toUpperCase()}${funcName.slice(1)}`));
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
// Also check for any other component-like functions
|
|
@@ -56,7 +56,7 @@ let ReactComponentNamingRule = class ReactComponentNamingRule extends BaseLintRu
|
|
|
56
56
|
.map((p) => p.key.name);
|
|
57
57
|
const hasComponentLikeProps = propNames.some((name) => ['utilities', 'styles', 'components', 'callbacks', 'savedUserSettings', 'onSaveUserSettings'].includes(name));
|
|
58
58
|
if (hasComponentLikeProps && funcName[0] !== funcName[0].toUpperCase()) {
|
|
59
|
-
violations.push(
|
|
59
|
+
violations.push(CreateViolation('react-component-naming', 'critical', path.node.id, `Function "${funcName}" appears to be a React component and must start with uppercase.`, `function ${funcName[0].toUpperCase()}${funcName.slice(1)}`));
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -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';
|
|
@@ -57,7 +57,7 @@ let ReactHooksRulesRule = class ReactHooksRulesRule extends BaseLintRule {
|
|
|
57
57
|
Test(ast, componentName) {
|
|
58
58
|
const violations = [];
|
|
59
59
|
const hooks = ['useState', 'useEffect', 'useMemo', 'useCallback', 'useRef', 'useContext', 'useReducer', 'useLayoutEffect'];
|
|
60
|
-
|
|
60
|
+
Traverse(ast, {
|
|
61
61
|
CallExpression(path) {
|
|
62
62
|
let hookName = null;
|
|
63
63
|
if (t.isIdentifier(path.node.callee) && hooks.includes(path.node.callee.name)) {
|
|
@@ -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, ExtractRunQueryNamesFromCode } 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';
|
|
@@ -54,7 +54,7 @@ let RequiredQueriesNotCalledRule = class RequiredQueriesNotCalledRule extends Ba
|
|
|
54
54
|
}
|
|
55
55
|
// Method 2: Parse child code AST and extract actual RunQuery QueryName values
|
|
56
56
|
if (dep.code) {
|
|
57
|
-
for (const name of
|
|
57
|
+
for (const name of ExtractRunQueryNamesFromCode(dep.code)) {
|
|
58
58
|
childClaimedQueries.add(name);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -68,7 +68,7 @@ let RequiredQueriesNotCalledRule = class RequiredQueriesNotCalledRule extends Ba
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
if (grandchild.code) {
|
|
71
|
-
for (const name of
|
|
71
|
+
for (const name of ExtractRunQueryNamesFromCode(grandchild.code)) {
|
|
72
72
|
childClaimedQueries.add(name);
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -83,7 +83,7 @@ let RequiredQueriesNotCalledRule = class RequiredQueriesNotCalledRule extends Ba
|
|
|
83
83
|
}
|
|
84
84
|
// Track whether RunQuery is called anywhere in the root component's code
|
|
85
85
|
let hasRunQueryCall = false;
|
|
86
|
-
|
|
86
|
+
Traverse(ast, {
|
|
87
87
|
CallExpression(path) {
|
|
88
88
|
// Check for utilities.rq.RunQuery pattern
|
|
89
89
|
if (t.isMemberExpression(path.node.callee) &&
|
|
@@ -4,11 +4,11 @@ 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, IsStringLike, IsNumberLike, IsObjectLike } 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';
|
|
11
|
-
import {
|
|
11
|
+
import { MapSQLTypeToJSType } from '../type-context.js';
|
|
12
12
|
/**
|
|
13
13
|
* Rule: runquery-call-validation
|
|
14
14
|
*
|
|
@@ -102,7 +102,7 @@ function isRunQueryCallee(callee) {
|
|
|
102
102
|
// ── useState init collector ──────────────────────────────────────────
|
|
103
103
|
function collectUseStateInits(ast) {
|
|
104
104
|
const stateInits = new Map();
|
|
105
|
-
|
|
105
|
+
Traverse(ast, {
|
|
106
106
|
VariableDeclarator(path) {
|
|
107
107
|
if (!t.isArrayPattern(path.node.id))
|
|
108
108
|
return;
|
|
@@ -183,7 +183,7 @@ function buildInvalidRunQueryPropertyMessage(propName) {
|
|
|
183
183
|
// ── Property type validation ─────────────────────────────────────────
|
|
184
184
|
function validateRunQueryPropertyType(propName, value, prop, violations) {
|
|
185
185
|
if (propName === 'QueryID' || propName === 'QueryName' || propName === 'CategoryID' || propName === 'CategoryPath') {
|
|
186
|
-
if (!
|
|
186
|
+
if (!IsStringLike(value)) {
|
|
187
187
|
const exampleMap = {
|
|
188
188
|
QueryID: `"550e8400-e29b-41d4-a716-446655440000"`,
|
|
189
189
|
QueryName: `"Sales by Region"`,
|
|
@@ -202,7 +202,7 @@ function validateRunQueryPropertyType(propName, value, prop, violations) {
|
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
else if (propName === 'Parameters') {
|
|
205
|
-
if (!
|
|
205
|
+
if (!IsObjectLike(value)) {
|
|
206
206
|
violations.push({
|
|
207
207
|
rule: RULE_NAME,
|
|
208
208
|
severity: 'critical',
|
|
@@ -215,7 +215,7 @@ function validateRunQueryPropertyType(propName, value, prop, violations) {
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
else if (propName === 'MaxRows' || propName === 'StartRow') {
|
|
218
|
-
if (!
|
|
218
|
+
if (!IsNumberLike(value)) {
|
|
219
219
|
violations.push({
|
|
220
220
|
rule: RULE_NAME,
|
|
221
221
|
severity: 'critical',
|
|
@@ -500,7 +500,7 @@ function validateParameterValueTypes(parametersNode, queryName, componentSpec, v
|
|
|
500
500
|
const extParam = param;
|
|
501
501
|
if (extParam.type) {
|
|
502
502
|
paramTypes.set(param.name.toLowerCase(), {
|
|
503
|
-
type:
|
|
503
|
+
type: MapSQLTypeToJSType(extParam.type),
|
|
504
504
|
sqlType: extParam.type,
|
|
505
505
|
});
|
|
506
506
|
}
|
|
@@ -690,7 +690,7 @@ let RunQueryCallValidationRule = class RunQueryCallValidationRule extends BaseLi
|
|
|
690
690
|
const violations = [];
|
|
691
691
|
// Pre-collect useState initializers for type checking
|
|
692
692
|
const stateInits = collectUseStateInits(ast);
|
|
693
|
-
|
|
693
|
+
Traverse(ast, {
|
|
694
694
|
CallExpression(path) {
|
|
695
695
|
if (!isRunQueryCallee(path.node.callee))
|
|
696
696
|
return;
|
|
@@ -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, IsNullOrUndefined, IsStringLike, IsNumberLike, IsArrayLike } 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';
|
|
@@ -108,7 +108,7 @@ function buildInvalidPropertyMessage(methodName, propName) {
|
|
|
108
108
|
function validatePropertyType(methodName, propName, value, prop, violations) {
|
|
109
109
|
if (propName === 'ExtraFilter' || propName === 'OrderBy' || propName === 'EntityName') {
|
|
110
110
|
const allowNullUndefined = propName === 'ExtraFilter' || propName === 'OrderBy';
|
|
111
|
-
if (!
|
|
111
|
+
if (!IsStringLike(value) && !(allowNullUndefined && IsNullOrUndefined(value))) {
|
|
112
112
|
const exampleMap = {
|
|
113
113
|
ExtraFilter: `"Status = 'Active' AND Type = 'Customer'"`,
|
|
114
114
|
OrderBy: `"CreatedAt DESC"`,
|
|
@@ -126,7 +126,7 @@ function validatePropertyType(methodName, propName, value, prop, violations) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
else if (propName === 'Fields') {
|
|
129
|
-
if (!
|
|
129
|
+
if (!IsArrayLike(value) && !IsStringLike(value)) {
|
|
130
130
|
violations.push({
|
|
131
131
|
rule: 'runview-call-validation',
|
|
132
132
|
severity: 'critical',
|
|
@@ -139,7 +139,7 @@ function validatePropertyType(methodName, propName, value, prop, violations) {
|
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
else if (propName === 'MaxRows' || propName === 'StartRow') {
|
|
142
|
-
if (!
|
|
142
|
+
if (!IsNumberLike(value)) {
|
|
143
143
|
violations.push({
|
|
144
144
|
rule: 'runview-call-validation',
|
|
145
145
|
severity: 'critical',
|
|
@@ -221,7 +221,7 @@ let RunViewCallValidationRule = class RunViewCallValidationRule extends BaseLint
|
|
|
221
221
|
get AppliesTo() { return 'all'; }
|
|
222
222
|
Test(ast, _componentName, componentSpec) {
|
|
223
223
|
const violations = [];
|
|
224
|
-
|
|
224
|
+
Traverse(ast, {
|
|
225
225
|
CallExpression(path) {
|
|
226
226
|
const callee = path.node.callee;
|
|
227
227
|
if (!t.isMemberExpression(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';
|
|
@@ -24,7 +24,7 @@ let SavedUserSettingsPatternRule = class SavedUserSettingsPatternRule extends Ba
|
|
|
24
24
|
Test(ast, componentName) {
|
|
25
25
|
const violations = [];
|
|
26
26
|
// Check for improper onSaveUserSettings usage
|
|
27
|
-
|
|
27
|
+
Traverse(ast, {
|
|
28
28
|
CallExpression(path) {
|
|
29
29
|
const callee = path.node.callee;
|
|
30
30
|
// Check for onSaveUserSettings calls
|