Skip to content

Commit 1933e5a

Browse files
authored
feat: html,css lint, zed config, perfectionist (#260)
- restored html linting - had to rewrite the eslint config to avoid JS rules being applied on html - added css lint - added .zed/settings.json for Zed - added eslint-plugin-perfectionist and updated the code to sort the imports properly
1 parent 54f64b4 commit 1933e5a

18 files changed

+307
-369
lines changed

.vscode/settings.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"source.fixAll.eslint": "explicit"
44
},
55
"eslint.validate": [
6-
"typescript",
7-
"typescriptreact",
6+
"css",
7+
"html",
88
"javascript",
99
"json",
1010
"jsonc",
11+
"typescript",
12+
"typescriptreact",
1113
"yaml"
1214
],
13-
"files.associations": {
14-
"*.css": "tailwindcss"
15-
}
15+
"css.customData": ["./.vscode/tailwind.json"]
1616
}

.vscode/tailwind.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"atDirectives": [
3+
{
4+
"name": "@theme",
5+
"description": "Use the @theme directive to define your project's custom design tokens, like fonts, colors, and breakpoints.",
6+
"references": [
7+
{
8+
"name": "Tailwind's “Functions & Directives” documentation",
9+
"url": "https://tailwindcss.com/docs/functions-and-directives#theme-directive"
10+
}
11+
]
12+
}
13+
]
14+
}

.zed/settings.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"disable_ai": true,
3+
"code_actions_on_format": {
4+
"source.fixAll.eslint": true
5+
},
6+
"languages": {
7+
"CSS": {
8+
"language_servers": ["eslint", "tailwindcss-language-server"]
9+
},
10+
"HTML": {
11+
"formatter": [{ "code_action": "source.fixAll.eslint" }],
12+
"language_servers": ["eslint", "vscode-html-language-server"]
13+
},
14+
"JSONC": {
15+
"formatter": [{ "code_action": "source.fixAll.eslint" }],
16+
"language_servers": ["eslint", "json-language-server"]
17+
},
18+
"JSON": {
19+
"formatter": [{ "code_action": "source.fixAll.eslint" }],
20+
"language_servers": ["eslint", "json-language-server"]
21+
},
22+
"YAML": {
23+
"language_servers": ["eslint", "yaml-language-server"]
24+
}
25+
}
26+
}

env.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
/// <reference types="vitest" />
33
/// <reference types="@testing-library/jest-dom/vitest" />
44

5-
interface ImportMetaEnv {
6-
readonly BASE?: string;
7-
}
8-
95
interface ImportMeta {
106
readonly env: ImportMetaEnv;
117
}
8+
9+
interface ImportMetaEnv {
10+
readonly BASE?: string;
11+
}

eslint.config.ts

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,21 @@
1-
import eslint from '@eslint/js';
1+
/* eslint-disable import-x/no-named-as-default-member */
22
import { includeIgnoreFile } from '@eslint/compat';
3-
import { defineConfig, globalIgnores } from 'eslint/config';
4-
import { configs as tseslintConfigs } from 'typescript-eslint';
3+
import css from '@eslint/css';
4+
import eslint from '@eslint/js';
5+
import html from '@html-eslint/eslint-plugin';
6+
import stylistic from '@stylistic/eslint-plugin';
7+
import { importX } from 'eslint-plugin-import-x';
8+
import jsonc from 'eslint-plugin-jsonc';
59
import jsxA11y from 'eslint-plugin-jsx-a11y';
6-
import solidTsConfig from 'eslint-plugin-solid/configs/typescript';
10+
import perfectionist from 'eslint-plugin-perfectionist';
711
import prettierRecommended from 'eslint-plugin-prettier/recommended';
8-
import jsonc from 'eslint-plugin-jsonc';
12+
import solidTsConfig from 'eslint-plugin-solid/configs/typescript';
913
import yml from 'eslint-plugin-yml';
10-
import { importX } from 'eslint-plugin-import-x';
11-
import stylistic from '@stylistic/eslint-plugin';
14+
import { defineConfig, globalIgnores } from 'eslint/config';
1215
import { fileURLToPath } from 'node:url';
13-
import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript';
16+
import tseslint from 'typescript-eslint';
1417

