Skip to content

Commit 57515d7

Browse files
committed
Lint and print
1 parent 53ca85e commit 57515d7

File tree

9 files changed

+424
-147
lines changed

9 files changed

+424
-147
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.eslintcache
22
/coverage/
3+
/dist/
34
/node_modules/

.npmignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.*
22
bin/
3+
src/
34
test/

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.github/
22
/coverage/
3+
/dist/
34
/.eslintcache
45
/.*ignore
56
/yarn.lock

package.json

+15-11
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"name": "@prettier/plugin-xml",
33
"version": "0.13.1",
44
"description": "prettier plugin for XML",
5-
"main": "src/plugin.js",
5+
"main": "dist/src/plugin.js",
66
"scripts": {
77
"lint": "eslint --cache .",
8+
"prepublishOnly": "tsc -p tsconfig.build.json",
89
"print": "prettier --plugin=.",
910
"test": "jest"
1011
},
@@ -24,7 +25,10 @@
2425
},
2526
"devDependencies": {
2627
"@types/jest": "^26.0.23",
28+
"@types/node": "^15.6.1",
2729
"@types/prettier": "^2.2.3",
30+
"@typescript-eslint/eslint-plugin": "^4.26.0",
31+
"@typescript-eslint/parser": "^4.26.0",
2832
"eslint": "^7.0.0",
2933
"eslint-config-prettier": "^8.0.0",
3034
"jest": "^27.0.1",
@@ -35,31 +39,31 @@
3539
"eslintConfig": {
3640
"extends": [
3741
"eslint:recommended",
42+
"plugin:@typescript-eslint/recommended",
3843
"prettier"
3944
],
4045
"env": {
4146
"es6": true,
4247
"jest": true,
4348
"node": true
4449
},
45-
"parserOptions": {
46-
"ecmaVersion": 2018
47-
},
50+
"parser": "@typescript-eslint/parser",
4851
"rules": {
49-
"no-unused-vars": [
50-
"error",
51-
{
52-
"argsIgnorePattern": "^_",
53-
"varsIgnorePattern": "^_"
54-
}
55-
]
52+
"@typescript-eslint/no-explicit-any": "off",
53+
"@typescript-eslint/no-non-null-assertion": "off"
5654
}
5755
},
56+
"eslintIgnore": [
57+
"dist"
58+
],
5859
"jest": {
5960
"preset": "ts-jest",
6061
"testRegex": ".test.ts$"
6162
},
6263
"prettier": {
64+
"plugins": [
65+
"."
66+
],
6367
"trailingComma": "none"
6468
}
6569
}

src/embed.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ function replaceNewlines(doc: Doc) {
3131
}
3232

3333
// Get the start and end element tags from the current node on the tree
34-
function getElementTags(path: FastPath<XMLAST>, print: (path: FastPath<XMLAST>) => Doc) {
34+
function getElementTags(
35+
path: FastPath<XMLAST>,
36+
print: (path: FastPath<XMLAST>) => Doc
37+
) {
3538
const node = path.getValue() as ElementCstNode;
3639
const { OPEN, Name, attribute, START_CLOSE, SLASH_OPEN, END_NAME, END } =
3740
node.children;
@@ -52,7 +55,7 @@ function getElementTags(path: FastPath<XMLAST>, print: (path: FastPath<XMLAST>)
5255
concat([SLASH_OPEN[0].image, END_NAME[0].image, END[0].image])
5356
)
5457
};
55-
};
58+
}
5659

5760
// Get the name of the parser that is represented by the given element node,
5861
// return null if a matching parser cannot be found

src/parser.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { parse as xmlToolsParse } from "@xml-tools/parser";
44
const parser: Parser = {
55
parse(text) {
66
const { lexErrors, parseErrors, cst } = xmlToolsParse(text);
7-
7+
88
if (lexErrors.length > 0 || parseErrors.length > 0) {
99
throw Error("Error parsing XML");
1010
}
11-
11+
1212
return cst;
1313
},
1414
astFormat: "xml",

0 commit comments

Comments
 (0)