Skip to content

Commit e7d663f

Browse files
authored
feat(eslint-config)!: split config packages (#50)
1 parent ff06fba commit e7d663f

File tree

15 files changed

+179
-76
lines changed

15 files changed

+179
-76
lines changed

.eslintrc.cjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,26 @@ module.exports = {
1010
env: {
1111
node: true,
1212
},
13+
overrides: [
14+
{
15+
files: [
16+
'packages/eslint-config/**/*.js',
17+
'packages/eslint-config-svelte/**/*.js',
18+
],
19+
parserOptions: {
20+
sourceType: 'script',
21+
},
22+
env: {
23+
commonjs: true,
24+
},
25+
rules: {
26+
'@typescript-eslint/no-require-imports': 'off',
27+
'@typescript-eslint/no-unsafe-member-access': 'off',
28+
'@typescript-eslint/no-unsafe-call': 'off',
29+
'@typescript-eslint/no-unsafe-assignment': 'off',
30+
'@typescript-eslint/no-var-requires': 'off',
31+
'unicorn/prefer-module': 'off',
32+
},
33+
},
34+
],
1335
};

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,26 @@ Shared configuration for JavaScript and TypeScript tools.
44

55
## Libraries
66

7-
| Tool | NPM Module | Version |
8-
| ----------------------------- | --------------------------------- | ----------------------------------------- |
9-
| [ESLint][eslint docs] | `@viamrobotics/eslint-config` | [![eslint version][]][eslint npm] |
10-
| [Prettier][prettier docs] | `@viamrobotics/prettier-config` | [![prettier version][]][prettier npm] |
11-
| [TypeScript][typescript docs] | `@viamrobotics/typescript-config` | [![typescript version][]][typescript npm] |
7+
| Tool | NPM Module | Version |
8+
| ----------------------------------------- | -------------------------------------- | --------------------------------------------------- |
9+
| [ESLint][eslint docs] | `@viamrobotics/eslint-config` | [![eslint version][]][eslint npm] |
10+
| [ESLint + Svelte][eslint-svelte docs] | `@viamrobotics/eslint-config-svelte` | [![eslint-svelte version][]][eslint-svelte npm] |
11+
| [Prettier][prettier docs] | `@viamrobotics/prettier-config` | [![prettier version][]][prettier npm] |
12+
| [Prettier + Svelte][prettier-svelte docs] | `@viamrobotics/prettier-config-svelte` | [![prettier-svelte version][]][prettier-svelte npm] |
13+
| [TypeScript][typescript docs] | `@viamrobotics/typescript-config` | [![typescript version][]][typescript npm] |
1214

1315
[eslint docs]: ./packages/eslint-config
1416
[eslint npm]: https://www.npmjs.com/package/@viamrobotics/eslint-config
1517
[eslint version]: https://img.shields.io/npm/v/@viamrobotics/eslint-config?style=flat-square
18+
[eslint-svelte docs]: ./packages/eslint-config-svelte
19+
[eslint-svelte npm]: https://www.npmjs.com/package/@viamrobotics/eslint-config-svelte
20+
[eslint-svelte version]: https://img.shields.io/npm/v/@viamrobotics/eslint-config-svelte?style=flat-square
1621
[prettier docs]: ./packages/prettier-config
1722
[prettier npm]: https://www.npmjs.com/package/@viamrobotics/prettier-config
1823
[prettier version]: https://img.shields.io/npm/v/@viamrobotics/prettier-config?style=flat-square
24+
[prettier-svelte docs]: ./packages/prettier-config-svelte
25+
[prettier-svelte npm]: https://www.npmjs.com/package/@viamrobotics/prettier-config-svelte
26+
[prettier-svelte version]: https://img.shields.io/npm/v/@viamrobotics/prettier-config-svelte?style=flat-square
1927
[typescript docs]: ./packages/typescript-config
2028
[typescript npm]: https://www.npmjs.com/package/@viamrobotics/typescript-config
2129
[typescript version]: https://img.shields.io/npm/v/@viamrobotics/typescript-config?style=flat-square
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tsconfig.json
2+
*.tsbuildinfo
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Viam's ESLint Config for Svelte
2+
3+
This module contains [Viam][]'s shared [ESLint][] configurations for ESLint v8 in [Svelte][] projects.
4+
5+
[viam]: https://www.viam.com/
6+
[eslint]: https://eslint.org/
7+
[svelte]: https://svelte.dev/
8+
9+
## Base config
10+
11+
Extend the [config](./eslint-config-svelte.js) in `.eslintrc.cjs`.
12+
13+
```shell
14+
pnpm add --save-dev \
15+
eslint@^8.56.0 \
16+
@viamrobotics/eslint-config-svelte \
17+
@typescript-eslint/parser \
18+
@typescript-eslint/eslint-plugin \
19+
eslint-config-prettier \
20+
eslint-plugin-jest-dom \
21+
eslint-plugin-simple-import-sort \
22+
eslint-plugin-svelte \
23+
eslint-plugin-tailwindcss \
24+
eslint-plugin-testing-library \
25+
eslint-plugin-unicorn \
26+
eslint-plugin-vitest
27+
```
28+
29+
```js
30+
// .eslintrc.cjs
31+
'use strict';
32+
33+
module.exports = {
34+
root: true,
35+
extends: ['@viamrobotics/eslint-config-svelte'],
36+
parserOptions: {
37+
tsconfigRootDir: __dirname,
38+
projectService: true,
39+
},
40+
};
41+
```
42+
43+
## Non-Svelte projects
44+
45+
See [@viamrobotics/eslint-config](../eslint-config/)

packages/eslint-config/svelte.cjs renamed to packages/eslint-config-svelte/eslint-config-svelte.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const baseConfig = require('./base.cjs');
3+
const baseConfig = require('@viamrobotics/eslint-config');
44

55
module.exports = {
66
...baseConfig,
@@ -11,6 +11,12 @@ module.exports = {
1111
'plugin:svelte/prettier',
1212
],
1313
settings: {
14+
svelte: {
15+
ignoreWarnings: [
16+
'@typescript-eslint/no-unsafe-assignment',
17+
'@typescript-eslint/no-unsafe-member-access',
18+
],
19+
},
1420
tailwindcss: {
1521
callees: ['classnames', 'cx'],
1622
classRegex: '^(?:class|cx)$',
@@ -29,6 +35,8 @@ module.exports = {
2935
parser: '@typescript-eslint/parser',
3036
},
3137
rules: {
38+
// Redundant with `svelte-check` and build
39+
'svelte/valid-compile': 'off',
3240
// Allows us to set option props to `undefined` by default
3341
'no-undef-init': 'off',
3442
},
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "@viamrobotics/eslint-config-svelte",
3+
"publishConfig": {
4+
"access": "public"
5+
},
6+
"version": "0.8.0",
7+
"description": "ESLint configuration for Svelte projects at Viam.",
8+
"type": "commonjs",
9+
"main": "./eslint-config-svelte.js",
10+
"types": "./dist/eslint-config-svelte.d.ts",
11+
"exports": {
12+
".": {
13+
"types": "./dist/eslint-config-svelte.d.ts",
14+
"default": "./eslint-config-svelte.js"
15+
}
16+
},
17+
"repository": {
18+
"type": "git",
19+
"url": "git+https://github.com/viamrobotics/js-config.git",
20+
"directory": "packages/eslint-config-svelte"
21+
},
22+
"keywords": [
23+
"eslint",
24+
"eslintconfig",
25+
"svelte"
26+
],
27+
"license": "Apache-2.0",
28+
"dependencies": {
29+
"@viamrobotics/eslint-config": "workspace:*"
30+
},
31+
"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",
43+
"typescript": ">=5 <6",
44+
"vitest": "*"
45+
}
46+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "@viamrobotics/typescript-config/base.json",
3+
"compilerOptions": {
4+
"types": ["node"],
5+
"composite": true,
6+
"declaration": true,
7+
"emitDeclarationOnly": true,
8+
"outDir": "dist"
9+
},
10+
"references": [{ "path": "../eslint-config" }],
11+
"include": ["*.js"]
12+
}

packages/eslint-config/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tsconfig.json
2+
*.tsbuildinfo

packages/eslint-config/README.md

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Shared ESLint Config for Viam
1+
# Viam's ESLint Config
22

33
This module contains [Viam][]'s shared [ESLint][] configurations for ESLint v8.
44

@@ -7,15 +7,16 @@ This module contains [Viam][]'s shared [ESLint][] configurations for ESLint v8.
77

88
## Base config
99

10-
Use the [base config](./base.cjs) for vanilla JavaScript / TypeScript projects. Be sure to add your `tsconfig.json` files to `parserOptions.project` and `settings['import/resolver'].typescript.project`.
10+
Extend the [config](./eslint-config.js) in `.eslintrc.cjs`.
1111

1212
```shell
1313
pnpm add --save-dev \
14+
eslint@^8.56.0 \
1415
@viamrobotics/eslint-config \
1516
@typescript-eslint/parser \
1617
@typescript-eslint/eslint-plugin \
17-
eslint \
1818
eslint-config-prettier \
19+
eslint-plugin-simple-import-sort \
1920
eslint-plugin-unicorn \
2021
eslint-plugin-vitest
2122
```
@@ -28,39 +29,12 @@ module.exports = {
2829
root: true,
2930
extends: ['@viamrobotics/eslint-config'],
3031
parserOptions: {
31-
project: ['./tsconfig.json'],
32+
tsconfigRootDir: __dirname,
33+
projectService: true,
3234
},
3335
};
3436
```
3537

3638
## Svelte config
3739

38-
Use the [Svelte config](./svelte.cjs) for Svelte projects.
39-
40-
```shell
41-
pnpm add --save-dev \
42-
@viamrobotics/eslint-config \
43-
@typescript-eslint/parser \
44-
@typescript-eslint/eslint-plugin \
45-
eslint \
46-
eslint-config-prettier \
47-
eslint-plugin-jest-dom \
48-
eslint-plugin-svelte \
49-
eslint-plugin-tailwindcss \
50-
eslint-plugin-testing-library \
51-
eslint-plugin-unicorn \
52-
eslint-plugin-vitest
53-
```
54-
55-
```js
56-
// .eslintrc.cjs
57-
'use strict';
58-
59-
module.exports = {
60-
root: true,
61-
extends: ['@viamrobotics/eslint-config/svelte'],
62-
parserOptions: {
63-
project: ['./tsconfig.json'],
64-
},
65-
};
66-
```
40+
See [@viamrobotics/eslint-config-svelte](../eslint-config-svelte/)

0 commit comments

Comments
 (0)