hana-linter 0.1.1
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/.github/workflows/npm-publish.yml +29 -0
- package/.prettierrc +7 -0
- package/CHANGELOG.md +14 -0
- package/README.md +286 -0
- package/dist/cli.js +104 -0
- package/dist/config.js +227 -0
- package/dist/content-lint.js +151 -0
- package/dist/files.js +73 -0
- package/dist/index.js +31 -0
- package/dist/lint.js +195 -0
- package/dist/report.js +28 -0
- package/dist/types/cli.js +2 -0
- package/dist/types/config.js +2 -0
- package/dist/types/issues.js +2 -0
- package/dist/types/rules.js +2 -0
- package/package.json +28 -0
- package/src/assets/.hana-linter.json +224 -0
- package/src/cli.ts +113 -0
- package/src/config.ts +305 -0
- package/src/content-lint.ts +187 -0
- package/src/files.ts +84 -0
- package/src/index.ts +37 -0
- package/src/lint.ts +222 -0
- package/src/report.ts +29 -0
- package/src/types/cli.ts +21 -0
- package/src/types/config.ts +20 -0
- package/src/types/issues.ts +9 -0
- package/src/types/rules.ts +140 -0
- package/tsconfig.json +45 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export type JsonRuleDefinition = {
|
|
2
|
+
/**
|
|
3
|
+
* Human-readable rule label.
|
|
4
|
+
*/
|
|
5
|
+
readonly description: string;
|
|
6
|
+
/**
|
|
7
|
+
* Regex source string (without leading/trailing slashes).
|
|
8
|
+
*/
|
|
9
|
+
readonly pattern: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional regex flags, e.g. "i", "u", "iu".
|
|
12
|
+
*/
|
|
13
|
+
readonly flags?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type JsonRuleGroup = {
|
|
17
|
+
/**
|
|
18
|
+
* Rules that must all pass.
|
|
19
|
+
*/
|
|
20
|
+
readonly all?: readonly JsonRuleDefinition[];
|
|
21
|
+
/**
|
|
22
|
+
* Rules where at least one must pass.
|
|
23
|
+
*/
|
|
24
|
+
readonly any?: readonly JsonRuleDefinition[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type JsonExtensionRuleSet = {
|
|
28
|
+
/**
|
|
29
|
+
* File extension this rule set applies to.
|
|
30
|
+
* Example: ".hdbtable". Use "*" to apply rules to all extensions.
|
|
31
|
+
*/
|
|
32
|
+
readonly extension: string;
|
|
33
|
+
/**
|
|
34
|
+
* Optional folder name that files must be located in (at any depth under rootDir).
|
|
35
|
+
*/
|
|
36
|
+
readonly folderName?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Grouped rule logic for this extension.
|
|
39
|
+
*/
|
|
40
|
+
readonly groups: JsonRuleGroup;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export type ContentTarget = 'field' | 'inputParameter' | 'outputParameter';
|
|
44
|
+
|
|
45
|
+
export type JsonContentRuleSet = {
|
|
46
|
+
/**
|
|
47
|
+
* File extension this content rule set applies to.
|
|
48
|
+
* Example: ".hdbtable". Use "*" to apply rules to all extensions.
|
|
49
|
+
*/
|
|
50
|
+
readonly extension: string;
|
|
51
|
+
/**
|
|
52
|
+
* Extracted identifier type to validate.
|
|
53
|
+
*/
|
|
54
|
+
readonly target: ContentTarget;
|
|
55
|
+
/**
|
|
56
|
+
* Grouped rule logic for this content target.
|
|
57
|
+
*/
|
|
58
|
+
readonly groups: JsonRuleGroup;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type JsonLintConfig = {
|
|
62
|
+
/**
|
|
63
|
+
* Base folder to scan in full-scan mode, usually "db/src".
|
|
64
|
+
*/
|
|
65
|
+
readonly rootDir: string;
|
|
66
|
+
/**
|
|
67
|
+
* Directory names to skip during recursive traversal.
|
|
68
|
+
*/
|
|
69
|
+
readonly ignoredDirectories: readonly string[];
|
|
70
|
+
/**
|
|
71
|
+
* Rule sets grouped by extension.
|
|
72
|
+
*/
|
|
73
|
+
readonly extensionRuleSets: readonly JsonExtensionRuleSet[];
|
|
74
|
+
/**
|
|
75
|
+
* Optional content-based rule sets (fields/parameters inside files).
|
|
76
|
+
*/
|
|
77
|
+
readonly contentRuleSets?: readonly JsonContentRuleSet[];
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export type RuleDefinition = {
|
|
81
|
+
/**
|
|
82
|
+
* Human-readable rule label.
|
|
83
|
+
*/
|
|
84
|
+
readonly description: string;
|
|
85
|
+
/**
|
|
86
|
+
* Compiled regex pattern.
|
|
87
|
+
*/
|
|
88
|
+
readonly pattern: RegExp;
|
|
89
|
+
/**
|
|
90
|
+
* Original regex source from config.
|
|
91
|
+
*/
|
|
92
|
+
readonly source: string;
|
|
93
|
+
/**
|
|
94
|
+
* Original regex flags from config.
|
|
95
|
+
*/
|
|
96
|
+
readonly flags: string;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type RuleGroup = {
|
|
100
|
+
/**
|
|
101
|
+
* Rules that must all pass.
|
|
102
|
+
*/
|
|
103
|
+
readonly all?: readonly RuleDefinition[];
|
|
104
|
+
/**
|
|
105
|
+
* Rules where at least one must pass.
|
|
106
|
+
*/
|
|
107
|
+
readonly any?: readonly RuleDefinition[];
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export type ExtensionRuleSet = {
|
|
111
|
+
/**
|
|
112
|
+
* File extension this rule set applies to.
|
|
113
|
+
* "*" means rules apply to all extensions.
|
|
114
|
+
*/
|
|
115
|
+
readonly extension: string;
|
|
116
|
+
/**
|
|
117
|
+
* Optional folder name that files must be located in (at any depth under rootDir).
|
|
118
|
+
*/
|
|
119
|
+
readonly folderName?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Grouped rule logic for this extension.
|
|
122
|
+
*/
|
|
123
|
+
readonly groups: RuleGroup;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type ContentRuleSet = {
|
|
127
|
+
/**
|
|
128
|
+
* File extension this content rule set applies to.
|
|
129
|
+
* "*" means rules apply to all extensions.
|
|
130
|
+
*/
|
|
131
|
+
readonly extension: string;
|
|
132
|
+
/**
|
|
133
|
+
* Extracted identifier type to validate.
|
|
134
|
+
*/
|
|
135
|
+
readonly target: ContentTarget;
|
|
136
|
+
/**
|
|
137
|
+
* Grouped rule logic for this content target.
|
|
138
|
+
*/
|
|
139
|
+
readonly groups: RuleGroup;
|
|
140
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "commonjs",
|
|
11
|
+
"target": "es2022",
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
// "types": [],
|
|
14
|
+
// For nodejs:
|
|
15
|
+
// "lib": ["esnext"],
|
|
16
|
+
"types": ["node"],
|
|
17
|
+
// and npm install -D @types/node
|
|
18
|
+
|
|
19
|
+
// Other Outputs
|
|
20
|
+
// "sourceMap": true,
|
|
21
|
+
// "declaration": true,
|
|
22
|
+
// "declarationMap": true,
|
|
23
|
+
|
|
24
|
+
// Stricter Typechecking Options
|
|
25
|
+
"noUncheckedIndexedAccess": true,
|
|
26
|
+
"exactOptionalPropertyTypes": false,
|
|
27
|
+
|
|
28
|
+
// Style Options
|
|
29
|
+
// "noImplicitReturns": true,
|
|
30
|
+
// "noImplicitOverride": true,
|
|
31
|
+
// "noUnusedLocals": true,
|
|
32
|
+
// "noUnusedParameters": true,
|
|
33
|
+
// "noFallthroughCasesInSwitch": true,
|
|
34
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
35
|
+
|
|
36
|
+
// Recommended Options
|
|
37
|
+
"strict": true,
|
|
38
|
+
// "jsx": "react-jsx",
|
|
39
|
+
// "verbatimModuleSyntax": true,
|
|
40
|
+
// "isolatedModules": true,
|
|
41
|
+
// "noUncheckedSideEffectImports": true,
|
|
42
|
+
"moduleDetection": "auto",
|
|
43
|
+
"skipLibCheck": true,
|
|
44
|
+
}
|
|
45
|
+
}
|