Add ESLint (#3)
This commit is contained in:
25
.eslintrc.json
Normal file
25
.eslintrc.json
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2020,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"@typescript-eslint"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"no-unexpected-multiline": "off",
|
||||||
|
"@typescript-eslint/indent": "off",
|
||||||
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
|
"@typescript-eslint/no-non-null-assertion": "off",
|
||||||
|
"@typescript-eslint/no-use-before-define": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": ["warn", {
|
||||||
|
"argsIgnorePattern": "^_"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
16
README.md
16
README.md
@@ -12,7 +12,7 @@ npm i
|
|||||||
|
|
||||||
## Build
|
## Build
|
||||||
|
|
||||||
This sample uses the TypeScript compiler to produce JavaScript that runs in modern browsers, and [lit-analyzer](https://www.npmjs.com/package/lit-analyzer), a program that type-checks and lints lit-html templates.
|
This sample uses the TypeScript compiler to produce JavaScript that runs in modern browsers.
|
||||||
|
|
||||||
To build the JavaScript version of your component:
|
To build the JavaScript version of your component:
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ npm test
|
|||||||
|
|
||||||
## Dev Server
|
## Dev Server
|
||||||
|
|
||||||
This sample uses [ES dev server](https://github.com/open-wc/open-wc/tree/master/packages/es-dev-server) for previewing the project without additional build steps. ES dev server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers.
|
This sample uses open-wc's [es-dev-server](https://github.com/open-wc/open-wc/tree/master/packages/es-dev-server) for previewing the project without additional build steps. ES dev server handles resolving Node-style "bare" import specifiers, which aren't supported in browsers. It also automatically transpiles JavaScript and adds polyfills to support older browsers.
|
||||||
|
|
||||||
To run the dev server and open the project in a new browser tab:
|
To run the dev server and open the project in a new browser tab:
|
||||||
|
|
||||||
@@ -48,6 +48,18 @@ To run the dev server and open the project in a new browser tab:
|
|||||||
npm run serve
|
npm run serve
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Linting
|
||||||
|
|
||||||
|
Linting of TypeScript files is provided by [ESLint](eslint.org) and [TypeScript ESLint](https://github.com/typescript-eslint/typescript-eslint). In addition, [lit-analyzer](https://www.npmjs.com/package/lit-analyzer) is used to type-check and lint lit-html templates.
|
||||||
|
|
||||||
|
The rules are mostly the recommended rules from each project, but some have been turned off to make LitElement usage easier. The recommended rules are pretty strict, so you may want to relax them by editing `.eslintrc.json` and `tsconfig.json`.
|
||||||
|
|
||||||
|
To lint the project run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run lint
|
||||||
|
```
|
||||||
|
|
||||||
## More information
|
## More information
|
||||||
|
|
||||||
See [Get started](https://lit-element.polymer-project.org/guide/start) on the LitElement site for more information.
|
See [Get started](https://lit-element.polymer-project.org/guide/start) on the LitElement site for more information.
|
||||||
|
|||||||
697
package-lock.json
generated
697
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -6,8 +6,9 @@
|
|||||||
"module": "my-element.js",
|
"module": "my-element.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "lit-analyzer && tsc",
|
"build": "tsc",
|
||||||
"build:watch": "tsc --watch",
|
"build:watch": "tsc --watch",
|
||||||
|
"lint": "lit-analyzer && eslint 'src/**/*.ts'",
|
||||||
"serve": "es-dev-server --app-index demo/index.html --node-resolve --watch --open",
|
"serve": "es-dev-server --app-index demo/index.html --node-resolve --watch --open",
|
||||||
"test": "karma start karma.conf.cjs",
|
"test": "karma start karma.conf.cjs",
|
||||||
"test:watch": "karma start karma.conf.cjs --auto-watch=true --single-run=false",
|
"test:watch": "karma start karma.conf.cjs --auto-watch=true --single-run=false",
|
||||||
@@ -29,9 +30,12 @@
|
|||||||
"@open-wc/testing-karma": "^3.2.19",
|
"@open-wc/testing-karma": "^3.2.19",
|
||||||
"@types/chai": "^4.2.7",
|
"@types/chai": "^4.2.7",
|
||||||
"@types/mocha": "^5.2.7",
|
"@types/mocha": "^5.2.7",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^2.12.0",
|
||||||
|
"@typescript-eslint/parser": "^2.12.0",
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.2.0",
|
||||||
"deepmerge": "^4.2.2",
|
"deepmerge": "^4.2.2",
|
||||||
"es-dev-server": "^1.23.1",
|
"es-dev-server": "^1.23.1",
|
||||||
|
"eslint": "^6.7.2",
|
||||||
"karma": "^4.4.1",
|
"karma": "^4.4.1",
|
||||||
"karma-chai": "^0.1.0",
|
"karma-chai": "^0.1.0",
|
||||||
"karma-mocha": "^1.3.0",
|
"karma-mocha": "^1.3.0",
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export class MyElement extends LitElement {
|
|||||||
@property({type: Number})
|
@property({type: Number})
|
||||||
count = 0;
|
count = 0;
|
||||||
|
|
||||||
render(){
|
render() {
|
||||||
return html`
|
return html`
|
||||||
<h1>Hello, ${this.name}!</h1>
|
<h1>Hello, ${this.name}!</h1>
|
||||||
<button @click=${this._onClick}>Click Count: ${this.count}</button>
|
<button @click=${this._onClick}>Click Count: ${this.count}</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user