1518
export default defineConfig(
16-
eslint.configs.recommended,
17-
tseslintConfigs.strictTypeChecked,
18-
tseslintConfigs.stylisticTypeChecked,
19-
jsxA11y.flatConfigs.strict,
20-
// @ts-expect-error Argument of type is not assignable to parameter of type 'InfiniteArray<ConfigWithExtends>'ts(2345)
21-
solidTsConfig,
22-
importX.flatConfigs.recommended,
23-
importX.flatConfigs.typescript,
24-
stylistic.configs.customize({
25-
semi: true,
26-
}),
27-
prettierRecommended,
2819
includeIgnoreFile(fileURLToPath(new URL('.gitignore', import.meta.url))),
2920
globalIgnores(['pnpm-lock.yaml']),
3021
{
@@ -34,26 +25,76 @@ export default defineConfig(
3425
ecmaFeatures: {
3526
jsx: true,
3627
},
28+
extraFileExtensions: ['.css'],
3729
projectService: true,
3830
tsconfigRootDir: import.meta.dirname,
3931
},
4032
},
33+
},
34+
{
35+
extends: [
36+
eslint.configs.recommended,
37+
tseslint.configs.strictTypeChecked,
38+
tseslint.configs.stylisticTypeChecked,
39+
jsxA11y.flatConfigs.strict,
40+
// @ts-expect-error Types of property create are incompatible. (ts 2322)
41+
solidTsConfig,
42+
// @ts-expect-error Types of property languageOptions are incompatible. (ts 2322)
43+
importX.flatConfigs.recommended,
44+
// @ts-expect-error Types of property languageOptions are incompatible. (ts 2322)
45+
importX.flatConfigs.typescript,
46+
stylistic.configs.customize({
47+
jsx: false,
48+
semi: true,
49+
}),
50+
perfectionist.configs['recommended-natural'],
51+
prettierRecommended,
52+
],
53+
files: ['**/*.{ts,tsx}'],
4154
rules: {
4255
'@typescript-eslint/restrict-template-expressions': [
4356
'error',
4457
{ allowNumber: true },
4558
],
4659
},
47-
settings: {
48-
'import-x/resolver-next': [createTypeScriptImportResolver()],
60+
},
61+
{
62+
extends: [
63+
jsonc.configs['flat/recommended-with-jsonc'],
64+
jsonc.configs['flat/prettier'],
65+
prettierRecommended,
66+
],
67+
files: ['**/*.json'],
68+
},
69+
{
70+
extends: [
71+
yml.configs['flat/recommended'],
72+
yml.configs['flat/prettier'],
73+
prettierRecommended,
74+
],
75+
files: ['**/*.{yml,yaml}'],
76+
},
77+
{
78+
extends: ['css/recommended', prettierRecommended],
79+
files: ['**/*.css'],
80+
language: 'css/css',
81+
plugins: { css },
82+
rules: {
83+
'css/no-invalid-at-rules': 'off',
4984
},
5085
},
51-
jsonc.configs['flat/recommended-with-jsonc'],
52-
jsonc.configs['flat/prettier'],
53-
yml.configs['flat/recommended'],
54-
yml.configs['flat/prettier'],
5586
{
56-
files: ['**/*.{json,yml,yaml}'],
57-
...tseslintConfigs.disableTypeChecked,
87+
extends: ['html/recommended'],
88+
files: ['**/*.html'],
89+
language: 'html/html',
90+
plugins: { html },
91+
rules: {
92+
'html/attrs-newline': [
93+
'error',
94+
{ closeStyle: 'newline', ifAttrsMoreThan: 3 },
95+
],
96+
'html/indent': ['error', 2],
97+
'html/no-trailing-spaces': 'error',
98+
},
5899
},
59100
);

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Solid Clock</title>
7-
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
7+
<link rel="icon" type="image/svg+xml" href="/logo.svg">
88
</head>
99
<body class="m-0">
1010
<script type="module" src="/src/index.tsx"></script>

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
},
1515
"devDependencies": {
1616
"@eslint/compat": "2.0.0",
17+
"@eslint/css": "0.14.1",
1718
"@eslint/js": "9.39.2",
19+
"@html-eslint/eslint-plugin": "0.52.1",
1820
"@solidjs/testing-library": "0.8.10",
1921
"@stylistic/eslint-plugin": "5.7.0",
2022
"@tailwindcss/vite": "4.1.18",
@@ -28,6 +30,7 @@
2830
"eslint-plugin-import-x": "4.16.1",
2931
"eslint-plugin-jsonc": "2.21.0",
3032
"eslint-plugin-jsx-a11y": "6.10.2",
33+
"eslint-plugin-perfectionist": "5.3.1",
3134
"eslint-plugin-prettier": "5.5.4",
3235
"eslint-plugin-solid": "0.14.5",
3336
"eslint-plugin-yml": "1.19.1",

0 commit comments

Comments
 (0)