@flint.fyi/plugin-flint 0.2.0 → 0.5.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/lib/index.d.ts +98 -1
- package/lib/index.js +837 -1
- package/lib/plugin.d.ts +93 -0
- package/lib/rules/getStartSourceFile.d.ts +10 -0
- package/lib/rules/invalidCodeLines.d.ts +6 -2
- package/lib/rules/missingPlaceholders.d.ts +10 -0
- package/lib/rules/nodePropertyInChecks.d.ts +10 -0
- package/lib/rules/placeholderFormats.d.ts +10 -0
- package/lib/rules/pluginRuleOrdering.d.ts +10 -0
- package/lib/rules/ruleCreationMethods.d.ts +10 -0
- package/lib/rules/ruleCreator.d.ts +3 -0
- package/lib/rules/testCaseDuplicates.d.ts +6 -2
- package/lib/rules/testCaseNameDuplicates.d.ts +10 -0
- package/lib/rules/testCaseNonStaticCode.d.ts +10 -0
- package/lib/rules/testCaseOnlyFlags.d.ts +10 -0
- package/lib/rules/testShorthands.d.ts +10 -0
- package/lib/rules/unusedMessageIds.d.ts +10 -0
- package/lib/utils/findProperty.d.ts +4 -0
- package/lib/utils/getRuleTesterCaseArrays.d.ts +6 -0
- package/lib/utils/getRuleTesterDescribedCases.d.ts +6 -0
- package/lib/utils/importHelpers.d.ts +5 -0
- package/lib/utils/isTypeFromTS.d.ts +3 -0
- package/lib/utils/messageHelpers.d.ts +12 -0
- package/lib/utils/parseTestCases.d.ts +5 -0
- package/lib/utils/ruleCreatorHelpers.d.ts +5 -0
- package/lib/utils/tsAstToLiteral.d.ts +6 -0
- package/lib/utils/types.d.ts +21 -0
- package/package.json +24 -9
- package/CHANGELOG.md +0 -36
- package/lib/findProperty.d.ts +0 -2
- package/lib/findProperty.js +0 -7
- package/lib/flint.d.ts +0 -9
- package/lib/flint.js +0 -7
- package/lib/getRuleTesterDescribedCases.d.ts +0 -5
- package/lib/getRuleTesterDescribedCases.js +0 -31
- package/lib/parseTestCases.d.ts +0 -4
- package/lib/parseTestCases.js +0 -62
- package/lib/rules/invalidCodeLines.js +0 -71
- package/lib/rules/invalidCodeLines.test.d.ts +0 -1
- package/lib/rules/invalidCodeLines.test.js +0 -197
- package/lib/rules/ruleTester.d.ts +0 -2
- package/lib/rules/ruleTester.js +0 -3
- package/lib/rules/testCaseDuplicates.js +0 -55
- package/lib/rules/testCaseDuplicates.test.d.ts +0 -1
- package/lib/rules/testCaseDuplicates.test.js +0 -173
- package/lib/tsAstToLiteral.d.ts +0 -4
- package/lib/tsAstToLiteral.js +0 -37
- package/lib/types.d.ts +0 -17
- package/lib/types.js +0 -1
- package/src/findProperty.ts +0 -15
- package/src/flint.ts +0 -9
- package/src/getRuleTesterDescribedCases.ts +0 -48
- package/src/index.ts +0 -1
- package/src/parseTestCases.ts +0 -96
- package/src/rules/invalidCodeLines.test.ts +0 -198
- package/src/rules/invalidCodeLines.ts +0 -84
- package/src/rules/ruleTester.ts +0 -4
- package/src/rules/testCaseDuplicates.test.ts +0 -174
- package/src/rules/testCaseDuplicates.ts +0 -63
- package/src/tsAstToLiteral.ts +0 -55
- package/src/types.ts +0 -22
- package/tsconfig.json +0 -14
- package/tsconfig.tsbuildinfo +0 -1
package/lib/plugin.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export declare const flint: import("@flint.fyi/core").Plugin<import("@flint.fyi/core").RuleAbout, string | undefined, [import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Requires passing `sourceFile` to `getStart()` for better performance.";
|
|
3
|
+
readonly id: "getStartSourceFile";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "missingSourceFile", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
9
|
+
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
|
|
10
|
+
readonly id: "invalidCodeLines";
|
|
11
|
+
readonly presets: ["logical"];
|
|
12
|
+
} & {
|
|
13
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
14
|
+
url: string;
|
|
15
|
+
}, object, object, "singleLineTest", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
16
|
+
readonly description: "Reports `context.report()` calls missing data for message placeholders.";
|
|
17
|
+
readonly id: "missingPlaceholders";
|
|
18
|
+
readonly presets: ["logical"];
|
|
19
|
+
} & {
|
|
20
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
21
|
+
url: string;
|
|
22
|
+
}, object, object, "missingPlaceholders", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
23
|
+
readonly description: "Disallows using the `in` operator to check properties on TypeScript nodes.";
|
|
24
|
+
readonly id: "nodePropertyInChecks";
|
|
25
|
+
readonly presets: ["logical"];
|
|
26
|
+
} & {
|
|
27
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
28
|
+
url: string;
|
|
29
|
+
}, object, object, "nodePropertyInChecks", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
30
|
+
readonly description: "Reports and auto-fixes message placeholders that are not formatted as `{{ placeholder }}`.";
|
|
31
|
+
readonly id: "placeholderFormats";
|
|
32
|
+
readonly presets: ["stylistic", "stylisticStrict"];
|
|
33
|
+
} & {
|
|
34
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
35
|
+
url: string;
|
|
36
|
+
}, object, object, "placeholderFormats", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
37
|
+
readonly description: "Reports Flint plugin `rules` arrays that are not sorted alphabetically.";
|
|
38
|
+
readonly id: "pluginRuleOrdering";
|
|
39
|
+
readonly presets: ["stylisticStrict"];
|
|
40
|
+
} & {
|
|
41
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
42
|
+
url: string;
|
|
43
|
+
}, object, object, "pluginRuleOrdering", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
44
|
+
readonly description: "Reports plugin rules created directly with language instead of through RuleCreator.";
|
|
45
|
+
readonly id: "ruleCreationMethods";
|
|
46
|
+
readonly presets: ["logical"];
|
|
47
|
+
} & {
|
|
48
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
49
|
+
url: string;
|
|
50
|
+
}, object, object, "ruleCreationMethods", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
51
|
+
readonly description: "Reports test cases that are identical to previous test cases.";
|
|
52
|
+
readonly id: "testCaseDuplicates";
|
|
53
|
+
readonly presets: ["logical"];
|
|
54
|
+
} & {
|
|
55
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
56
|
+
url: string;
|
|
57
|
+
}, object, object, "duplicateTest", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
58
|
+
readonly description: "Reports test cases that have the same name as a previous test case.";
|
|
59
|
+
readonly id: "testCaseNameDuplicates";
|
|
60
|
+
readonly presets: ["logical"];
|
|
61
|
+
} & {
|
|
62
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
63
|
+
url: string;
|
|
64
|
+
}, object, object, "duplicateTestName", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
65
|
+
readonly description: "Test case code should be a static string literal.";
|
|
66
|
+
readonly id: "testCaseNonStaticCode";
|
|
67
|
+
readonly presets: ["logical"];
|
|
68
|
+
} & {
|
|
69
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
70
|
+
url: string;
|
|
71
|
+
}, object, object, "nonStaticTestCaseCode", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
72
|
+
readonly description: "Reports test cases that are marked `only: true`.";
|
|
73
|
+
readonly id: "testCaseOnlyFlags";
|
|
74
|
+
readonly presets: ["logical"];
|
|
75
|
+
} & {
|
|
76
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
77
|
+
url: string;
|
|
78
|
+
}, object, object, "testCaseOnly", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
79
|
+
readonly description: "Test cases with only a code property can use string shorthand syntax instead of object literal syntax.";
|
|
80
|
+
readonly id: "testShorthands";
|
|
81
|
+
readonly presets: ["logical"];
|
|
82
|
+
} & {
|
|
83
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
84
|
+
url: string;
|
|
85
|
+
}, object, object, "testShorthands", import("@flint.fyi/core").AnyOptionalSchema>, import("@flint.fyi/core").Rule<{
|
|
86
|
+
readonly description: "Reports message IDs defined in the messages object that are never used in recognized report calls.";
|
|
87
|
+
readonly id: "unusedMessageIds";
|
|
88
|
+
readonly presets: ["logical"];
|
|
89
|
+
} & {
|
|
90
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
91
|
+
url: string;
|
|
92
|
+
}, object, object, "unusedMessageIds", import("@flint.fyi/core").AnyOptionalSchema>]>;
|
|
93
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Requires passing `sourceFile` to `getStart()` for better performance.";
|
|
3
|
+
readonly id: "getStartSourceFile";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "missingSourceFile", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=getStartSourceFile.d.ts.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
2
|
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
|
|
3
3
|
readonly id: "invalidCodeLines";
|
|
4
|
-
readonly
|
|
5
|
-
}
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "singleLineTest", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
6
9
|
export default _default;
|
|
10
|
+
//# sourceMappingURL=invalidCodeLines.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports `context.report()` calls missing data for message placeholders.";
|
|
3
|
+
readonly id: "missingPlaceholders";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "missingPlaceholders", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=missingPlaceholders.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Disallows using the `in` operator to check properties on TypeScript nodes.";
|
|
3
|
+
readonly id: "nodePropertyInChecks";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "nodePropertyInChecks", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=nodePropertyInChecks.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports and auto-fixes message placeholders that are not formatted as `{{ placeholder }}`.";
|
|
3
|
+
readonly id: "placeholderFormats";
|
|
4
|
+
readonly presets: ["stylistic", "stylisticStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "placeholderFormats", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=placeholderFormats.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports Flint plugin `rules` arrays that are not sorted alphabetically.";
|
|
3
|
+
readonly id: "pluginRuleOrdering";
|
|
4
|
+
readonly presets: ["stylisticStrict"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "pluginRuleOrdering", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=pluginRuleOrdering.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports plugin rules created directly with language instead of through RuleCreator.";
|
|
3
|
+
readonly id: "ruleCreationMethods";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "ruleCreationMethods", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=ruleCreationMethods.d.ts.map
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
2
|
readonly description: "Reports test cases that are identical to previous test cases.";
|
|
3
3
|
readonly id: "testCaseDuplicates";
|
|
4
|
-
readonly
|
|
5
|
-
}
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "duplicateTest", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
6
9
|
export default _default;
|
|
10
|
+
//# sourceMappingURL=testCaseDuplicates.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports test cases that have the same name as a previous test case.";
|
|
3
|
+
readonly id: "testCaseNameDuplicates";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "duplicateTestName", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=testCaseNameDuplicates.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Test case code should be a static string literal.";
|
|
3
|
+
readonly id: "testCaseNonStaticCode";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "nonStaticTestCaseCode", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=testCaseNonStaticCode.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports test cases that are marked `only: true`.";
|
|
3
|
+
readonly id: "testCaseOnlyFlags";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "testCaseOnly", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=testCaseOnlyFlags.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Test cases with only a code property can use string shorthand syntax instead of object literal syntax.";
|
|
3
|
+
readonly id: "testShorthands";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "testShorthands", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=testShorthands.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: import("@flint.fyi/core").Rule<{
|
|
2
|
+
readonly description: "Reports message IDs defined in the messages object that are never used in recognized report calls.";
|
|
3
|
+
readonly id: "unusedMessageIds";
|
|
4
|
+
readonly presets: ["logical"];
|
|
5
|
+
} & {
|
|
6
|
+
presets?: ("logical" | "logicalStrict" | "stylistic" | "stylisticStrict")[];
|
|
7
|
+
url: string;
|
|
8
|
+
}, object, object, "unusedMessageIds", import("@flint.fyi/core").AnyOptionalSchema>;
|
|
9
|
+
export default _default;
|
|
10
|
+
//# sourceMappingURL=unusedMessageIds.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AST } from "@flint.fyi/typescript-language";
|
|
2
|
+
import type ts from "typescript";
|
|
3
|
+
export declare function findProperty<Node extends AST.Expression>(properties: ts.NodeArray<AST.ObjectLiteralElementLike>, name: string, predicate: (node: AST.Expression) => node is Node): (AST.Expression & Node) | undefined;
|
|
4
|
+
//# sourceMappingURL=findProperty.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AST } from "@flint.fyi/typescript-language";
|
|
2
|
+
export declare function getRuleTesterCaseArrays(node: AST.CallExpression): {
|
|
3
|
+
invalid: AST.ArrayLiteralExpression;
|
|
4
|
+
valid: AST.ArrayLiteralExpression;
|
|
5
|
+
} | undefined;
|
|
6
|
+
//# sourceMappingURL=getRuleTesterCaseArrays.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AST } from "@flint.fyi/typescript-language";
|
|
2
|
+
export declare function getRuleTesterDescribedCases(node: AST.CallExpression): {
|
|
3
|
+
invalid: import("./types.ts").ParsedTestCaseInvalid[];
|
|
4
|
+
valid: import("./types.ts").ParsedTestCase[];
|
|
5
|
+
} | undefined;
|
|
6
|
+
//# sourceMappingURL=getRuleTesterDescribedCases.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AST } from "@flint.fyi/typescript-language";
|
|
2
|
+
import { type Node } from "typescript";
|
|
3
|
+
export declare function isImportedBindingFromModule(declaration: Node, moduleName: string): declaration is AST.ImportSpecifier | AST.NamespaceImport;
|
|
4
|
+
export declare function isImportedSpecifierFromModule(declaration: Node, moduleName: string, importedName: string): declaration is AST.ImportSpecifier;
|
|
5
|
+
//# sourceMappingURL=importHelpers.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AST } from "@flint.fyi/typescript-language";
|
|
2
|
+
interface MessageStringVisitorContext {
|
|
3
|
+
isInArray: boolean;
|
|
4
|
+
messageId: string;
|
|
5
|
+
node: AST.StringLiteral;
|
|
6
|
+
propertyName: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function findMessagesProperty(node: AST.CallExpression): AST.PropertyAssignment | undefined;
|
|
9
|
+
export declare function forEachMessageString(messagesProperty: AST.PropertyAssignment): Generator<MessageStringVisitorContext>;
|
|
10
|
+
export declare function getStringOriginalQuote(node: AST.StringLiteral, sourceFile: AST.SourceFile): string;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=messageHelpers.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AST } from "@flint.fyi/typescript-language";
|
|
2
|
+
import type { ParsedTestCase, ParsedTestCaseInvalid } from "./types.ts";
|
|
3
|
+
export declare function parseTestCase(node: AST.Expression): ParsedTestCase | undefined;
|
|
4
|
+
export declare function parseTestCaseInvalid(node: AST.Expression): ParsedTestCaseInvalid | undefined;
|
|
5
|
+
//# sourceMappingURL=parseTestCases.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AST, Checker } from "@flint.fyi/typescript-language";
|
|
2
|
+
export declare function isLanguageCreateRule(node: AST.CallExpression, typeChecker: Checker): boolean;
|
|
3
|
+
export declare const isRuleCreatorCreateRule: (node: AST.CallExpression, typeChecker: Checker) => boolean;
|
|
4
|
+
export declare const isRuleContextReport: (node: AST.CallExpression, typeChecker: Checker) => boolean;
|
|
5
|
+
//# sourceMappingURL=ruleCreatorHelpers.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AST } from "@flint.fyi/typescript-language";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
export declare function tsAstToLiteral(node: AST.ArrayLiteralExpression): unknown[];
|
|
4
|
+
export declare function tsAstToLiteral(node: AST.ObjectLiteralExpression): object;
|
|
5
|
+
export declare function tsAstToLiteral(node: ts.Node): unknown;
|
|
6
|
+
//# sourceMappingURL=tsAstToLiteral.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InvalidTestCase, TestCase } from "@flint.fyi/rule-tester";
|
|
2
|
+
import type { AST } from "@flint.fyi/typescript-language";
|
|
3
|
+
import type * as ts from "typescript";
|
|
4
|
+
export interface ParsedTestCase extends TestCase {
|
|
5
|
+
nodes: ParsedTestCaseNodes;
|
|
6
|
+
}
|
|
7
|
+
export interface ParsedTestCaseInvalid extends InvalidTestCase {
|
|
8
|
+
nodes: ParsedTestCaseNodesInvalid;
|
|
9
|
+
}
|
|
10
|
+
export interface ParsedTestCaseNodes {
|
|
11
|
+
case: ts.Node;
|
|
12
|
+
code: AST.NoSubstitutionTemplateLiteral | AST.StringLiteral;
|
|
13
|
+
fileName?: AST.NoSubstitutionTemplateLiteral | AST.StringLiteral | undefined;
|
|
14
|
+
files?: AST.ObjectLiteralExpression | undefined;
|
|
15
|
+
name?: AST.NoSubstitutionTemplateLiteral | AST.StringLiteral | undefined;
|
|
16
|
+
options?: AST.ObjectLiteralExpression | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface ParsedTestCaseNodesInvalid extends ParsedTestCaseNodes {
|
|
19
|
+
snapshot: AST.NoSubstitutionTemplateLiteral | AST.StringLiteral;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flint.fyi/plugin-flint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "[Experimental] A Flint plugin for linting Flint plugins.",
|
|
5
|
+
"homepage": "https://www.flint.fyi/rules/flint",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/
|
|
8
|
+
"url": "git+https://github.com/flint-fyi/flint.git",
|
|
8
9
|
"directory": "packages/plugin-flint"
|
|
9
10
|
},
|
|
10
11
|
"license": "MIT",
|
|
@@ -12,19 +13,33 @@
|
|
|
12
13
|
"name": "JoshuaKGoldberg",
|
|
13
14
|
"email": "npm@joshuakgoldberg.com"
|
|
14
15
|
},
|
|
16
|
+
"sideEffects": false,
|
|
15
17
|
"type": "module",
|
|
16
|
-
"
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./lib/index.js"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"lib/",
|
|
23
|
+
"!lib/**/*.map"
|
|
24
|
+
],
|
|
17
25
|
"dependencies": {
|
|
18
|
-
"
|
|
19
|
-
"@flint.fyi/
|
|
20
|
-
"@flint.fyi/
|
|
21
|
-
"@flint.fyi/utils": ""
|
|
26
|
+
"typescript": "^5.9.3 || ^6.0.0",
|
|
27
|
+
"@flint.fyi/typescript-language": "^0.18.0",
|
|
28
|
+
"@flint.fyi/core": "^0.21.0",
|
|
29
|
+
"@flint.fyi/utils": "^0.14.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"tsdown": "0.21.0",
|
|
33
|
+
"vitest": "4.1.0",
|
|
34
|
+
"@flint.fyi/rule-tester": "^0.16.1"
|
|
22
35
|
},
|
|
23
36
|
"engines": {
|
|
24
37
|
"node": ">=24.0.0"
|
|
25
38
|
},
|
|
26
39
|
"publishConfig": {
|
|
27
|
-
"access": "public"
|
|
28
|
-
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"test": "vitest --project plugin-flint"
|
|
29
44
|
}
|
|
30
45
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# @flint.fyi/plugin-flint
|
|
2
|
-
|
|
3
|
-
## 0.2.0
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 950e84c: feat(rule-tester): [invalidCodeLines] add rule
|
|
8
|
-
|
|
9
|
-
## 0.1.0
|
|
10
|
-
|
|
11
|
-
### Minor Changes
|
|
12
|
-
|
|
13
|
-
- d89c480: feat(comparisons): add eslint-plugin-eslint-plugin comparisons
|
|
14
|
-
|
|
15
|
-
### Patch Changes
|
|
16
|
-
|
|
17
|
-
- Updated dependencies [738fe36]
|
|
18
|
-
- @flint.fyi/rule-tester@0.14.3
|
|
19
|
-
|
|
20
|
-
## 0.0.2
|
|
21
|
-
|
|
22
|
-
### Patch Changes
|
|
23
|
-
|
|
24
|
-
- 0b80834: allow rules to indicate dependencies
|
|
25
|
-
- 63b61e5: add --suggestions to CLI
|
|
26
|
-
- Updated dependencies [0b80834]
|
|
27
|
-
- Updated dependencies [63b61e5]
|
|
28
|
-
- @flint.fyi/core@0.13.5
|
|
29
|
-
- @flint.fyi/ts@0.13.2
|
|
30
|
-
- @flint.fyi/utils@0.13.2
|
|
31
|
-
|
|
32
|
-
## 0.0.1
|
|
33
|
-
|
|
34
|
-
### Patch Changes
|
|
35
|
-
|
|
36
|
-
- 83a4361: initial functionality
|
package/lib/findProperty.d.ts
DELETED
package/lib/findProperty.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
|
-
export function findProperty(properties, name, predicate) {
|
|
3
|
-
return properties.find((property) => ts.isPropertyAssignment(property) &&
|
|
4
|
-
ts.isIdentifier(property.name) &&
|
|
5
|
-
property.name.text === name &&
|
|
6
|
-
predicate(property.initializer))?.initializer;
|
|
7
|
-
}
|
package/lib/flint.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare const flint: import("@flint.fyi/core").Plugin<import("@flint.fyi/core").RuleAbout, string | undefined, [import("@flint.fyi/core").Rule<{
|
|
2
|
-
readonly description: "Reports cases for invalid code that isn't formatted across lines.";
|
|
3
|
-
readonly id: "invalidCodeLines";
|
|
4
|
-
readonly preset: "logical";
|
|
5
|
-
}, import("@flint.fyi/ts/lib/nodes.js").TSNodesByName, import("@flint.fyi/ts").TypeScriptServices, "singleLineTest", undefined>, import("@flint.fyi/core").Rule<{
|
|
6
|
-
readonly description: "Reports test cases that are identical to previous test cases.";
|
|
7
|
-
readonly id: "testCaseDuplicates";
|
|
8
|
-
readonly preset: "logical";
|
|
9
|
-
}, import("@flint.fyi/ts/lib/nodes.js").TSNodesByName, import("@flint.fyi/ts").TypeScriptServices, "duplicateTest", undefined>]>;
|
package/lib/flint.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createPlugin } from "@flint.fyi/core";
|
|
2
|
-
import invalidCodeLines from "./rules/invalidCodeLines.js";
|
|
3
|
-
import testCaseDuplicates from "./rules/testCaseDuplicates.js";
|
|
4
|
-
export const flint = createPlugin({
|
|
5
|
-
name: "flint",
|
|
6
|
-
rules: [invalidCodeLines, testCaseDuplicates],
|
|
7
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { isTruthy } from "@flint.fyi/utils";
|
|
2
|
-
import * as ts from "typescript";
|
|
3
|
-
import { findProperty } from "./findProperty.js";
|
|
4
|
-
import { parseTestCase, parseTestCaseInvalid } from "./parseTestCases.js";
|
|
5
|
-
export function getRuleTesterDescribedCases(node) {
|
|
6
|
-
if (!ts.isPropertyAccessExpression(node.expression) ||
|
|
7
|
-
!ts.isIdentifier(node.expression.expression) ||
|
|
8
|
-
!ts.isIdentifier(node.expression.name) ||
|
|
9
|
-
node.expression.name.text !== "describe" ||
|
|
10
|
-
node.arguments.length !== 2) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
// TODO: Check node.expression.expression's type for being a RuleTester
|
|
14
|
-
// https://github.com/JoshuaKGoldberg/flint/issues/152
|
|
15
|
-
const argument = node.arguments[1];
|
|
16
|
-
if (!ts.isObjectLiteralExpression(argument)) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const invalid = findProperty(argument.properties, "invalid", ts.isArrayLiteralExpression);
|
|
20
|
-
if (!invalid) {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
const valid = findProperty(argument.properties, "valid", ts.isArrayLiteralExpression);
|
|
24
|
-
if (!valid) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
invalid: invalid.elements.map(parseTestCaseInvalid).filter(isTruthy),
|
|
29
|
-
valid: valid.elements.map(parseTestCase).filter(isTruthy),
|
|
30
|
-
};
|
|
31
|
-
}
|
package/lib/parseTestCases.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
|
-
import type { ParsedTestCase, ParsedTestCaseInvalid } from "./types.js";
|
|
3
|
-
export declare function parseTestCase(node: ts.Expression): ParsedTestCase | undefined;
|
|
4
|
-
export declare function parseTestCaseInvalid(node: ts.Expression): ParsedTestCaseInvalid | undefined;
|
package/lib/parseTestCases.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
|
-
import { findProperty } from "./findProperty.js";
|
|
3
|
-
import { tsAstToLiteral } from "./tsAstToLiteral.js";
|
|
4
|
-
export function parseTestCase(node) {
|
|
5
|
-
if (ts.isStringLiteralLike(node)) {
|
|
6
|
-
return {
|
|
7
|
-
code: node.text,
|
|
8
|
-
nodes: {
|
|
9
|
-
case: node,
|
|
10
|
-
code: node,
|
|
11
|
-
},
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
if (!ts.isObjectLiteralExpression(node)) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
const code = findProperty(node.properties, "code", ts.isStringLiteralLike);
|
|
18
|
-
if (!code) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
const fileName = findProperty(node.properties, "fileName", ts.isStringLiteralLike);
|
|
22
|
-
const options = findProperty(node.properties, "options", ts.isObjectLiteralExpression);
|
|
23
|
-
return {
|
|
24
|
-
code: code.text,
|
|
25
|
-
fileName: fileName?.text,
|
|
26
|
-
nodes: {
|
|
27
|
-
case: node,
|
|
28
|
-
code,
|
|
29
|
-
fileName,
|
|
30
|
-
options,
|
|
31
|
-
},
|
|
32
|
-
options: options && tsAstToLiteral(options),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export function parseTestCaseInvalid(node) {
|
|
36
|
-
if (!ts.isObjectLiteralExpression(node)) {
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
39
|
-
const code = findProperty(node.properties, "code", ts.isStringLiteralLike);
|
|
40
|
-
if (!code) {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
const fileName = findProperty(node.properties, "fileName", ts.isStringLiteralLike);
|
|
44
|
-
const options = findProperty(node.properties, "options", ts.isObjectLiteralExpression);
|
|
45
|
-
const snapshot = findProperty(node.properties, "snapshot", ts.isStringLiteralLike);
|
|
46
|
-
if (!snapshot) {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
code: code.text,
|
|
51
|
-
fileName: fileName?.text,
|
|
52
|
-
nodes: {
|
|
53
|
-
case: node,
|
|
54
|
-
code,
|
|
55
|
-
fileName,
|
|
56
|
-
options,
|
|
57
|
-
snapshot,
|
|
58
|
-
},
|
|
59
|
-
options: options && tsAstToLiteral(options),
|
|
60
|
-
snapshot: snapshot.text,
|
|
61
|
-
};
|
|
62
|
-
}
|