Skip to content

Commit 8b5d172

Browse files
committed
chore: update eslint to handle ts files
1 parent eae82be commit 8b5d172

File tree

3 files changed

+87
-37
lines changed

3 files changed

+87
-37
lines changed

.eslintrc.js

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,48 @@
11
module.exports = {
2-
ignorePatterns: ['vite.*.js', 'src/**/*'],
2+
ignorePatterns: ['vite.*.js', 'packages/**/*.js', 'src/**/*'],
33
root: true,
4-
parser: '@typescript-eslint/parser',
5-
plugins: ['@typescript-eslint', 'html', 'import'],
6-
extends: [
7-
'eslint:recommended',
8-
'plugin:import/recommended',
9-
'plugin:import/typescript',
10-
'plugin:@typescript-eslint/recommended',
11-
'plugin:lit/recommended',
12-
'plugin:lit-a11y/recommended',
13-
'plugin:storybook/recommended',
14-
],
15-
rules: {
16-
// disable the rule for all files
17-
'@typescript-eslint/explicit-module-boundary-types': 'off',
18-
'@typescript-eslint/no-non-null-assertion': 'off',
19-
'@typescript-eslint/no-explicit-any': 'off',
20-
'@typescript-eslint/no-inferrable-types': 'off',
21-
'@typescript-eslint/ban-ts-comment': 'off', //TODO: Remove (maybe)
22-
'@typescript-eslint/ban-types': 'off', //TODO: Remove (maybe)
23-
},
24-
settings: {
25-
'import/resolver': {
26-
typescript: {},
4+
plugins: ['html', 'import'],
5+
overrides: [
6+
{
7+
files: ['*.ts', '*.tsx'],
8+
parser: '@typescript-eslint/parser',
9+
plugins: ['@typescript-eslint'],
10+
extends: [
11+
'plugin:import/typescript',
12+
'plugin:@typescript-eslint/recommended',
13+
'plugin:wc/recommended',
14+
'plugin:lit/recommended',
15+
'plugin:lit-a11y/recommended',
16+
'plugin:storybook/recommended',
17+
],
18+
rules: {
19+
// disable the rule for all files
20+
'@typescript-eslint/explicit-module-boundary-types': 'off',
21+
'@typescript-eslint/no-non-null-assertion': 'off',
22+
'@typescript-eslint/no-explicit-any': 'off',
23+
'@typescript-eslint/no-inferrable-types': 'off',
24+
'@typescript-eslint/ban-ts-comment': 'off', //TODO: Remove (maybe)
25+
'@typescript-eslint/ban-types': 'off', //TODO: Remove (maybe)
26+
'lit/no-useless-template-literals': 'error',
27+
'lit/prefer-nothing': 'error',
28+
},
29+
parserOptions: {
30+
project: './tsconfig.json',
31+
tsconfigRootDir: './',
32+
},
33+
settings: {
34+
'import/resolver': {
35+
typescript: {},
36+
},
37+
wc: {
38+
elementBaseClasses: ['LitElement'], // Recognize `LitElement` as a Custom Element base class
39+
},
40+
},
2741
},
28-
},
29-
parserOptions: {
30-
project: './tsconfig.json',
31-
tsconfigRootDir: './',
32-
},
42+
],
3343
env: {
3444
browser: true,
3545
node: true,
46+
es6: true,
3647
},
3748
};

package-lock.json

Lines changed: 39 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"custom-elements"
2020
],
2121
"scripts": {
22-
"lint:eslint": "eslint --ext .ts,.html,.mjs,.cjs . --ignore-path .gitignore",
23-
"format:eslint": "eslint --ext .ts,.html,.mjs,.cjs . --fix --ignore-path .gitignore",
22+
"lint:eslint": "eslint ./packages --ignore-path .gitignore",
23+
"format:eslint": "eslint ./packages --fix --ignore-path .gitignore",
2424
"lint:prettier": "prettier \"**/*.js\" \"**/*.ts\" \"**/*.mjs\" --check --ignore-path .gitignore",
2525
"format:prettier": "prettier \"**/*.js\" \"**/*.ts\" \"**/*.mjs\" --write --ignore-path .gitignore",
2626
"lint": "npm run lint:eslint && npm run lint:prettier",
@@ -90,8 +90,9 @@
9090
"eslint-plugin-html": "7.1.0",
9191
"eslint-plugin-import": "2.27.5",
9292
"eslint-plugin-lit": "1.8.3",
93-
"eslint-plugin-lit-a11y": "2.4.1",
93+
"eslint-plugin-lit-a11y": "4.1.0",
9494
"eslint-plugin-storybook": "0.6.12",
95+
"eslint-plugin-wc": "1.5.0",
9596
"github-markdown-css": "5.2.0",
9697
"glob": "8.0.3",
9798
"husky": "8.0.3",
@@ -133,8 +134,10 @@
133134
"./packages/*"
134135
],
135136
"lint-staged": {
136-
"*.ts": "tsc-files --project tsconfig.lint-staged.json",
137-
"*.{js,ts,mjs,cjs,html}": "eslint --cache --fix -c .eslintrc.js",
137+
"*.ts": [
138+
"tsc-files --project tsconfig.lint-staged.json",
139+
"eslint --cache --fix -c .eslintrc.js"
140+
],
138141
"*": "prettier --ignore-unknown --write"
139142
},
140143
"storybook": {

0 commit comments

Comments
 (0)