Skip to content

Commit c1537a5

Browse files
author
LongYinan
committed
style: add format command and apply it
1 parent 62816f2 commit c1537a5

File tree

11 files changed

+105
-104
lines changed

11 files changed

+105
-104
lines changed

.eslintrc.yml

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ globals:
1717
plugins:
1818
- import
1919
- sonarjs
20-
20+
2121
extends:
2222
- eslint:recommended
2323
- plugin:sonarjs/recommended
@@ -28,10 +28,10 @@ settings:
2828
pragma: React
2929
version: 16.12.0
3030

31-
rules:
31+
rules:
3232
# 0 = off, 1 = warn, 2 = error
3333
'no-undef': 2
34-
'no-console': [2, { allow: ['error', 'warn', 'info', 'assert']}]
34+
'no-console': [2, { allow: ['error', 'warn', 'info', 'assert'] }]
3535
'comma-dangle': ['error', 'only-multiline']
3636
'no-unused-vars': 0
3737
'no-var': 2
@@ -42,10 +42,14 @@ rules:
4242
'no-use-before-define': [2, { 'functions': false, 'classes': false }]
4343
'eqeqeq': [2, 'always', { 'null': 'ignore' }]
4444
'no-case-declarations': 0
45-
'no-restricted-syntax': [2, {
46-
'selector': 'BinaryExpression[operator=/(==|===|!=|!==)/][left.raw=true], BinaryExpression[operator=/(==|===|!=|!==)/][right.raw=true]',
47-
'message': Don't compare for equality against boolean literals
48-
}]
45+
'no-restricted-syntax':
46+
[
47+
2,
48+
{
49+
'selector': 'BinaryExpression[operator=/(==|===|!=|!==)/][left.raw=true], BinaryExpression[operator=/(==|===|!=|!==)/][right.raw=true]',
50+
'message': Don't compare for equality against boolean literals,
51+
},
52+
]
4953

5054
'import/first': 2
5155
'import/newline-after-import': 2
@@ -57,14 +61,12 @@ rules:
5761
'sonarjs/no-small-switch': 0
5862

