use crate::languages::spec::{
DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec,
};
static JS_VENDORED_DIRS: &[&str] = &["node_modules", ".next", ".nuxt"];
pub static ESLINT: ToolSpec = ToolSpec {
name: "eslint",
command: &["eslint", "--format", "json"],
local_paths: &["node_modules/.bin/eslint"],
config_files: &[
"eslint.config.js",
"eslint.config.mjs",
"eslint.config.cjs",
".eslintrc",
".eslintrc.js",
".eslintrc.cjs",
".eslintrc.json",
".eslintrc.yml",
".eslintrc.yaml",
],
config_flag: None,
output_format: OutputFormat::Json,
diagnostics_stream: DiagnosticsStream::Stdout,
timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
timeout_context: None,
establishes_compilation: false,
serial_in_repository: false,
accepts_files: true,
};
pub static TSC: ToolSpec = ToolSpec {
name: "tsc",
command: &["tsc", "--noEmit", "--pretty", "false"],
local_paths: &["node_modules/.bin/tsc"],
config_files: &["tsconfig.json"],
config_flag: None,
output_format: OutputFormat::Tsc,
diagnostics_stream: DiagnosticsStream::Stdout,
timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
timeout_context: None,
establishes_compilation: true,
serial_in_repository: false,
accepts_files: false,
};
pub static JAVASCRIPT: LanguageSupport = LanguageSupport {
name: "javascript",
display_name: "JavaScript",
extensions: &[".js", ".jsx", ".mjs", ".cjs"],
filenames: &[],
filename_prefixes: &[],
tools: &[&ESLINT],
conventions: &[
"Unhandled promise rejections and missing await",
"Sequential awaits in a loop where the work is independent",
"var versus let/const, and accidental global scope",
"Equality coercion (== versus ===)",
],
vendored_dirs: JS_VENDORED_DIRS,
};
pub static TYPESCRIPT: LanguageSupport = LanguageSupport {
name: "typescript",
display_name: "TypeScript",
extensions: &[".ts", ".tsx", ".mts", ".cts"],
filenames: &[],
filename_prefixes: &[],
tools: &[&ESLINT, &TSC],
conventions: &[
"`any` where a real type is available, and unsafe casts",
"Unhandled promise rejections and missing await",
"Non-null assertions (!) that hide a genuine null case",
"Sequential awaits in a loop where the work is independent",
],
vendored_dirs: JS_VENDORED_DIRS,
};
pub static VUE: LanguageSupport = LanguageSupport {
name: "vue",
display_name: "Vue",
extensions: &[".vue"],
filenames: &[],
filename_prefixes: &[],
tools: &[&ESLINT],
conventions: &[
"Reactive state mutated from outside the component that owns it",
"v-for without a stable key, and keys that identify the wrong row",
"Watchers whose side effects retrigger themselves",
"Props mutated directly instead of emitted as events",
"Computed properties hiding side effects",
],
vendored_dirs: JS_VENDORED_DIRS,
};
pub static SVELTE: LanguageSupport = LanguageSupport {
name: "svelte",
display_name: "Svelte",
extensions: &[".svelte"],
filenames: &[],
filename_prefixes: &[],
tools: &[&ESLINT],
conventions: &[
"Reactive statements with dependencies they do not declare",
"Stores subscribed but never unsubscribed on destroy",
"State mutated from outside the component tree",
"Derived values recomputed on unrelated changes",
],
vendored_dirs: JS_VENDORED_DIRS,
};
pub(crate) static FAMILY: &[&LanguageSupport] = &[&JAVASCRIPT, &TYPESCRIPT, &VUE, &SVELTE];