Skip to content

Commit bba9e90

Browse files
committed
feat: add func-style
1 parent ffeac49 commit bba9e90

File tree

5 files changed

+60
-62
lines changed

5 files changed

+60
-62
lines changed

.prettierrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const { prettier } = require('prefer-code-style')
2+
13
module.exports = {
2-
...require('./lib').prettier,
4+
...prettier,
35
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
"lib"
2424
],
2525
"scripts": {
26+
"prebuild": "rimraf ./lib/",
2627
"build": "tsc --build tsconfig.json",
2728
"prepublishOnly": "yarn build",
29+
"deps": "yarn upgrade-interactive --latest",
2830
"lint": "yarn lint:es",
2931
"lint:es": "eslint --ignore-path \"./.eslintignore\" \"./**/*.{js,jsx,ts,tsx}\"",
3032
"test": "echo \"Error: no test specified\" && exit 1"
@@ -58,6 +60,7 @@
5860
},
5961
"devDependencies": {
6062
"cz-conventional-changelog": "3.3.0",
61-
"typescript": "^4.3.5"
63+
"rimraf": "^3.0.2",
64+
"typescript": "^4.4.2"
6265
}
6366
}

src/eslint.ts

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -5,65 +5,59 @@ const IS_TS_PROJECT = fs.existsSync(
55
path.join(process.cwd() || '.', './tsconfig.json')
66
)
77

8-
const parser = IS_TS_PROJECT
9-
? '@typescript-eslint/parser'
10-
: '@babel/eslint-parser'
11-
12-
const _extends = (() => {
13-
return [
14-
'eslint:recommended',
15-
IS_TS_PROJECT ? 'plugin:@typescript-eslint/recommended' : null,
16-
'plugin:import/errors',
17-
'plugin:import/warnings',
18-
'plugin:import/typescript',
19-
'plugin:jsx-a11y/recommended',
20-
'plugin:react/recommended',
21-
'plugin:react-hooks/recommended',
22-
'plugin:prettier/recommended',
23-
].filter((ext) => ext && typeof ext === 'string')
24-
})()
25-
26-
const rules = {
27-
'simple-import-sort/imports': 1,
28-
'simple-import-sort/exports': 1,
29-
'sort-imports': 0,
30-
'import/order': 0,
31-
'react/jsx-sort-props': [
32-
2,
33-
{
34-
callbacksLast: true,
35-
shorthandFirst: true,
36-
shorthandLast: false,
37-
ignoreCase: false,
38-
noSortAlphabetically: false,
39-
reservedFirst: true,
40-
},
41-
],
42-
...(IS_TS_PROJECT
43-
? {
44-
'@typescript-eslint/no-var-requires': 0,
45-
'@typescript-eslint/no-non-null-assertion': 0,
46-
'@typescript-eslint/no-use-before-define': 2,
47-
'@typescript-eslint/explicit-module-boundary-types': 0,
48-
'@typescript-eslint/consistent-type-imports': [
49-
2,
50-
{
51-
prefer: 'type-imports',
52-
disallowTypeAnnotations: true,
53-
},
54-
],
55-
}
56-
: {}),
57-
}
58-
598
module.exports = {
609
env: {
6110
node: true,
6211
browser: true,
6312
es6: true,
6413
},
65-
parser,
66-
extends: _extends,
14+
parser: IS_TS_PROJECT ? '@typescript-eslint/parser' : '@babel/eslint-parser',
15+
extends: (() =>
16+
[
17+
'eslint:recommended',
18+
IS_TS_PROJECT ? 'plugin:@typescript-eslint/recommended' : null,
19+
'plugin:import/errors',
20+
'plugin:import/warnings',
21+
'plugin:import/typescript',
22+
'plugin:jsx-a11y/recommended',
23+
'plugin:react/recommended',
24+
'plugin:react-hooks/recommended',
25+
'plugin:prettier/recommended',
26+
].filter((ext) => ext && typeof ext === 'string')
27+
)(),
6728
plugins: ['simple-import-sort'],
68-
rules,
29+
rules: {
30+
'simple-import-sort/imports': 1,
31+
'simple-import-sort/exports': 1,
32+
'sort-imports': 0,
33+
'import/order': 0,
34+
'react/jsx-sort-props': [
35+
2,
36+
{
37+
callbacksLast: true,
38+
shorthandFirst: true,
39+
shorthandLast: false,
40+
ignoreCase: false,
41+
noSortAlphabetically: false,
42+
reservedFirst: true,
43+
},
44+
],
45+
'func-style': [2, 'declaration', { allowArrowFunctions: true }],
46+
47+
...(IS_TS_PROJECT
48+
? {
49+
'@typescript-eslint/no-var-requires': 0,
50+
'@typescript-eslint/no-non-null-assertion': 0,
51+
'@typescript-eslint/no-use-before-define': 2,
52+
'@typescript-eslint/explicit-module-boundary-types': 0,
53+
'@typescript-eslint/consistent-type-imports': [
54+
2,
55+
{
56+
prefer: 'type-imports',
57+
disallowTypeAnnotations: true,
58+
},
59+
],
60+
}
61+
: {}),
62+
},
6963
}

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"strict": true,
88
"esModuleInterop": true,
99
"skipLibCheck": true,
10-
"declaration": true,
1110
"forceConsistentCasingInFileNames": true
1211
},
1312
"include": ["src/*.ts"]

yarn.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4077,7 +4077,7 @@ [email protected]:
40774077

40784078
rimraf@^3.0.2:
40794079
version "3.0.2"
4080-
resolved "https://registry.npm.taobao.org/rimraf/download/rimraf-3.0.2.tgz?cache=0&sync_timestamp=1614946161596&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Frimraf%2Fdownload%2Frimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
4080+
resolved "https://registry.npm.taobao.org/rimraf/download/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
40814081
integrity sha1-8aVAK6YiCtUswSgrrBrjqkn9Bho=
40824082
dependencies:
40834083
glob "^7.1.3"
@@ -4805,10 +4805,10 @@ typedarray-to-buffer@^3.1.5:
48054805
dependencies:
48064806
is-typedarray "^1.0.0"
48074807

4808-
typescript@^4.3.5:
4809-
version "4.3.5"
4810-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4"
4811-
integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==
4808+
typescript@^4.4.2:
4809+
version "4.4.2"
4810+
resolved "https://registry.nlark.com/typescript/download/typescript-4.4.2.tgz?cache=0&sync_timestamp=1630012140746&other_urls=https%3A%2F%2Fregistry.nlark.com%2Ftypescript%2Fdownload%2Ftypescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
4811+
integrity sha1-bWGGQNQw41aaHftE99fmAM7T7oY=
48124812

48134813
unbox-primitive@^1.0.0, unbox-primitive@^1.0.1:
48144814
version "1.0.1"

0 commit comments

Comments
 (0)