Skip to content

Commit fc74010

Browse files
committed
chore: add eslint and prettier cmd
1 parent f404071 commit fc74010

File tree

6 files changed

+750
-29
lines changed

6 files changed

+750
-29
lines changed

.eslintignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.github
2+
bin
3+
playground
4+
src/__tests__
5+
transformations/__testfixtures__
6+
transformations/__tests__
7+
vue-transformations/__testfixtures__
8+
vue-transformations/__tests__
9+
.editorconfig
10+
.eslintignore
11+
.eslintrc.js
12+
.gitignore
13+
.prettierignore
14+
.prettierrc
15+
LICENSE
16+
package.json
17+
README.md
18+
tsconfig.json
19+
yarn.lock

.eslintrc.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const DOMGlobals = ['window', 'document']
2+
const NodeGlobals = ['module', 'require']
3+
4+
module.exports = {
5+
parser: '@typescript-eslint/parser',
6+
parserOptions: {
7+
sourceType: 'module'
8+
},
9+
rules: {
10+
'no-unused-vars': [
11+
'error',
12+
// we are only using this rule to check for unused arguments since TS
13+
// catches unused variables but not args.
14+
{ varsIgnorePattern: '.*', args: 'none' }
15+
],
16+
// since we target ES2015 for baseline support, we need to forbid object
17+
// rest spread usage (both assign and destructure)
18+
'no-restricted-syntax': [
19+
'error',
20+
'ObjectExpression > SpreadElement',
21+
'ObjectPattern > RestElement'
22+
]
23+
},
24+
overrides: [
25+
// tests, no restrictions (runs in Node / jest with jsdom)
26+
{
27+
files: ['**/__tests__/**', 'test-dts/**'],
28+
rules: {
29+
'no-restricted-globals': 'off',
30+
'no-restricted-syntax': 'off'
31+
}
32+
},
33+
// shared, may be used in any env
34+
{
35+
files: ['packages/shared/**'],
36+
rules: {
37+
'no-restricted-globals': 'off'
38+
}
39+
},
40+
// Packages targeting DOM
41+
{
42+
files: ['packages/{vue,vue-compat,runtime-dom}/**'],
43+
rules: {
44+
'no-restricted-globals': ['error', ...NodeGlobals]
45+
}
46+
},
47+
// Packages targeting Node
48+
{
49+
files: ['packages/{compiler-sfc,compiler-ssr,server-renderer}/**'],
50+
rules: {
51+
'no-restricted-globals': ['error', ...DOMGlobals],
52+
'no-restricted-syntax': 'off'
53+
}
54+
},
55+
// Private package, browser only + no syntax restrictions
56+
{
57+
files: ['packages/template-explorer/**', 'packages/sfc-playground/**'],
58+
rules: {
59+
'no-restricted-globals': ['error', ...NodeGlobals],
60+
'no-restricted-syntax': 'off'
61+
}
62+
}
63+
]
64+
}

.prettierignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.github
2+
bin
3+
playground
4+
src/__tests__
5+
transformations/__testfixtures__
6+
transformations/__tests__
7+
vue-transformations/__testfixtures__
8+
vue-transformations/__tests__
9+
.editorconfig
10+
.eslintignore
11+
.eslintrc.js
12+
.gitignore
13+
.prettierignore
14+
.prettierrc
15+
LICENSE
16+
package.json
17+
README.md
18+
tsconfig.json
19+
yarn.lock

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
semi: false
2+
singleQuote: true
3+
printWidth: 80
4+
trailingComma: 'none'
5+
endOfLine: 'lf'
6+
arrowParens: 'avoid'

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
"build": "tsc",
1313
"prepublishOnly": "tsc",
1414
"playground": "npm run build && cd ./playground && npm install && npm run dev",
15-
"test": "jest"
15+
"test": "jest",
16+
"fix": "npm-run-all --parallel lint:fix format:fix",
17+
"lint:codes": "eslint . --ext .ts",
18+
"lint:fix": "npm run lint:codes --fix",
19+
"format:prettier": "prettier --config .prettierrc .",
20+
"format:fix": "prettier --write --config .prettierrc ."
1621
},
1722
"repository": {
1823
"type": "git",
@@ -43,8 +48,11 @@
4348
"@types/lodash": "^4.14.170",
4449
"@types/node": "^12.12.47",
4550
"@types/yargs": "^15.0.4",
51+
"@typescript-eslint/parser": "^4.27.0",
52+
"eslint": "^7.29.0",
4653
"jest": "^26.1.0",
47-
"prettier": "^2.0.4",
54+
"npm-run-all": "^4.1.5",
55+
"prettier": "^2.3.1",
4856
"ts-jest": "^26.1.1",
4957
"typescript": "^4.1.3"
5058
},
@@ -56,10 +64,6 @@
5664
"<rootDir>/node_modules/"
5765
]
5866
},
59-
"prettier": {
60-
"semi": false,
61-
"singleQuote": true
62-
},
6367
"engines": {
6468
"node": ">= 10.0"
6569
}

0 commit comments

Comments
 (0)