Skip to content

Commit b430350

Browse files
committed
APP-7509: update common ESLint configs to v9
1 parent e7d663f commit b430350

File tree

17 files changed

+976
-1020
lines changed

17 files changed

+976
-1020
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.cjs

Lines changed: 0 additions & 35 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
node_modules
22
dist
3-
*.d.cts
4-
*.d.ts
53
*.tgz
64
*.tsbuildinfo

eslint.config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import baseConfig from '@viamrobotics/eslint-config';
2+
3+
export default [
4+
...baseConfig,
5+
{
6+
languageOptions: {
7+
parserOptions: {
8+
projectService: true,
9+
tsconfigRootDir: import.meta.dirname,
10+
},
11+
},
12+
},
13+
{
14+
ignores: ['**/dist/**'],
15+
},
16+
];

package.json

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,20 @@
1717
},
1818
"packageManager": "[email protected]+sha256.06e65a4965baff6d6097f9c8f75c35f6d420974dbc03d775009056a69edfd271",
1919
"devDependencies": {
20-
"@types/node": "^22.10.1",
20+
"@types/node": "^22.13.1",
2121
"@types/semver": "^7.5.8",
22-
"@typescript-eslint/eslint-plugin": "^8.17.0",
23-
"@typescript-eslint/parser": "^8.17.0",
22+
"@typescript-eslint/eslint-plugin": "^8.23.0",
23+
"@typescript-eslint/parser": "^8.23.0",
2424
"@viamrobotics/eslint-config": "workspace:*",
2525
"@viamrobotics/prettier-config": "workspace:*",
2626
"@viamrobotics/typescript-config": "workspace:*",
27-
"concurrently": "^9.1.0",
28-
"eslint": "^8.57.1",
29-
"eslint-config-prettier": "^9.1.0",
30-
"eslint-plugin-jest-dom": "^5.5.0",
31-
"eslint-plugin-simple-import-sort": "^12.1.1",
32-
"eslint-plugin-svelte": "^2.46.1",
33-
"eslint-plugin-tailwindcss": "^3.17.5",
34-
"eslint-plugin-testing-library": "^7.0.0",
35-
"eslint-plugin-unicorn": "^56.0.1",
36-
"eslint-plugin-vitest": "^0.5.4",
37-
"prettier": "^3.4.1",
38-
"semver": "^7.6.3",
39-
"svelte": "^5.4.0",
40-
"tailwindcss": "3.4.15",
41-
"typescript": "^5.7.2",
42-
"vitest": "^2.1.8"
27+
"concurrently": "^9.1.2",
28+
"eslint": "^9.16.0",
29+
"prettier": "^3.4.2",
30+
"semver": "^7.7.1",
31+
"svelte": "^5.5.2",
32+
"tailwindcss": "3.4.16",
33+
"typescript": "^5.7.3",
34+
"vitest": "^3.0.5"
4335
}
4436
}
Lines changed: 101 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,111 @@
1-
'use strict';
1+
import * as svelteParser from 'svelte-eslint-parser';
2+
import jestDOM from 'eslint-plugin-jest-dom';
3+
import svelte from 'eslint-plugin-svelte';
4+
import tailwind from 'eslint-plugin-tailwindcss';
5+
import testingLibrary from 'eslint-plugin-testing-library';
6+
import globals from 'globals';
7+
import ts from 'typescript-eslint';
28

3-
const baseConfig = require('@viamrobotics/eslint-config');
9+
import baseConfig from '@viamrobotics/eslint-config';
410

