eslint-plugin-obsidian 2.7.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dto/callExpression.d.ts +14 -0
- package/dist/dto/callExpression.d.ts.map +1 -0
- package/dist/dto/callExpression.js +32 -0
- package/dist/dto/callExpression.js.map +1 -0
- package/dist/dto/class.js +2 -2
- package/dist/dto/class.js.map +1 -1
- package/dist/dto/componentProps.d.ts +8 -0
- package/dist/dto/componentProps.d.ts.map +1 -0
- package/dist/dto/componentProps.js +30 -0
- package/dist/dto/componentProps.js.map +1 -0
- package/dist/dto/context.d.ts +1 -1
- package/dist/dto/context.d.ts.map +1 -1
- package/dist/dto/decorator.js +2 -2
- package/dist/dto/decorator.js.map +1 -1
- package/dist/dto/file.d.ts +3 -1
- package/dist/dto/file.d.ts.map +1 -1
- package/dist/dto/file.js +14 -6
- package/dist/dto/file.js.map +1 -1
- package/dist/dto/functionalComponent.d.ts +8 -0
- package/dist/dto/functionalComponent.d.ts.map +1 -0
- package/dist/dto/functionalComponent.js +14 -0
- package/dist/dto/functionalComponent.js.map +1 -0
- package/dist/dto/generics.d.ts +9 -0
- package/dist/dto/generics.d.ts.map +1 -0
- package/dist/dto/generics.js +24 -0
- package/dist/dto/generics.js.map +1 -0
- package/dist/dto/identifier.d.ts +7 -0
- package/dist/dto/identifier.d.ts.map +1 -0
- package/dist/dto/identifier.js +13 -0
- package/dist/dto/identifier.js.map +1 -0
- package/dist/dto/types/missingType.d.ts +9 -0
- package/dist/dto/types/missingType.d.ts.map +1 -0
- package/dist/dto/types/missingType.js +22 -0
- package/dist/dto/types/missingType.js.map +1 -0
- package/dist/dto/types/singleType.d.ts +12 -0
- package/dist/dto/types/singleType.d.ts.map +1 -0
- package/dist/dto/types/singleType.js +29 -0
- package/dist/dto/types/singleType.js.map +1 -0
- package/dist/dto/types/type.d.ts +8 -0
- package/dist/dto/types/type.d.ts.map +1 -0
- package/dist/dto/types/type.js +3 -0
- package/dist/dto/types/type.js.map +1 -0
- package/dist/dto/types/typeIntersection.d.ts +13 -0
- package/dist/dto/types/typeIntersection.d.ts.map +1 -0
- package/dist/dto/types/typeIntersection.js +36 -0
- package/dist/dto/types/typeIntersection.js.map +1 -0
- package/dist/dto/types/typeLiteral.d.ts +11 -0
- package/dist/dto/types/typeLiteral.d.ts.map +1 -0
- package/dist/dto/types/typeLiteral.js +29 -0
- package/dist/dto/types/typeLiteral.js.map +1 -0
- package/dist/dto/types/typeReference.d.ts +12 -0
- package/dist/dto/types/typeReference.d.ts.map +1 -0
- package/dist/dto/types/typeReference.js +27 -0
- package/dist/dto/types/typeReference.js.map +1 -0
- package/dist/dto/variable.d.ts +9 -0
- package/dist/dto/variable.d.ts.map +1 -0
- package/dist/dto/variable.js +25 -0
- package/dist/dto/variable.js.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/rules/stronglyTypedInjectComponent/createRule.d.ts +8 -0
- package/dist/rules/stronglyTypedInjectComponent/createRule.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/createRule.js +17 -0
- package/dist/rules/stronglyTypedInjectComponent/createRule.js.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/index.d.ts +8 -0
- package/dist/rules/stronglyTypedInjectComponent/index.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/index.js +43 -0
- package/dist/rules/stronglyTypedInjectComponent/index.js.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/injectComponentHandler.d.ts +11 -0
- package/dist/rules/stronglyTypedInjectComponent/injectComponentHandler.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/injectComponentHandler.js +26 -0
- package/dist/rules/stronglyTypedInjectComponent/injectComponentHandler.js.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/errorReporter.d.ts +9 -0
- package/dist/rules/stronglyTypedInjectComponent/result/errorReporter.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/errorReporter.js +17 -0
- package/dist/rules/stronglyTypedInjectComponent/result/errorReporter.js.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/missingTypeError.d.ts +9 -0
- package/dist/rules/stronglyTypedInjectComponent/result/missingTypeError.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/missingTypeError.js +14 -0
- package/dist/rules/stronglyTypedInjectComponent/result/missingTypeError.js.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/redundantTypeError.d.ts +9 -0
- package/dist/rules/stronglyTypedInjectComponent/result/redundantTypeError.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/redundantTypeError.js +15 -0
- package/dist/rules/stronglyTypedInjectComponent/result/redundantTypeError.js.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/result.d.ts +5 -0
- package/dist/rules/stronglyTypedInjectComponent/result/result.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/result.js +3 -0
- package/dist/rules/stronglyTypedInjectComponent/result/result.js.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/success.d.ts +6 -0
- package/dist/rules/stronglyTypedInjectComponent/result/success.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/result/success.js +13 -0
- package/dist/rules/stronglyTypedInjectComponent/result/success.js.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/typeValidator.d.ts +16 -0
- package/dist/rules/stronglyTypedInjectComponent/typeValidator.d.ts.map +1 -0
- package/dist/rules/stronglyTypedInjectComponent/typeValidator.js +57 -0
- package/dist/rules/stronglyTypedInjectComponent/typeValidator.js.map +1 -0
- package/dist/rules/unresolvedProviderDependencies/subgraphResolver.js +3 -3
- package/dist/rules/unresolvedProviderDependencies/subgraphResolver.js.map +1 -1
- package/dist/utils/array.d.ts +3 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/array.js.map +1 -0
- package/dist/{ast/utils.d.ts → utils/ast.d.ts} +7 -2
- package/dist/utils/ast.d.ts.map +1 -0
- package/dist/{ast/utils.js → utils/ast.js} +27 -13
- package/dist/utils/ast.js.map +1 -0
- package/dist/utils/regex.d.ts +2 -0
- package/dist/utils/regex.d.ts.map +1 -0
- package/dist/utils/regex.js +10 -0
- package/dist/utils/regex.js.map +1 -0
- package/package.json +2 -1
- package/dist/ast/utils.d.ts.map +0 -1
- package/dist/ast/utils.js.map +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeReference = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const identifier_1 = require("../identifier");
|
|
6
|
+
class TypeReference {
|
|
7
|
+
constructor(node) {
|
|
8
|
+
this.node = node;
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return [new identifier_1.Identifier(this.node.typeName).name];
|
|
12
|
+
}
|
|
13
|
+
isEmpty() {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
equals(types) {
|
|
17
|
+
return (0, lodash_1.isEqual)(this.toString(), types.map((type) => type.toString()).flat());
|
|
18
|
+
}
|
|
19
|
+
includes(type) {
|
|
20
|
+
return type.some((t) => (0, lodash_1.isEqual)(this.toString(), t.toString()));
|
|
21
|
+
}
|
|
22
|
+
size() {
|
|
23
|
+
return 1;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.TypeReference = TypeReference;
|
|
27
|
+
//# sourceMappingURL=typeReference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeReference.js","sourceRoot":"","sources":["../../../src/dto/types/typeReference.ts"],"names":[],"mappings":";;;AACA,mCAAiC;AAEjC,8CAA2C;AAE3C,MAAa,aAAa;IACxB,YAAoB,IAA8B;QAA9B,SAAI,GAAJ,IAAI,CAA0B;IAAI,CAAC;IAEvD,QAAQ;QACN,OAAO,CAAC,IAAI,uBAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,CAAC,KAAa;QAClB,OAAO,IAAA,gBAAO,EAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,gBAAO,EAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,IAAI;QACF,OAAO,CAAC,CAAC;IACX,CAAC;CACF;AAtBD,sCAsBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/types';
|
|
2
|
+
export declare class Variable {
|
|
3
|
+
private node;
|
|
4
|
+
constructor(node: TSESTree.VariableDeclarator);
|
|
5
|
+
get name(): string;
|
|
6
|
+
get isArrowFunction(): boolean;
|
|
7
|
+
get arrowFunction(): TSESTree.ArrowFunctionExpression;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=variable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.d.ts","sourceRoot":"","sources":["../../src/dto/variable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGzD,qBAAa,QAAQ;IACP,OAAO,CAAC,IAAI;gBAAJ,IAAI,EAAE,QAAQ,CAAC,kBAAkB;IAErD,IAAI,IAAI,WAEP;IAED,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,IAAI,aAAa,IAAI,QAAQ,CAAC,uBAAuB,CAGpD;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Variable = void 0;
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
class Variable {
|
|
9
|
+
constructor(node) {
|
|
10
|
+
this.node = node;
|
|
11
|
+
}
|
|
12
|
+
get name() {
|
|
13
|
+
return this.node.id.name;
|
|
14
|
+
}
|
|
15
|
+
get isArrowFunction() {
|
|
16
|
+
var _a;
|
|
17
|
+
return ((_a = this.node.init) === null || _a === void 0 ? void 0 : _a.type) === 'ArrowFunctionExpression';
|
|
18
|
+
}
|
|
19
|
+
get arrowFunction() {
|
|
20
|
+
(0, assert_1.default)(this.isArrowFunction, 'Variable does not represent an arrow function');
|
|
21
|
+
return this.node.init;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Variable = Variable;
|
|
25
|
+
//# sourceMappingURL=variable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable.js","sourceRoot":"","sources":["../../src/dto/variable.ts"],"names":[],"mappings":";;;;;;AACA,oDAA4B;AAE5B,MAAa,QAAQ;IACnB,YAAoB,IAAiC;QAAjC,SAAI,GAAJ,IAAI,CAA6B;IAAG,CAAC;IAEzD,IAAI,IAAI;QACN,OAAQ,IAAI,CAAC,IAAI,CAAC,EAA0B,CAAC,IAAI,CAAC;IACpD,CAAC;IAED,IAAI,eAAe;;QACjB,OAAO,CAAA,MAAA,IAAI,CAAC,IAAI,CAAC,IAAI,0CAAE,IAAI,MAAK,yBAAyB,CAAC;IAC5D,CAAC;IAED,IAAI,aAAa;QACf,IAAA,gBAAM,EAAC,IAAI,CAAC,eAAe,EAAE,+CAA+C,CAAC,CAAC;QAC9E,OAAO,IAAI,CAAC,IAAI,CAAC,IAAwC,CAAC;IAC5D,CAAC;CACF;AAfD,4BAeC"}
|
package/dist/index.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const { unresolvedProviderDependenciesGenerator } = require('./rules/unresolvedProviderDependencies');
|
|
4
4
|
const { noCircularDependenciesGenerator } = require('./rules/noCircularDependency');
|
|
5
|
+
const { stronglyTypedInjectComponentGenerator } = require('./rules/stronglyTypedInjectComponent');
|
|
5
6
|
module.exports = {
|
|
6
7
|
rules: {
|
|
7
8
|
'unresolved-provider-dependencies': unresolvedProviderDependenciesGenerator(),
|
|
8
9
|
'no-circular-dependencies': noCircularDependenciesGenerator(),
|
|
10
|
+
'strongly-typed-inject-component': stronglyTypedInjectComponentGenerator(),
|
|
9
11
|
},
|
|
10
12
|
};
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,MAAM,EAAE,uCAAuC,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACtG,MAAM,EAAE,+BAA+B,EAAE,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,MAAM,EAAE,uCAAuC,EAAE,GAAG,OAAO,CAAC,wCAAwC,CAAC,CAAC;AACtG,MAAM,EAAE,+BAA+B,EAAE,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AACpF,MAAM,EAAE,qCAAqC,EAAE,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC;AAElG,MAAM,CAAC,OAAO,GAAG;IACf,KAAK,EAAE;QACL,kCAAkC,EAAE,uCAAuC,EAAE;QAC7E,0BAA0B,EAAE,+BAA+B,EAAE;QAC7D,iCAAiC,EAAE,qCAAqC,EAAE;KAC3E;CACF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/types';
|
|
2
|
+
import { Context } from '../../dto/context';
|
|
3
|
+
import { CallExpression } from '../../dto/callExpression';
|
|
4
|
+
import type { Options } from '.';
|
|
5
|
+
export declare function create(context: Context, options: Options): {
|
|
6
|
+
CallExpression(node: TSESTree.CallExpression): void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=createRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRule.d.ts","sourceRoot":"","sources":["../../../src/rules/stronglyTypedInjectComponent/createRule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAEjC,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO;yBAOhC,uBAAuB;EAI/C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = void 0;
|
|
4
|
+
const injectComponentHandler_1 = require("./injectComponentHandler");
|
|
5
|
+
const callExpression_1 = require("../../dto/callExpression");
|
|
6
|
+
const errorReporter_1 = require("./result/errorReporter");
|
|
7
|
+
const typeValidator_1 = require("./typeValidator");
|
|
8
|
+
function create(context, options) {
|
|
9
|
+
const injectComponentHandler = new injectComponentHandler_1.InjectComponentHandler(new typeValidator_1.TypeValidator(options), new errorReporter_1.ErrorReporter(context));
|
|
10
|
+
return {
|
|
11
|
+
CallExpression(node) {
|
|
12
|
+
injectComponentHandler.handle(new callExpression_1.CallExpression(node));
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
exports.create = create;
|
|
17
|
+
//# sourceMappingURL=createRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRule.js","sourceRoot":"","sources":["../../../src/rules/stronglyTypedInjectComponent/createRule.ts"],"names":[],"mappings":";;;AAEA,qEAAkE;AAClE,6DAA0D;AAC1D,0DAAuD;AACvD,mDAAgD;AAGhD,SAAgB,MAAM,CAAC,OAAgB,EAAE,OAAgB;IACvD,MAAM,sBAAsB,GAAG,IAAI,+CAAsB,CACvD,IAAI,6BAAa,CAAC,OAAO,CAAC,EAC1B,IAAI,6BAAa,CAAC,OAAO,CAAC,CAC3B,CAAC;IAEF,OAAO;QACL,cAAc,CAAC,IAA6B;YAC1C,sBAAsB,CAAC,MAAM,CAAC,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1D,CAAC;KACF,CAAC;AACJ,CAAC;AAXD,wBAWC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export type Options = readonly [
|
|
3
|
+
{
|
|
4
|
+
injectedPropsPattern: string;
|
|
5
|
+
}
|
|
6
|
+
];
|
|
7
|
+
export declare const stronglyTypedInjectComponentGenerator: () => TSESLint.RuleModule<"strongly-typed-inject-component", Options, TSESLint.RuleListener>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rules/stronglyTypedInjectComponent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAKtE,MAAM,MAAM,OAAO,GAAG,SAAS;IAC7B;QACE,oBAAoB,EAAE,MAAM,CAAC;KAC9B;CACF,CAAC;AAQF,eAAO,MAAM,qCAAqC,8FAiCjD,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stronglyTypedInjectComponentGenerator = void 0;
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const createRule_1 = require("./createRule");
|
|
6
|
+
const context_1 = require("../../dto/context");
|
|
7
|
+
const createRule = utils_1.ESLintUtils.RuleCreator((name) => `https://wix-incubator.github.io/obsidian/docs/documentation/meta/eslint#${name}`);
|
|
8
|
+
const stronglyTypedInjectComponentGenerator = () => {
|
|
9
|
+
return createRule({
|
|
10
|
+
create: (context, options) => {
|
|
11
|
+
return (0, createRule_1.create)(new context_1.Context(context), options);
|
|
12
|
+
},
|
|
13
|
+
name: 'strongly-typed-inject-component',
|
|
14
|
+
meta: {
|
|
15
|
+
docs: {
|
|
16
|
+
description: 'Calling injectComponent without prop types is a bad practice and a common source of bugs.',
|
|
17
|
+
recommended: 'strict',
|
|
18
|
+
},
|
|
19
|
+
messages: {
|
|
20
|
+
'strongly-typed-inject-component': '{{message}}',
|
|
21
|
+
},
|
|
22
|
+
schema: [
|
|
23
|
+
{
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
injectedPropsPattern: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
additionalProperties: false,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
type: 'problem',
|
|
34
|
+
},
|
|
35
|
+
defaultOptions: [
|
|
36
|
+
{
|
|
37
|
+
injectedPropsPattern: '/\\b(Injected|InjectedProps)\\b/',
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.stronglyTypedInjectComponentGenerator = stronglyTypedInjectComponentGenerator;
|
|
43
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/rules/stronglyTypedInjectComponent/index.ts"],"names":[],"mappings":";;;AAAA,oDAAsE;AAEtE,6CAAsC;AACtC,+CAA0C;AAU1C,MAAM,UAAU,GAAG,mBAAW,CAAC,WAAW,CACxC,CAAC,IAAI,EAAE,EAAE,CAAC,2EAA2E,IAAI,EAAE,CAC5F,CAAC;AAEK,MAAM,qCAAqC,GAAG,GAAG,EAAE;IACxD,OAAO,UAAU,CAAC;QAChB,MAAM,EAAE,CAAC,OAAgE,EAAE,OAAgB,EAAE,EAAE;YAC7F,OAAO,IAAA,mBAAM,EAAC,IAAI,iBAAO,CAA6C,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;QAC3F,CAAC;QACD,IAAI,EAAE,iCAAiC;QACvC,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,WAAW,EAAE,2FAA2F;gBACxG,WAAW,EAAE,QAAQ;aACtB;YACD,QAAQ,EAAE;gBACR,iCAAiC,EAAE,aAAa;aACjD;YACD,MAAM,EAAE;gBACN;oBACE,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,oBAAoB,EAAE;4BACpB,IAAI,EAAE,QAAQ;yBACf;qBACF;oBACD,oBAAoB,EAAE,KAAK;iBAC5B;aACF;YACD,IAAI,EAAE,SAAS;SAChB;QACD,cAAc,EAAE;YACd;gBACE,oBAAoB,EAAE,kCAAkC;aACzD;SACF;KACF,CAAgB,CAAC;AACpB,CAAC,CAAC;AAjCW,QAAA,qCAAqC,yCAiChD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CallExpression } from '../../dto/callExpression';
|
|
2
|
+
import type { ErrorReporter } from './result/errorReporter';
|
|
3
|
+
import type { TypeValidator } from './typeValidator';
|
|
4
|
+
export declare class InjectComponentHandler {
|
|
5
|
+
private typeValidator;
|
|
6
|
+
private errorReporter;
|
|
7
|
+
constructor(typeValidator: TypeValidator, errorReporter: ErrorReporter);
|
|
8
|
+
handle(callExpression: CallExpression): void;
|
|
9
|
+
private getInjectedComponent;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=injectComponentHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectComponentHandler.d.ts","sourceRoot":"","sources":["../../../src/rules/stronglyTypedInjectComponent/injectComponentHandler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,qBAAa,sBAAsB;IACrB,OAAO,CAAC,aAAa;IAAiB,OAAO,CAAC,aAAa;gBAAnD,aAAa,EAAE,aAAa,EAAU,aAAa,EAAE,aAAa;IAE/E,MAAM,CAAC,cAAc,EAAE,cAAc;IAQ5C,OAAO,CAAC,oBAAoB;CAM7B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InjectComponentHandler = void 0;
|
|
4
|
+
const ast_1 = require("../../utils/ast");
|
|
5
|
+
const file_1 = require("../../dto/file");
|
|
6
|
+
class InjectComponentHandler {
|
|
7
|
+
constructor(typeValidator, errorReporter) {
|
|
8
|
+
this.typeValidator = typeValidator;
|
|
9
|
+
this.errorReporter = errorReporter;
|
|
10
|
+
}
|
|
11
|
+
handle(callExpression) {
|
|
12
|
+
if (callExpression.isExpression('injectComponent')) {
|
|
13
|
+
const injectedComponent = this.getInjectedComponent(callExpression.node, callExpression.arguments);
|
|
14
|
+
const result = this.typeValidator.validate(injectedComponent, callExpression.generics);
|
|
15
|
+
this.errorReporter.report(result, callExpression.node);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
getInjectedComponent(node, args) {
|
|
19
|
+
return new file_1.File((0, ast_1.requireProgram)(node))
|
|
20
|
+
.variables
|
|
21
|
+
.filter((variable) => variable.isArrowFunction)
|
|
22
|
+
.find((variable) => variable.name === args[0].name);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.InjectComponentHandler = InjectComponentHandler;
|
|
26
|
+
//# sourceMappingURL=injectComponentHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectComponentHandler.js","sourceRoot":"","sources":["../../../src/rules/stronglyTypedInjectComponent/injectComponentHandler.ts"],"names":[],"mappings":";;;AAEA,yCAAiD;AACjD,yCAAsC;AAKtC,MAAa,sBAAsB;IACjC,YAAoB,aAA4B,EAAU,aAA4B;QAAlE,kBAAa,GAAb,aAAa,CAAe;QAAU,kBAAa,GAAb,aAAa,CAAe;IAAI,CAAC;IAEpF,MAAM,CAAC,cAA8B;QAC1C,IAAI,cAAc,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE;YAClD,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,SAAS,CAAC,CAAC;YACnG,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,iBAAiB,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;YACvF,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,IAAI,CAAC,CAAC;SACxD;IACH,CAAC;IAEO,oBAAoB,CAAC,IAA6B,EAAE,IAAkB;QAC5E,OAAO,IAAI,WAAI,CAAC,IAAA,oBAAc,EAAC,IAAI,CAAC,CAAC;aAClC,SAAS;aACT,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC;aAC9C,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;CACF;AAjBD,wDAiBC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/types';
|
|
2
|
+
import type { Context } from '../../../dto/context';
|
|
3
|
+
import type { Result } from './result';
|
|
4
|
+
export declare class ErrorReporter {
|
|
5
|
+
private context;
|
|
6
|
+
constructor(context: Context);
|
|
7
|
+
report(result: Result, node: TSESTree.Node): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=errorReporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorReporter.d.ts","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/errorReporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,aAAa;IACZ,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO;IAE7B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI;CAWlD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorReporter = void 0;
|
|
4
|
+
class ErrorReporter {
|
|
5
|
+
constructor(context) {
|
|
6
|
+
this.context = context;
|
|
7
|
+
}
|
|
8
|
+
report(result, node) {
|
|
9
|
+
if (result.isError) {
|
|
10
|
+
this.context.reportError(node, 'strongly-typed-inject-component', {
|
|
11
|
+
message: result.getMessage(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.ErrorReporter = ErrorReporter;
|
|
17
|
+
//# sourceMappingURL=errorReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorReporter.js","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/errorReporter.ts"],"names":[],"mappings":";;;AAIA,MAAa,aAAa;IACxB,YAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAI,CAAC;IAElC,MAAM,CAAC,MAAc,EAAE,IAAmB;QAC/C,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,IAAI,CAAC,OAAO,CAAC,WAAW,CACtB,IAAI,EACJ,iCAAiC,EACjC;gBACE,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE;aAC7B,CACF,CAAC;SACH;IACH,CAAC;CACF;AAdD,sCAcC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Type } from '../../../dto/types/type';
|
|
2
|
+
import type { Result } from './result';
|
|
3
|
+
export declare class MissingTypeError implements Result {
|
|
4
|
+
private readonly missingTypes;
|
|
5
|
+
readonly isError = true;
|
|
6
|
+
constructor(missingTypes: Type[]);
|
|
7
|
+
getMessage(): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=missingTypeError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missingTypeError.d.ts","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/missingTypeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,gBAAiB,YAAW,MAAM;IAGjC,OAAO,CAAC,QAAQ,CAAC,YAAY;IAFzC,QAAQ,CAAC,OAAO,QAAQ;gBAEK,YAAY,EAAE,IAAI,EAAE;IAEjD,UAAU;CAGX"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingTypeError = void 0;
|
|
4
|
+
class MissingTypeError {
|
|
5
|
+
constructor(missingTypes) {
|
|
6
|
+
this.missingTypes = missingTypes;
|
|
7
|
+
this.isError = true;
|
|
8
|
+
}
|
|
9
|
+
getMessage() {
|
|
10
|
+
return `The call to injectComponent is missing prop types. It should be typed as: injectComponent<${this.missingTypes.map(t => t.toString()).join(', ')}> `;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.MissingTypeError = MissingTypeError;
|
|
14
|
+
//# sourceMappingURL=missingTypeError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missingTypeError.js","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/missingTypeError.ts"],"names":[],"mappings":";;;AAGA,MAAa,gBAAgB;IAG3B,YAA6B,YAAoB;QAApB,iBAAY,GAAZ,YAAY,CAAQ;QAFxC,YAAO,GAAG,IAAI,CAAC;IAE6B,CAAC;IAEtD,UAAU;QACR,OAAO,6FAA6F,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IAC9J,CAAC;CACF;AARD,4CAQC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Type } from '../../../dto/types/type';
|
|
2
|
+
import type { Result } from './result';
|
|
3
|
+
export declare class RedundantTypeError implements Result {
|
|
4
|
+
private readonly redundantType;
|
|
5
|
+
readonly isError = true;
|
|
6
|
+
constructor(redundantType: Type[]);
|
|
7
|
+
getMessage(): string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=redundantTypeError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redundantTypeError.d.ts","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/redundantTypeError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,kBAAmB,YAAW,MAAM;IAGnC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAF1C,QAAQ,CAAC,OAAO,QAAQ;gBAEK,aAAa,EAAE,IAAI,EAAE;IAElD,UAAU;CAGX"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedundantTypeError = void 0;
|
|
4
|
+
const array_1 = require("../../../utils/array");
|
|
5
|
+
class RedundantTypeError {
|
|
6
|
+
constructor(redundantType) {
|
|
7
|
+
this.redundantType = redundantType;
|
|
8
|
+
this.isError = true;
|
|
9
|
+
}
|
|
10
|
+
getMessage() {
|
|
11
|
+
return `injectComponent has one or more redundant types: ${(0, array_1.toString)(this.redundantType)}.`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.RedundantTypeError = RedundantTypeError;
|
|
15
|
+
//# sourceMappingURL=redundantTypeError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redundantTypeError.js","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/redundantTypeError.ts"],"names":[],"mappings":";;;AACA,gDAAgD;AAGhD,MAAa,kBAAkB;IAG7B,YAA6B,aAAqB;QAArB,kBAAa,GAAb,aAAa,CAAQ;QAFzC,YAAO,GAAG,IAAI,CAAC;IAE8B,CAAC;IAEvD,UAAU;QACR,OAAO,oDAAoD,IAAA,gBAAQ,EAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC;IAC7F,CAAC;CACF;AARD,gDAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/result.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,UAAU,EAAE,MAAM,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/result.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"success.d.ts","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/success.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,qBAAa,OAAQ,YAAW,MAAM;IACpC,QAAQ,CAAC,OAAO,SAAS;IAEzB,UAAU,IAAI,MAAM;CAGrB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Success = void 0;
|
|
4
|
+
class Success {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.isError = false;
|
|
7
|
+
}
|
|
8
|
+
getMessage() {
|
|
9
|
+
throw new Error('Success should not have an error message');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.Success = Success;
|
|
13
|
+
//# sourceMappingURL=success.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"success.js","sourceRoot":"","sources":["../../../../src/rules/stronglyTypedInjectComponent/result/success.ts"],"names":[],"mappings":";;;AAEA,MAAa,OAAO;IAApB;QACW,YAAO,GAAG,KAAK,CAAC;IAK3B,CAAC;IAHC,UAAU;QACR,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,CAAC;CACF;AAND,0BAMC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Generics } from '../../dto/generics';
|
|
2
|
+
import type { Variable } from '../../dto/variable';
|
|
3
|
+
import type { Options } from '.';
|
|
4
|
+
import type { Result } from './result/result';
|
|
5
|
+
export declare class TypeValidator {
|
|
6
|
+
private options;
|
|
7
|
+
constructor(options: Options);
|
|
8
|
+
validate(injectedComponent?: Variable, generics?: Generics): Result;
|
|
9
|
+
private areTypesValid;
|
|
10
|
+
private hasInlineType;
|
|
11
|
+
private typesAreEqual;
|
|
12
|
+
private isInjected;
|
|
13
|
+
private typesAreInCorrectOrder;
|
|
14
|
+
private get injectedPattern();
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=typeValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeValidator.d.ts","sourceRoot":"","sources":["../../../src/rules/stronglyTypedInjectComponent/typeValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC;AAIjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAI9C,qBAAa,aAAa;IACZ,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO;IAE7B,QAAQ,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IAO1E,OAAO,CAAC,aAAa;IAkBrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,sBAAsB;IAO9B,OAAO,KAAK,eAAe,GAE1B;CACF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeValidator = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const functionalComponent_1 = require("../../dto/functionalComponent");
|
|
6
|
+
const regex_1 = require("../../utils/regex");
|
|
7
|
+
const typeLiteral_1 = require("../../dto/types/typeLiteral");
|
|
8
|
+
const redundantTypeError_1 = require("./result/redundantTypeError");
|
|
9
|
+
const success_1 = require("./result/success");
|
|
10
|
+
const missingTypeError_1 = require("./result/missingTypeError");
|
|
11
|
+
class TypeValidator {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
validate(injectedComponent, generics) {
|
|
16
|
+
if (!injectedComponent)
|
|
17
|
+
return new success_1.Success();
|
|
18
|
+
const componentProps = new functionalComponent_1.FunctionalComponent(injectedComponent.arrowFunction).props.type;
|
|
19
|
+
const injectComponentGenerics = (generics === null || generics === void 0 ? void 0 : generics.types) || [];
|
|
20
|
+
return this.areTypesValid(componentProps, injectComponentGenerics);
|
|
21
|
+
}
|
|
22
|
+
areTypesValid(componentProps, injectComponentGenerics) {
|
|
23
|
+
if (this.typesAreEqual(componentProps, injectComponentGenerics) && this.isInjected(componentProps)) {
|
|
24
|
+
return new redundantTypeError_1.RedundantTypeError(injectComponentGenerics);
|
|
25
|
+
}
|
|
26
|
+
if (this.hasInlineType(injectComponentGenerics) ||
|
|
27
|
+
(this.typesAreEqual(componentProps, injectComponentGenerics) && !this.isInjected(componentProps)) ||
|
|
28
|
+
((0, lodash_1.isEmpty)(injectComponentGenerics) && this.isInjected(componentProps)) ||
|
|
29
|
+
this.typesAreInCorrectOrder(injectComponentGenerics, componentProps)) {
|
|
30
|
+
return new success_1.Success();
|
|
31
|
+
}
|
|
32
|
+
// TODO: Report the actual missing type
|
|
33
|
+
return new missingTypeError_1.MissingTypeError(injectComponentGenerics);
|
|
34
|
+
}
|
|
35
|
+
hasInlineType(injectComponentGenerics) {
|
|
36
|
+
return injectComponentGenerics.some(typeLiteral_1.TypeLiteral.isTypeLiteral);
|
|
37
|
+
}
|
|
38
|
+
typesAreEqual(componentProps, injectComponentGenerics) {
|
|
39
|
+
return componentProps.equals(injectComponentGenerics);
|
|
40
|
+
}
|
|
41
|
+
isInjected(componentProps) {
|
|
42
|
+
return componentProps.size() === 1 &&
|
|
43
|
+
!!componentProps.toString()[0].match((0, regex_1.stringToRegex)(this.injectedPattern));
|
|
44
|
+
}
|
|
45
|
+
typesAreInCorrectOrder(injectComponentGenerics, componentProps) {
|
|
46
|
+
var _a;
|
|
47
|
+
const isInjectSecond = !!((_a = injectComponentGenerics[1]) === null || _a === void 0 ? void 0 : _a.toString()[0].match((0, regex_1.stringToRegex)(this.injectedPattern)));
|
|
48
|
+
return isInjectSecond &&
|
|
49
|
+
componentProps.size() === injectComponentGenerics.length &&
|
|
50
|
+
componentProps.includes(injectComponentGenerics);
|
|
51
|
+
}
|
|
52
|
+
get injectedPattern() {
|
|
53
|
+
return this.options[0].injectedPropsPattern;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.TypeValidator = TypeValidator;
|
|
57
|
+
//# sourceMappingURL=typeValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typeValidator.js","sourceRoot":"","sources":["../../../src/rules/stronglyTypedInjectComponent/typeValidator.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AACjC,uEAAoE;AAKpE,6CAAkD;AAClD,6DAA0D;AAC1D,oEAAiE;AAEjE,8CAA2C;AAC3C,gEAA6D;AAE7D,MAAa,aAAa;IACxB,YAAoB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;IAAI,CAAC;IAElC,QAAQ,CAAC,iBAA4B,EAAE,QAAmB;QAC/D,IAAI,CAAC,iBAAiB;YAAE,OAAO,IAAI,iBAAO,EAAE,CAAC;QAC7C,MAAM,cAAc,GAAG,IAAI,yCAAmB,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;QAC3F,MAAM,uBAAuB,GAAG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,KAAK,KAAI,EAAE,CAAC;QACtD,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,uBAAuB,CAAC,CAAC;IACrE,CAAC;IAEO,aAAa,CAAC,cAAoB,EAAE,uBAA+B;QACzE,IAAK,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,uBAAuB,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE;YACnG,OAAO,IAAI,uCAAkB,CAAC,uBAAuB,CAAC,CAAC;SACxD;QAED,IACE,IAAI,CAAC,aAAa,CAAC,uBAAuB,CAAC;YAC3C,CAAC,IAAI,CAAC,aAAa,CAAC,cAAc,EAAE,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;YACjG,CAAC,IAAA,gBAAO,EAAC,uBAAuB,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;YACrE,IAAI,CAAC,sBAAsB,CAAC,uBAAuB,EAAE,cAAc,CAAC,EACpE;YACA,OAAO,IAAI,iBAAO,EAAE,CAAC;SACtB;QAED,uCAAuC;QACvC,OAAO,IAAI,mCAAgB,CAAC,uBAAuB,CAAC,CAAC;IACvD,CAAC;IAEO,aAAa,CAAC,uBAA+B;QACnD,OAAO,uBAAuB,CAAC,IAAI,CAAC,yBAAW,CAAC,aAAa,CAAC,CAAC;IACjE,CAAC;IAEO,aAAa,CAAC,cAAoB,EAAE,uBAA+B;QACzE,OAAO,cAAc,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;IACxD,CAAC;IAEO,UAAU,CAAC,cAAoB;QACrC,OAAO,cAAc,CAAC,IAAI,EAAE,KAAK,CAAC;YAChC,CAAC,CAAC,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAA,qBAAa,EAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAC9E,CAAC;IAEO,sBAAsB,CAAC,uBAA+B,EAAE,cAAoB;;QAClF,MAAM,cAAc,GAAG,CAAC,CAAC,CAAA,MAAA,uBAAuB,CAAC,CAAC,CAAC,0CAAE,QAAQ,GAAG,CAAC,EAAE,KAAK,CAAC,IAAA,qBAAa,EAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAA,CAAC;QAC9G,OAAO,cAAc;YACnB,cAAc,CAAC,IAAI,EAAE,KAAK,uBAAuB,CAAC,MAAM;YACxD,cAAc,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;IACrD,CAAC;IAED,IAAY,eAAe;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC;IAC9C,CAAC;CACF;AAnDD,sCAmDC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SubgraphResolver = void 0;
|
|
4
|
-
const
|
|
4
|
+
const ast_1 = require("../../utils/ast");
|
|
5
5
|
const classFile_1 = require("../../dto/classFile");
|
|
6
6
|
const file_1 = require("../../dto/file");
|
|
7
7
|
class SubgraphResolver {
|
|
@@ -50,13 +50,13 @@ class SubgraphResolver {
|
|
|
50
50
|
createLocalGraphClasses({ clazz, imports, path }, localGraphNames) {
|
|
51
51
|
if (localGraphNames.length === 0)
|
|
52
52
|
return [];
|
|
53
|
-
const parent = new file_1.File((0,
|
|
53
|
+
const parent = new file_1.File((0, ast_1.requireProgram)(clazz.node), path);
|
|
54
54
|
return localGraphNames.map((localGraphName) => {
|
|
55
55
|
return new classFile_1.ClassFile(parent.requireGraph(localGraphName), imports, path);
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
58
|
getSubgraphNamesFromDecoratorProperty(subgraphs) {
|
|
59
|
-
return (0,
|
|
59
|
+
return (0, ast_1.mapArrayExpression)(subgraphs.getValue(), (el) => el.name);
|
|
60
60
|
}
|
|
61
61
|
getLocalGraphNames(subgraphs, { imports }) {
|
|
62
62
|
return subgraphs.filter((subgraph) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraphResolver.js","sourceRoot":"","sources":["../../../src/rules/unresolvedProviderDependencies/subgraphResolver.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"subgraphResolver.js","sourceRoot":"","sources":["../../../src/rules/unresolvedProviderDependencies/subgraphResolver.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,WAEpC;AAED,wBAAgB,QAAQ,CAAC,KAAK,GAAE,GAAG,EAAO,UAEzC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toString = exports.isEmpty = void 0;
|
|
4
|
+
function isEmpty(array) {
|
|
5
|
+
return array === undefined || array.length === 0;
|
|
6
|
+
}
|
|
7
|
+
exports.isEmpty = isEmpty;
|
|
8
|
+
function toString(array = []) {
|
|
9
|
+
return `[${array.map((a) => a.toString()).join(', ')}]`;
|
|
10
|
+
}
|
|
11
|
+
exports.toString = toString;
|
|
12
|
+
//# sourceMappingURL=array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":";;;AAAA,SAAgB,OAAO,CAAC,KAAa;IACjC,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;AACrD,CAAC;AAFD,0BAEC;AAED,SAAgB,QAAQ,CAAC,QAAe,EAAE;IACtC,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC5D,CAAC;AAFD,4BAEC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { TSESTree } from '@typescript-eslint/types';
|
|
2
2
|
import type { ArrayExpressionElement } from '../types';
|
|
3
3
|
export declare function isClassLike(node: TSESTree.Node): node is TSESTree.ClassDeclaration;
|
|
4
|
+
export declare function isTypeReference(node?: TSESTree.Node): node is TSESTree.TSTypeReference;
|
|
5
|
+
export declare function isTypeLiteral(node: TSESTree.Node): node is TSESTree.TSTypeLiteral;
|
|
4
6
|
export declare function isImportDeclaration(node: TSESTree.Node): node is TSESTree.ImportDeclaration;
|
|
5
7
|
export declare function isMethodDefinition(node: TSESTree.Node): node is TSESTree.MethodDefinition;
|
|
6
8
|
export declare function getClassDeclaration(node: TSESTree.Node): TSESTree.ClassDeclaration | undefined;
|
|
7
9
|
export declare function requireProgram(node: TSESTree.Node | undefined): TSESTree.Program;
|
|
8
|
-
export declare function isImportLike(node: TSESTree.Node): boolean;
|
|
9
10
|
export declare function getDecoratorProperty(decorator: TSESTree.Decorator, propertyName: string): TSESTree.Property | undefined;
|
|
10
11
|
export declare function mapArrayExpression<T>(array: TSESTree.ArrayExpression, map: (el: ArrayExpressionElement) => T): T[];
|
|
11
|
-
|
|
12
|
+
export declare function isTypeIntersection(node: TSESTree.Node | undefined): node is TSESTree.TSIntersectionType;
|
|
13
|
+
export declare function isTypeAnnotation(node: TSESTree.Node | undefined): node is TSESTree.TSTypeAnnotation;
|
|
14
|
+
export declare function isAnyType(node: TSESTree.Node | undefined): node is TSESTree.TSAnyKeyword;
|
|
15
|
+
export declare function isVariableDeclaration(node: TSESTree.Node): node is TSESTree.VariableDeclaration;
|
|
16
|
+
//# sourceMappingURL=ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/utils/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAGvD,wBAAgB,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAWlF;AAED,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,eAAe,CAEtF;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,aAAa,CAEjF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,iBAAiB,CAE3F;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAEzF;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAC,gBAAgB,GAAG,SAAS,CAW9F;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAAG,QAAQ,CAAC,OAAO,CAQhF;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,iCAMvF;AAUD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,sBAAsB,KAAK,CAAC,OAE5G;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,QAAQ,CAAC,kBAAkB,CAEvG;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,QAAQ,CAAC,gBAAgB,CAEnG;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,SAAS,GAAG,IAAI,IAAI,QAAQ,CAAC,YAAY,CAExF;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,IAAI,QAAQ,CAAC,mBAAmB,CAE/F"}
|