drep/languages/definitions/
javascript.rs1use crate::languages::spec::{
9 DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec,
10};
11
12static JS_VENDORED_DIRS: &[&str] = &["node_modules", ".next", ".nuxt"];
17
18pub static ESLINT: ToolSpec = ToolSpec {
20 name: "eslint",
21 command: &["eslint", "--format", "json"],
22 local_paths: &["node_modules/.bin/eslint"],
23 config_files: &[
24 "eslint.config.js",
25 "eslint.config.mjs",
26 "eslint.config.cjs",
27 ".eslintrc",
28 ".eslintrc.js",
29 ".eslintrc.cjs",
30 ".eslintrc.json",
31 ".eslintrc.yml",
32 ".eslintrc.yaml",
33 ],
34 config_flag: None,
35 output_format: OutputFormat::Json,
36 diagnostics_stream: DiagnosticsStream::Stdout,
37 timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
38 timeout_context: None,
39 establishes_compilation: false,
40 serial_in_repository: false,
41 accepts_files: true,
42};
43
44pub static TSC: ToolSpec = ToolSpec {
46 name: "tsc",
47 command: &["tsc", "--noEmit", "--pretty", "false"],
48 local_paths: &["node_modules/.bin/tsc"],
49 config_files: &["tsconfig.json"],
50 config_flag: None,
51 output_format: OutputFormat::Tsc,
52 diagnostics_stream: DiagnosticsStream::Stdout,
53 timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
54 timeout_context: None,
55 establishes_compilation: true,
56 serial_in_repository: false,
57 accepts_files: false,
60};
61
62pub static JAVASCRIPT: LanguageSupport = LanguageSupport {
64 name: "javascript",
65 display_name: "JavaScript",
66 extensions: &[".js", ".jsx", ".mjs", ".cjs"],
67 filenames: &[],
68 filename_prefixes: &[],
69 tools: &[&ESLINT],
70 conventions: &[
71 "Unhandled promise rejections and missing await",
72 "Sequential awaits in a loop where the work is independent",
73 "var versus let/const, and accidental global scope",
74 "Equality coercion (== versus ===)",
75 ],
76 vendored_dirs: JS_VENDORED_DIRS,
77};
78
79pub static TYPESCRIPT: LanguageSupport = LanguageSupport {
81 name: "typescript",
82 display_name: "TypeScript",
83 extensions: &[".ts", ".tsx", ".mts", ".cts"],
84 filenames: &[],
85 filename_prefixes: &[],
86 tools: &[&ESLINT, &TSC],
87 conventions: &[
88 "`any` where a real type is available, and unsafe casts",
89 "Unhandled promise rejections and missing await",
90 "Non-null assertions (!) that hide a genuine null case",
91 "Sequential awaits in a loop where the work is independent",
92 ],
93 vendored_dirs: JS_VENDORED_DIRS,
94};
95
96pub static VUE: LanguageSupport = LanguageSupport {
105 name: "vue",
106 display_name: "Vue",
107 extensions: &[".vue"],
108 filenames: &[],
109 filename_prefixes: &[],
110 tools: &[&ESLINT],
111 conventions: &[
112 "Reactive state mutated from outside the component that owns it",
113 "v-for without a stable key, and keys that identify the wrong row",
114 "Watchers whose side effects retrigger themselves",
115 "Props mutated directly instead of emitted as events",
116 "Computed properties hiding side effects",
117 ],
118 vendored_dirs: JS_VENDORED_DIRS,
119};
120
121pub static SVELTE: LanguageSupport = LanguageSupport {
128 name: "svelte",
129 display_name: "Svelte",
130 extensions: &[".svelte"],
131 filenames: &[],
132 filename_prefixes: &[],
133 tools: &[&ESLINT],
134 conventions: &[
135 "Reactive statements with dependencies they do not declare",
136 "Stores subscribed but never unsubscribed on destroy",
137 "State mutated from outside the component tree",
138 "Derived values recomputed on unrelated changes",
139 ],
140 vendored_dirs: JS_VENDORED_DIRS,
141};
142
143pub(crate) static FAMILY: &[&LanguageSupport] = &[&JAVASCRIPT, &TYPESCRIPT, &VUE, &SVELTE];