catlint 1.2.1 → 1.3.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.
@@ -27893,4 +27893,4 @@ var program = new import_commander.Command();
27893
27893
  program.name("catlint").description("A linter for detecting code bad practices").version("0.0.1");
27894
27894
  program.command("init").description("Inits CatLint in your current project folder").action(async () => await init());
27895
27895
  program.command("lint").description("Lints the current project").action(async () => await lint());
27896
- program.parse();
27896
+ program.parse(process.argv);
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,80 @@
1
+ declare enum IRKind {
2
+ Codeline = 0,
3
+ Literal = 1,
4
+ Function = 2,
5
+ Class = 3,
6
+ Variable = 4
7
+ }
8
+ interface IRNode {
9
+ line: number;
10
+ kind: IRKind;
11
+ name: string;
12
+ value: IRNode[];
13
+ }
14
+
15
+ interface IRFile {
16
+ name: string;
17
+ extensions: string[];
18
+ program: IRNode[];
19
+ }
20
+
21
+ type IRParser = (filename: string, content: string) => IRFile;
22
+
23
+ declare enum Level {
24
+ Error = "ERROR",
25
+ Warning = "WARNING",
26
+ Info = "INFO"
27
+ }
28
+ interface Message {
29
+ message: string;
30
+ line: number;
31
+ level: Level;
32
+ }
33
+
34
+ type RuleFn = (file: IRFile) => Message[];
35
+ interface Rule {
36
+ name: string;
37
+ fn?: RuleFn;
38
+ subrules?: Rule[];
39
+ }
40
+ interface AdaptedRule extends Rule {
41
+ fn: RuleFn;
42
+ subrules: AdaptedRule[];
43
+ }
44
+
45
+ interface Config {
46
+ lint: {
47
+ includes: string[];
48
+ excludes: string[];
49
+ };
50
+ parsers: {
51
+ pattern: string;
52
+ parser: IRParser;
53
+ }[];
54
+ rules: Rule[];
55
+ }
56
+ interface NormalizedConfig extends Config {
57
+ rules: AdaptedRule[];
58
+ }
59
+ declare const defaultConfig: NormalizedConfig;
60
+
61
+ declare function defineConfig(config: Config): NormalizedConfig;
62
+
63
+ declare const loadConfigFromFile: (filePath: string) => Promise<NormalizedConfig | null>;
64
+ declare const loadConfig: (projectPath: string) => Promise<NormalizedConfig>;
65
+
66
+ type LintResult = {
67
+ name: string;
68
+ messages: Message[];
69
+ subrules: LintResult[];
70
+ isCorrect: boolean;
71
+ };
72
+
73
+ declare function travelFile(file: IRFile): (rule: AdaptedRule) => LintResult;
74
+ declare function lintFile(file: IRFile, rules: AdaptedRule[]): LintResult[];
75
+
76
+ declare const lintProject: (config: NormalizedConfig, projectDir: string) => Promise<LintResult[][]>;
77
+
78
+ declare const createRule: (name: string, fn: (subrule: (subrule: Rule) => void) => RuleFn) => Rule;
79
+
80
+ export { type AdaptedRule, type Config, type IRFile, IRKind, type IRNode, type IRParser, Level, type LintResult, type Message, type NormalizedConfig, type Rule, type RuleFn, createRule, defaultConfig, defineConfig, lintFile, lintProject, loadConfig, loadConfigFromFile, travelFile };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "catlint",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
package/src/cli/index.ts CHANGED
@@ -17,4 +17,4 @@ program
17
17
  .description('Lints the current project')
18
18
  .action(async () => await lint());
19
19
 
20
- program.parse();
20
+ program.parse(process.argv);
package/tsup.config.ts CHANGED
@@ -2,7 +2,7 @@ import { defineConfig } from 'tsup';
2
2
 
3
3
  export default defineConfig({
4
4
  entry: ['src/index.ts', 'src/cli/index.ts'],
5
- format: ['esm', 'cjs'],
5
+ format: ['cjs'],
6
6
  dts: true,
7
7
  clean: true,
8
8
  esbuildOptions(options) {