Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
feat: use lit and wc plugins for web components
Browse files Browse the repository at this point in the history
  • Loading branch information
zmrl010 committed Sep 12, 2022
1 parent cd569fb commit fe321fe
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 5 deletions.
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
"./import": "./dist/configs/import.js",
"./jest": "./dist/configs/jest.js",
"./jsx-a11y": "./dist/configs/jsx-a11y.js",
"./lit": "./dist/configs/lit.js",
"./package.json": "./package.json",
"./react": "./dist/configs/react.js",
"./testing-library": "./dist/configs/testing-library.js",
"./package.json": "./package.json"
"./wc": "./dist/configs/wc.js"
},
"eslintConfig": {
"extends": "./dist/configs/main.js",
Expand Down Expand Up @@ -88,9 +90,11 @@
"eslint-plugin-jest": "^26.9.0",
"eslint-plugin-jest-dom": "^4.0.2",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-lit": "^1.6.1",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-testing-library": "^5.6.3",
"eslint-plugin-wc": "^1.3.2",
"read-pkg-up": "^7.0.1",
"semver": "^7.3.7"
}
Expand Down
60 changes: 60 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/configs/import.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Linter } from 'eslint';
import '../eslint-patch/modern-module-resolution';

const importConfig: Linter.Config = {
const config: Linter.Config = {
env: {
es6: true,
},
Expand Down Expand Up @@ -88,4 +88,4 @@ const importConfig: Linter.Config = {
],
};

export = importConfig;
export = config;
29 changes: 29 additions & 0 deletions src/configs/lit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Linter } from 'eslint';
import '../eslint-patch/modern-module-resolution';

const config: Linter.Config = {
extends: ['./wc'],
plugins: ['lit'],

rules: {
'lit/attribute-value-entities': 'error',
'lit/binding-positions': 'error',
'lit/no-duplicate-template-bindings': 'error',
'lit/no-invalid-html': 'error',
'lit/no-legacy-template-syntax': 'error',
'lit/no-property-change-update': 'error',

'lit/no-invalid-escape-sequences': 'off',
'lit/no-legacy-imports': 'off',
'lit/no-private-properties': 'off',
'lit/no-template-arrow': 'off',
'lit/no-template-bind': 'off',
'lit/no-template-map': 'off',
'lit/no-useless-template-literals': 'off',
'lit/no-value-attribute': 'off',
'lit/prefer-static-styles': 'off',
'lit/quoted-expressions': 'off',
},
};

export = config;
4 changes: 2 additions & 2 deletions src/configs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import '../eslint-patch/modern-module-resolution';

const tsConfig = resolveFirst('tsconfig.json', 'types/tsconfig.json');

const main: Linter.Config = {
const config: Linter.Config = {
env: {
browser: true,
es6: true,
Expand Down Expand Up @@ -425,4 +425,4 @@ const main: Linter.Config = {
],
};

export = main;
export = config;
22 changes: 22 additions & 0 deletions src/configs/wc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Linter } from 'eslint';
import '../eslint-patch/modern-module-resolution';

const config: Linter.Config = {
plugins: ['wc'],
parserOptions: {
sourceType: 'module',
},
rules: {
'wc/no-constructor-attributes': 'error',
'wc/no-invalid-element-name': 'error',
'wc/no-self-class': 'error',
'wc/attach-shadow-constructor': 'error',
'wc/guard-super-call': 'error',
'wc/no-closed-shadow-root': 'error',
'wc/no-constructor-params': 'error',
'wc/no-typos': 'error',
'wc/require-listener-teardown': 'error',
},
};

export = config;
4 changes: 4 additions & 0 deletions test/wc/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ['./index.js'],
};
3 changes: 3 additions & 0 deletions test/wc/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@zmrl', '@zmrl/eslint-config/lit'],
};
13 changes: 13 additions & 0 deletions test/wc/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"devDependencies": {
"@zmrl/eslint-config": "workspace:*",
"eslint": "^8.22.0",
"eslint-find-rules": "^4.1.0"
},
"main": "./index.js",
"name": "lit-test",
"scripts": {
"find-new-rules": "eslint-find-rules -u"
},
"version": "1.2.3"
}

0 comments on commit fe321fe

Please sign in to comment.