5-
module.exports = {
6-
...baseConfig,
7-
extends: [
8-
...baseConfig.extends,
9-
'plugin:tailwindcss/recommended',
10-
'plugin:svelte/recommended',
11-
'plugin:svelte/prettier',
12-
],
13-
settings: {
14-
svelte: {
15-
ignoreWarnings: [
16-
'@typescript-eslint/no-unsafe-assignment',
17-
'@typescript-eslint/no-unsafe-member-access',
18-
],
11+
const extraFileExtensions = ['.svelte'];
12+
13+
/**
14+
* @typedef {import('@viamrobotics/eslint-config').ConfigArray} ConfigArray
15+
*/
16+
17+
/** @satisfies {ConfigArray} */
18+
const config = ts.config(
19+
baseConfig,
20+
tailwind.configs['flat/recommended'],
21+
svelte.configs['flat/recommended'],
22+
svelte.configs['flat/prettier'],
23+
24+
// Base options and settings
25+
{
26+
name: 'viam/svelte/base',
27+
languageOptions: {
28+
parserOptions: { extraFileExtensions },
29+
globals: {
30+
...globals.browser,
31+
},
32+
},
33+
settings: {
34+
svelte: {
35+
ignoreWarnings: [
36+
'@typescript-eslint/no-unsafe-assignment',
37+
'@typescript-eslint/no-unsafe-member-access',
38+
],
39+
},
40+
tailwindcss: {
41+
callees: ['classnames', 'cx'],
42+
classRegex: '^(?:class|cx)$',
43+
},
1944
},
20-
tailwindcss: {
21-
callees: ['classnames', 'cx'],
22-
classRegex: '^(?:class|cx)$',
45+
rules: {
46+
// Too many false positives
47+
'svelte/require-stores-init': 'off',
2348
},
2449
},
25-
parserOptions: {
26-
...baseConfig.parserOptions,
27-
extraFileExtensions: ['.svelte'],
28-
},
29-
overrides: [
30-
...baseConfig.overrides,
31-
{
32-
files: ['*.svelte'],
33-
parser: 'svelte-eslint-parser',
50+
51+
{
52+
name: 'viam/svelte/svelte-base',
53+
files: ['**/*.svelte'],
54+
languageOptions: {
55+
parser: svelteParser,
3456
parserOptions: {
35-
parser: '@typescript-eslint/parser',
36-
},
37-
rules: {
38-
// Redundant with `svelte-check` and build
39-
'svelte/valid-compile': 'off',
40-
// Allows us to set option props to `undefined` by default
41-
'no-undef-init': 'off',
57+
parser: ts.parser,
58+
extraFileExtensions,
59+
svelteFeatures: {
60+
experimentalGenerics: true,
61+
},
4262
},
4363
},
44-
// Rules for tests
45-
{
46-
files: ['**/__tests__/**', '**/*.test.ts', '**/*.spec.ts'],
47-
extends: ['plugin:jest-dom/recommended', 'plugin:testing-library/dom'],
48-
rules: {
49-
'testing-library/await-async-events': [
50-
'error',
51-
{ eventModule: ['fireEvent', 'userEvent'] },
52-
],
53-
'testing-library/no-await-sync-events': 'off',
54-
'testing-library/no-node-access': [
55-
'error',
56-
{ allowContainerFirstChild: true },
57-
],
58-
'testing-library/prefer-explicit-assert': [
59-
'error',
60-
{ assertion: 'toBeInTheDocument' },
61-
],
62-
'testing-library/prefer-user-event': 'error',
64+
rules: {
65+
// Allows us to set option props to `undefined` by default
66+
'no-undef-init': 'off',
67+
},
68+
},
69+
70+
{
71+
name: 'viam/svelte/modules',
72+
files: ['**/*.svelte.ts', '*.svelte.ts'],
73+
languageOptions: {
74+
parser: svelteParser,
75+
parserOptions: {
76+
parser: ts.parser,
6377
},
6478
},
65-
],
66-
};
79+
},
80+
81+
{
82+
...jestDOM.configs['flat/recommended'],
83+
name: 'viam/svelte/jest-dom',
84+
files: ['**/__tests__/**', '**/*.test.ts', '**/*.spec.ts'],
85+
},
86+
87+
{
88+
...testingLibrary.configs['flat/dom'],
89+
name: 'viam/svelte/testing-library',
90+
files: ['**/__tests__/**', '**/*.test.ts', '**/*.spec.ts'],
91+
rules: {
92+
...testingLibrary.configs['flat/dom'].rules,
93+
'testing-library/await-async-events': [
94+
'error',
95+
{ eventModule: ['fireEvent', 'userEvent'] },
96+
],
97+
'testing-library/no-await-sync-events': 'off',
98+
'testing-library/no-node-access': [
99+
'error',
100+
{ allowContainerFirstChild: true },
101+
],
102+
'testing-library/prefer-explicit-assert': [
103+
'error',
104+
{ assertion: 'toBeInTheDocument' },
105+
],
106+
'testing-library/prefer-user-event': 'error',
107+
},
108+
}
109+
);
110+
111+
export default config;

packages/eslint-config-svelte/package.json

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"publishConfig": {
44
"access": "public"
55
},
6-
"version": "0.8.0",
6+
"version": "1.0.0",
77
"description": "ESLint configuration for Svelte projects at Viam.",
8-
"type": "commonjs",
8+
"type": "module",
99
"main": "./eslint-config-svelte.js",
1010
"types": "./dist/eslint-config-svelte.d.ts",
1111
"exports": {
@@ -26,21 +26,28 @@
2626
],
2727
"license": "Apache-2.0",
2828
"dependencies": {
29-
"@viamrobotics/eslint-config": "workspace:*"
29+
"@typescript-eslint/utils": "~8.23.0",
30+
"@viamrobotics/eslint-config": "workspace:^",
31+
"eslint-plugin-jest-dom": "~5.5.0",
32+
"eslint-plugin-svelte": "~3.0.0 || ~3.0.0-next",
33+
"eslint-plugin-tailwindcss": "~3.17.5",
34+
"eslint-plugin-testing-library": "~7.1.1",
35+
"globals": "^15.13.0",
36+
"typescript-eslint": "~8.23.0"
3037
},
3138
"peerDependencies": {
32-
"@typescript-eslint/eslint-plugin": ">=6 <9",
33-
"@typescript-eslint/parser": ">=6 <9",
34-
"eslint": ">=8 <9",
35-
"eslint-config-prettier": ">=9 <10",
36-
"eslint-plugin-jest-dom": ">=5 <6",
37-
"eslint-plugin-simple-import-sort": ">=12 <13",
38-
"eslint-plugin-svelte": ">=2 <3",
39-
"eslint-plugin-tailwindcss": ">=3 <4",
40-
"eslint-plugin-testing-library": ">=6 <8",
41-
"eslint-plugin-unicorn": ">=47 <57",
42-
"eslint-plugin-vitest": ">=0.5 <0.6",
39+
"eslint": ">=9 <10",
40+
"svelte": "*",
41+
"tailwindcss": ">=3 <4",
4342
"typescript": ">=5 <6",
4443
"vitest": "*"
44+
},
45+
"peerDependenciesMeta": {
46+
"svelte": {
47+
"optional": true
48+
},
49+
"vitest": {
50+
"optional": true
51+
}
4552
}
4653
}

packages/eslint-config-svelte/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"outDir": "dist"
99
},
1010
"references": [{ "path": "../eslint-config" }],
11-
"include": ["*.js"]
11+
"include": ["*.js", "typings"]
1212
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare module 'eslint-plugin-tailwindcss' {
2+
import type { Linter } from 'eslint';
3+
4+
const rules: Linter.RulesRecord;
5+
const configs: { 'flat/recommended': Linter.Config };
6+
7+
export default { rules, configs };
8+
}

0 commit comments

Comments
 (0)