-
Notifications
You must be signed in to change notification settings - Fork 3.8k
feat: add eslint; more lint more better #4618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: 2 | ||
# log-file: ./efm.log.txt | ||
# log-level: 10 | ||
lint-debounce: 1s | ||
|
||
tools: | ||
eslint-lint: &eslint-lint | ||
lint-command: 'eslint_d --format unix --stdin --stdin-filename "${INPUT}"' | ||
lint-stdin: true | ||
lint-ignore-exit-code: true | ||
lint-formats: | ||
- '%f:%l:%c: %m [%trror]' | ||
- '%f:%l:%c: %m [%tarning]' | ||
root-markers: | ||
- 'eslint.config.ts' | ||
|
||
languages: | ||
javascript: | ||
- !!merge <<: *eslint-lint | ||
javascriptreact: | ||
- !!merge <<: *eslint-lint | ||
typescript: | ||
- !!merge <<: *eslint-lint | ||
typescriptreact: | ||
- !!merge <<: *eslint-lint | ||
svelte: | ||
- !!merge <<: *eslint-lint |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,10 @@ command = "nixd" | |
expr = "import (builtins.getFlake (builtins.toString ./.)).inputs.nixpkgs { }" | ||
|
||
[language-server.astro-ls] | ||
args = ["--stdio"] | ||
command = "astro-ls" | ||
config = { "typescript" = { "tsdk" = "./site/node_modules/typescript/lib" }, "environment" = "node" } | ||
args = ["--stdio"] | ||
command = "astro-ls" | ||
config = { "typescript" = { "tsdk" = "./site/node_modules/typescript/lib" }, "environment" = "node" } | ||
language-servers = ["eslint"] | ||
|
||
[language-server.biome] | ||
args = ["lsp-proxy"] | ||
|
@@ -35,6 +36,10 @@ config.provideFormatter = true | |
args = ["--stdio"] | ||
command = "vscode-html-language-server" | ||
|
||
[language-server.efm-langserver] | ||
args = ["-c", "../.efm.config.yaml"] | ||
command = "efm-langserver" | ||
|
||
[[language]] | ||
auto-format = true | ||
language-servers = [{ name = "vscode-solidity-server" }] | ||
|
@@ -73,44 +78,58 @@ roots = [".git", "tailwind.config.js", "tailwind.config.cjs", "tailwi | |
scope = "source.html" | ||
|
||
[[language]] | ||
auto-format = true | ||
formatter = { command = "treefmt", args = ["--stdin", ".js"] } | ||
language-servers = [{ name = "typescript-language-server", except-features = ["format"] }] | ||
name = "javascript" | ||
auto-format = true | ||
formatter = { command = "treefmt", args = ["--stdin", ".js"] } | ||
language-servers = [ | ||
{ name = "typescript-language-server", except-features = ["format"] }, | ||
{ name = "efm-langserver", except-features = ["format"] }, | ||
] | ||
name = "javascript" | ||
Comment on lines
-76
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additive diagnostics without format. |
||
|
||
[[language]] | ||
auto-format = true | ||
formatter = { command = "treefmt", args = ["--stdin", ".ts"] } | ||
language-servers = [{ name = "typescript-language-server", except-features = ["format"] }] | ||
name = "typescript" | ||
auto-format = true | ||
formatter = { command = "treefmt", args = ["--stdin", ".ts"] } | ||
language-servers = [ | ||
{ name = "typescript-language-server", except-features = ["format"] }, | ||
{ name = "efm-langserver", except-features = ["format"] }, | ||
] | ||
name = "typescript" | ||
|
||
[[language]] | ||
auto-format = true | ||
formatter = { command = "treefmt", args = ["--stdin", ".tsx"] } | ||
language-servers = [ | ||
{ name = "typescript-language-server", except-features = ["format"] }, | ||
{ name = "efm-langserver", except-features = ["format"] }, | ||
"tailwindcss-ls", | ||
] | ||
name = "tsx" | ||
|
||
[[language]] | ||
auto-format = true | ||
formatter = { command = "treefmt", args = ["--stdin", ".jsx"] } | ||
language-servers = [{ name = "typescript-language-server", except-features = ["format"] }] | ||
name = "jsx" | ||
auto-format = true | ||
formatter = { command = "treefmt", args = ["--stdin", ".jsx"] } | ||
language-servers = [ | ||
{ name = "typescript-language-server", except-features = ["format"] }, | ||
{ name = "efm-langserver", except-features = ["format"] }, | ||
] | ||
name = "jsx" | ||
|
||
[[language]] | ||
language-servers = [{ name = "vscode-json-language-server", except-features = ["format"] }, "biome"] | ||
name = "json" | ||
|
||
[[language]] | ||
auto-format = true | ||
file-types = ["svelte"] | ||
formatter = { command = "treefmt", args = ["--stdin", ".svelte"] } | ||
language-servers = ["svelteserver", "tailwindcss-ls"] | ||
name = "svelte" | ||
roots = ["svelte.config.js"] | ||
scope = "source.svelte" | ||
auto-format = true | ||
file-types = ["svelte"] | ||
formatter = { command = "treefmt", args = ["--stdin", ".svelte"] } | ||
language-servers = [ | ||
"svelteserver", | ||
"tailwindcss-ls", | ||
{ name = "efm-langserver", except-features = ["format"] }, | ||
] | ||
name = "svelte" | ||
roots = ["svelte.config.js"] | ||
scope = "source.svelte" | ||
|
||
[[language]] | ||
comment-token = "#" | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { includeIgnoreFile } from "@eslint/compat" | ||
import * as U from "@unionlabs/eslint-config" | ||
import type { Linter } from "eslint" | ||
import svelteConfig from "./svelte.config.js" | ||
|
||
const gitignore = includeIgnoreFile( | ||
new URL(import.meta.resolve("./.gitignore")).pathname, | ||
) | ||
|
||
const config: Linter.Config[] = [ | ||
gitignore, | ||
...U.configs.svelte(svelteConfig), | ||
] | ||
|
||
export default config | ||
Comment on lines
+1
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Much simpler and more consistent. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "@unionlabs/eslint-config", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New workspace project to contain ESLint config for various projects. Currently supports JS, TS, and Svelte. Changes to this project update in real-time for sibling workspace projects given that we are exporting TS and using workspace linking. |
||
"version": "1.9.9", | ||
"type": "module", | ||
"license": "MIT", | ||
"author": "@unionlabs", | ||
"description": "Union ESLint Configuration", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/unionlabs/union.git", | ||
"directory": "eslint-config-union" | ||
}, | ||
"main": "src/index.ts", | ||
"peerDependencies": { | ||
"eslint": "^9.24.0", | ||
"eslint-plugin-svelte": "^3.5.1", | ||
"typescript": ">=5.8.2" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@sveltejs/kit": { | ||
"optional": true | ||
}, | ||
"eslint-plugin-svelte": { | ||
"optional": true | ||
} | ||
}, | ||
"devDependencies": { | ||
"@sveltejs/kit": "^2", | ||
"eslint": "^9.27.0", | ||
"eslint-plugin-svelte": "^3.9.0", | ||
"globals": "^16.0.0", | ||
"typescript": ">=5.8.2" | ||
}, | ||
"dependencies": { | ||
"@eslint/js": "^9.27.0", | ||
"typescript-eslint": "^8.32.1" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import eslint from "@eslint/js" | ||
import { Linter } from "eslint" | ||
|
||
const config: Linter.Config[] = [ | ||
eslint.configs.recommended, | ||
{ | ||
name: "union:javascript:rules", | ||
rules: {}, | ||
}, | ||
] | ||
export default config |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { Config as SvelteConfig } from "@sveltejs/kit" | ||
import type { Linter } from "eslint" | ||
import svelte from "eslint-plugin-svelte" | ||
import globals from "globals" | ||
import tseslint from "typescript-eslint" | ||
import javascript from "./javascript.js" | ||
import typescript from "./typescript.js" | ||
|
||
const config = (config: SvelteConfig): Linter.Config[] => [ | ||
...javascript, | ||
...typescript, | ||
...svelte.configs["flat/recommended"], | ||
{ | ||
languageOptions: { | ||
globals: { | ||
...globals.browser, | ||
...globals.node, | ||
}, | ||
}, | ||
}, | ||
{ | ||
files: ["**/*.svelte", "**/*.svelte.ts", "**/*.svelte.js"], | ||
|
||
languageOptions: { | ||
parserOptions: { | ||
projectService: true, | ||
extraFileExtensions: [".svelte"], // Add support for additional file extensions, such as .svelte | ||
parser: tseslint.parser, | ||
// Specify a parser for each language, if needed: | ||
// parser: { | ||
// ts: ts.parser, | ||
// js: espree, // Use espree for .js files (add: import espree from 'espree') | ||
// typescript: ts.parser | ||
// }, | ||
|
||
// We recommend importing and specifying svelte.config.js. | ||
// By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly. | ||
// While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it, | ||
// explicitly specifying it ensures better compatibility and functionality. | ||
config, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "union:svelte:rules", | ||
rules: {}, | ||
}, | ||
] | ||
export default config |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Linter } from "eslint" | ||
import tseslint from "typescript-eslint" | ||
import javascript from "./javascript.js" | ||
|
||
const config: Linter.Config[] = [ | ||
...javascript, | ||
...tseslint.configs.recommended as Linter.Config[], | ||
{ | ||
name: "union:typescript:rules", | ||
rules: { | ||
"@typescript-eslint/no-empty-object-type": [ | ||
// Allow `{}` types for empty `TaggedEnum`s | ||
"off", | ||
], | ||
"@typescript-eslint/no-unused-vars": [ | ||
// Allow unused underscore-prefixed variables | ||
"error", | ||
{ | ||
args: "all", | ||
argsIgnorePattern: "^_", | ||
caughtErrors: "all", | ||
caughtErrorsIgnorePattern: "^_", | ||
destructuredArrayIgnorePattern: "^_", | ||
varsIgnorePattern: "^_", | ||
ignoreRestSiblings: true, | ||
}, | ||
], | ||
}, | ||
}, | ||
] | ||
export default config |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import javascript from "./configs/javascript.js" | ||
import svelte from "./configs/svelte.js" | ||
import typescript from "./configs/typescript.js" | ||
|
||
export const configs = { | ||
javascript, | ||
svelte, | ||
typescript, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "tsconfig.src.json" | ||
}, | ||
{ | ||
"path": "tsconfig.test.json" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/tsconfig", | ||
"extends": "../tsconfig.base.json", | ||
"include": ["src"], | ||
"compilerOptions": { | ||
"types": ["node"], | ||
"outDir": "build/src", | ||
"tsBuildInfoFile": ".tsbuildinfo/src.tsbuildinfo", | ||
"rootDir": "src" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What
efm-langserver
runs for a given input.