5963
overrides:
60-
-
61-
files:
64+
- files:
6265
- packages/**/*.ts
6366
rules:
6467
'no-unused-vars': [2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
65-
66-
-
67-
files:
68+
69+
- files:
6870
- packages/**/*.ts
6971
plugins:
7072
- '@typescript-eslint'
@@ -84,23 +86,29 @@ overrides:
8486

8587
'@typescript-eslint/no-empty-function': 2
8688

87-
'@typescript-eslint/no-unused-vars': [2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
88-
'@typescript-eslint/member-ordering': [2, {
89-
default: [
90-
'public-static-field',
91-
'protected-static-field',
92-
'private-static-field',
93-
'public-static-method',
94-
'protected-static-method',
95-
'private-static-method',
96-
'public-instance-field',
97-
'protected-instance-field',
98-
'private-instance-field',
99-
'public-constructor',
100-
'protected-constructor',
101-
'private-constructor',
102-
'public-instance-method',
103-
'protected-instance-method',
104-
'private-instance-method'
89+
'@typescript-eslint/no-unused-vars':
90+
[2, { varsIgnorePattern: '^_', argsIgnorePattern: '^_', ignoreRestSiblings: true }]
91+
'@typescript-eslint/member-ordering':
92+
[
93+
2,
94+
{
95+
default:
96+
[
97+
'public-static-field',
98+
'protected-static-field',
99+
'private-static-field',
100+
'public-static-method',
101+
'protected-static-method',
102+
'private-static-method',
103+
'public-instance-field',
104+
'protected-instance-field',
105+
'private-instance-field',
106+
'public-constructor',
107+
'protected-constructor',
108+
'private-constructor',
109+
'public-instance-method',
110+
'protected-instance-method',
111+
'private-instance-method',
112+
],
113+
},
105114
]
106-
}]

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
target
2+
node_modules
3+
lib

lerna.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"packages": [
3-
"packages/*"
4-
],
2+
"packages": ["packages/*"],
53
"npmClient": "yarn",
64
"useWorkspaces": true,
75
"version": "independent"

package.json

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@
66
"author": "LongYinan <[email protected]>",
77
"license": "MIT",
88
"private": true,
9-
"workspaces": [
10-
"packages/*"
11-
],
9+
"workspaces": ["packages/*"],
1210
"scripts": {
1311
"lint": "eslint . -c ./.eslintrc.yml 'packages/**/*.{ts,js}'",
1412
"test": "ava",
13+
"format": "run-p format:md format:json format:yaml format:source",
14+
"format:md": "prettier --parser markdown --write './**/*.md'",
15+
"format:json": "prettier --parser json --write './**/*.json'",
16+
"format:source": "prettier --config ./package.json --write './**/*.{js,ts}'",
17+
"format:yaml": "prettier --parser yaml --write './**/*.{yml,yaml}'",
1518
"typecheck": "tsc -b tsconfig.project.json -verbose"
1619
},
1720
"devDependencies": {
@@ -30,35 +33,23 @@
3033
"lerna": "^3.20.2",
3134
"lint-staged": "^10.1.7",
3235
"napi-rs": "^0.2.3",
36+
"npm-run-all": "^4.1.5",
3337
"nyc": "^15.0.1",
3438
"prettier": "^2.0.5",
3539
"ts-node": "^8.9.1",
3640
"tsconfig-paths": "^3.9.0",
3741
"typescript": "^3.8.3"
3842
},
3943
"ava": {
40-
"extensions": [
41-
"ts"
42-
],
43-
"require": [
44-
"ts-node/register",
45-
"tsconfig-paths/register"
46-
],
47-
"files": [
48-
"packages/**/*.spec.ts"
49-
]
44+
"extensions": ["ts"],
45+
"require": ["ts-node/register", "tsconfig-paths/register"],
46+
"files": ["packages/**/*.spec.ts"]
5047
},
5148
"lint-staged": {
52-
"*.@(js|ts|tsx)": [
53-
"prettier --write",
54-
"eslint -c .eslintrc.yml --fix"
55-
],
56-
"*.@(yml|yaml)": [
57-
"prettier --parser yaml --write"
58-
],
59-
"*.md": [
60-
"prettier --parser markdown --write"
61-
]
49+
"*.@(js|ts|tsx)": ["prettier --write", "eslint -c .eslintrc.yml --fix"],
50+
"*.@(yml|yaml)": ["prettier --parser yaml --write"],
51+
"*.json": ["prettier --parser json --write"],
52+
"*.md": ["prettier --parser markdown --write"]
6253
},
6354
"prettier": {
6455
"printWidth": 120,

packages/crc32/package.json

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,13 @@
22
"name": "@node-rs/crc32",
33
"version": "0.0.0",
44
"description": "SIMD crc32",
5-
"keywords": [
6-
"SIMD",
7-
"NAPI",
8-
"napi-rs",
9-
"node-rs",
10-
"crc32",
11-
"crc32c"
12-
],
5+
"keywords": ["SIMD", "NAPI", "napi-rs", "node-rs", "crc32", "crc32c"],
136
"author": "LongYinan <[email protected]>",
147
"homepage": "https://github.com/Brooooooklyn/node-rs",
158
"license": "MIT",
169
"main": "index.js",
1710
"typings": "index.d.ts",
18-
"files": [
19-
"index.js",
20-
"index.d.ts",
21-
"index.*.node",
22-
"LICENSE",
23-
"COPYING"
24-
],
11+
"files": ["index.js", "index.d.ts", "index.*.node", "LICENSE", "COPYING"],
2512
"repository": {
2613
"type": "git",
2714
"url": "git+https://github.com/Brooooooklyn/node-rs.git"

packages/helper/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## Usage
66

77
### locateBinding
8+
89
Load native binding file from `dirname`
910

1011
```ts

packages/helper/package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,13 @@
22
"name": "@node-rs/helper",
33
"version": "0.0.0",
44
"description": "Helper library for node-rs",
5-
"keywords": [
6-
"N-API",
7-
"napi",
8-
"Rust",
9-
"Performance"
10-
],
5+
"keywords": ["N-API", "napi", "Rust", "Performance"],
116
"author": "LongYinan <[email protected]>",
127
"homepage": "https://github.com/brooooooklyn/node-rs",
138
"license": "MIT",
149
"main": "lib/index.js",
1510
"typings": "lib/index.d.ts",
16-
"files": [
17-
"lib"
18-
],
11+
"files": ["lib"],
1912
"repository": {
2013
"type": "git",
2114
"url": "git+https://github.com/Brooooooklyn/node-rs.git"

packages/helper/tsconfig.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
"rootDir": "./src",
66
"composite": true
77
},
8-
"include": [
9-
"./src"
10-
]
8+
"include": ["./src"]
119
}

tsconfig.json

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,9 @@
2626
"importsNotUsedAsValues": "remove",
2727
"baseUrl": "./packages",
2828
"paths": {
29-
"@node-rs/*": [
30-
"./*/src"
31-
]
29+
"@node-rs/*": ["./*/src"]
3230
},
33-
"lib": [
34-
"dom",
35-
"ES5",
36-
"ES2015",
37-
"ES2016",
38-
"ES2017",
39-
"ES2018",
40-
"ES2019",
41-
"ES2020",
42-
"esnext"
43-
]
31+
"lib": ["dom", "ES5", "ES2015", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020", "esnext"]
4432
},
45-
"exclude": [
46-
"node_modules"
47-
]
33+
"exclude": ["node_modules"]
4834
}

tsconfig.project.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"references": [
3-
{ "path": "./packages/helper" }
4-
],
2+
"references": [{ "path": "./packages/helper" }],
53
"compilerOptions": {
64
"noEmit": true
75
}

0 commit comments

Comments
 (0)