Skip to content

Commit 9224e2c

Browse files
committed
Add eslint
1 parent ea2b061 commit 9224e2c

27 files changed

+649
-54
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/*.html
2+
coverage
3+
yarn.lock
4+
dist
5+
node_modules
6+
**/*.js

.eslintrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
3+
parser: "@typescript-eslint/parser",
4+
plugins: ["@typescript-eslint"],
5+
root: true,
6+
rules: {
7+
"@typescript-eslint/no-non-null-assertion": "off",
8+
"@typescript-eslint/no-non-null-asserted-optional-chain": "off",
9+
"@typescript-eslint/no-unused-vars": "error",
10+
"@typescript-eslint/no-explicit-any": "off",
11+
},
12+
overrides: [
13+
{
14+
files: ["**/__tests__/**/*.ts"],
15+
rules: {
16+
"@typescript-eslint/no-explicit-any": "off",
17+
},
18+
},
19+
],
20+
};

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,20 @@
88
"test": "jest --coverage",
99
"format": "prettier --write .",
1010
"build": "rimraf dist && tsc -b tsconfig.build.json",
11+
"check:lint": "eslint src",
1112
"check:ts": "tsc --noEmit",
1213
"check:format": "prettier --list-different .",
13-
"prepublish": "yarn check:ts && yarn check:format && yarn build"
14+
"prepublish": "yarn check:lint && yarn check:ts && yarn check:format && yarn build"
1415
},
1516
"devDependencies": {
1617
"@types/jest": "^28.1.7",
18+
"@typescript-eslint/eslint-plugin": "^5.36.1",
19+
"@typescript-eslint/parser": "^5.36.1",
20+
"eslint": "^8.23.0",
1721
"jest": "^28.1.3",
1822
"prettier": "^2.7.1",
1923
"rimraf": "^3.0.2",
2024
"ts-jest": "^28.0.8",
21-
"typescript": "^4.7.4"
25+
"typescript": "^4.8.2"
2226
}
2327
}

src/constants/node-types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { TokenTypes } from "./token-types";
2-
31
export enum NodeTypes {
42
Document = "Document",
53
Tag = "Tag",

src/tokenizer/handlers/style-tag-content.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import {
44
TokenTypes,
55
} from "../../constants";
66
import { Range, Token, TokenizerState } from "../../types";
7-
import {
8-
calculateTokenLocation,
9-
calculateTokenPosition,
10-
getLineInfo,
11-
} from "../../utils";
7+
import { calculateTokenLocation, calculateTokenPosition } from "../../utils";
128

139
const CLOSING_STYLE_TAG_PATTERN = /<\/style\s*>/i;
1410

src/tokenizer/tokenize.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const contextHandlers: Record<TokenizerContextTypes, TokenizeHandler> = {
4747
function tokenizeChars(
4848
chars: string,
4949
state: TokenizerState,
50-
tokens: any[],
50+
tokens: Token[],
5151
{
5252
isFinalChunk,
5353
positionOffset,
@@ -108,7 +108,7 @@ export function tokenize(
108108
}
109109

110110
const chars = state.decisionBuffer + source;
111-
const tokens: any[] = [];
111+
const tokens: Token[] = [];
112112
const positionOffset = state.caretPosition - state.decisionBuffer.length;
113113

114114
tokenizeChars(chars, state, tokens, {

src/tree-constructor/__tests__/__output__/attributes-empty.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { NodeTypes } from "../../../constants";
2-
31
export default {
42
type: "Document",
53
range: [0, 100],

src/tree-constructor/__tests__/__output__/custom-elements.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { NodeTypes } from "../../../constants";
2-
31
export default {
42
type: "Document",
53
range: [0, 88],

src/tree-constructor/__tests__/__output__/doctypes.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { NodeTypes } from "../../../constants";
2-
31
export default {
42
type: "Document",
53
range: [0, 304],

src/tree-constructor/__tests__/__output__/nested-tags.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { NodeTypes } from "../../../constants";
2-
31
export default {
42
type: "Document",
53
range: [0, 89],

0 commit comments

Comments
 (0)