├── .gitignore
├── .prettierignore
├── .npmrc
├── logo.png
├── image.png
├── commitlint.config.js
├── .eslintignore
├── .editorconfig
├── eslintrc.vue.js
├── CHANGELOG.md
├── README.md
├── .prettierrc.js
├── eslintrc.react.js
├── eslintrc.rn.js
├── eslintrc.node.js
├── js-ts-common.rule.js
├── tsconfig.json
├── eslintrc.javascript-base.js
├── LICENSE
├── eslintrc.typescript-base.js
└── package.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | coverage
3 | dist
4 | node_modules
5 | release
6 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | engine-strict=true
2 | auth-token=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
3 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fengyinchao/fe-standard-config-seed/HEAD/logo.png
--------------------------------------------------------------------------------
/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fengyinchao/fe-standard-config-seed/HEAD/image.png
--------------------------------------------------------------------------------
/commitlint.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ['@commitlint/config-conventional'],
3 | };
4 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | .vscode
2 | coverage
3 | dist
4 | node_modules
5 | release
6 |
7 | commitlint.config.js
8 |
9 | .cz-config.js
10 | .eslintrc.js
11 | .prettierrc.js
12 | .stylelintrc.js
13 | .versionrc.js
14 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | insert_final_newline = true
8 | end_of_line = lf
9 |
10 | [*.spec.ts.snap]
11 | trim_trailing_whitespace = false
12 | insert_final_newline = false
13 |
--------------------------------------------------------------------------------
/eslintrc.vue.js:
--------------------------------------------------------------------------------
1 | // https://www.npmjs.com/package/eslint-plugin-vue
2 | module.exports = {
3 | extends: [
4 | 'plugin:vue/vue3-recommended',
5 | 'plugin:vue/recommended', // Use this if you are using Vue.js 2.x.
6 | ],
7 | rules: {
8 | 'vue/no-unused-vars': 'error',
9 | },
10 | };
11 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 1.1.7 (2022/08/15 冯银超)
2 |
3 | - 更新依赖以兼容 node 10 版本
4 |
5 | ## 1.1.5 (2022/08/05 冯银超)
6 |
7 | - 更新依赖
8 |
9 | ## 1.1.3 (2022/08/05 冯银超)
10 |
11 | - 更新 eslintrc.typescript-base.js 和 js-ts-common.rule.js
12 |
13 | ## 1.1.2 (2022/08/05 冯银超)
14 |
15 | - 更新 eslintrc.typescript-base.js
16 |
17 | ## 1.1.1 (2022/08/05 冯银超)
18 |
19 | - eslintrc.rn.js bug 修复
20 |
21 | ## 1.1.0 (2022/08/04 冯银超)
22 |
23 | - ESLint 通用规则集
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |

2 |
3 | # fed-standard-config
4 |
5 | ## FED 最新代码规范 2022
6 |
7 | [FED 前端代码规范](https://www.yuque.com/fengyinchao/awb51o/ksm7sc/edit)
8 |
9 | ## 接入指南
10 |
11 | 1、项目目录安装依赖 yarn add --dev @fengyinchao/eslint-config-fed
12 |
13 | 2、安装 vscode 插件:vscode-plugin-fed-tools
14 |
15 | 3、然后按下图操作即可:
16 | 
17 |
18 | ## License
19 |
20 | MIT
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | // 更多配置:https://prettier.io/docs/en/options.html
2 |
3 | module.exports = {
4 | printWidth: 120, // 一行最大宽度,超过自动折行
5 | semi: true, // 语句后加分号
6 | singleQuote: true, // 使用单引号
7 | quoteProps: 'as-needed', // 对象中的属性按需加引号
8 | trailingComma: 'all', // 使用冗余逗号
9 | bracketSpacing: true, // 对象左右括号里使用空格
10 | arrowParens: 'avoid', // 箭头函数单参数时不用加括号
11 | htmlWhitespaceSensitivity: 'css', // html内联元素空格处理,ignore忽略前后空格,css
12 | endOfLine: 'lf',
13 | };
14 |
--------------------------------------------------------------------------------
/eslintrc.react.js:
--------------------------------------------------------------------------------
1 | // https://www.npmjs.com/package/eslint-plugin-react-hooks
2 | // https://github.com/jsx-eslint/eslint-plugin-react
3 | module.exports = {
4 | extends: ['plugin:react/recommended', 'plugin:react-hooks/recommended'],
5 | plugins: ['react', 'react-hooks'],
6 | rules: {
7 | 'react/sort-comp': 'off', // 生命周期等要按顺序写
8 | 'react-hooks/rules-of-hooks': 'error', // hook 不能写在分支里
9 | 'react-hooks/exhaustive-deps': 'warn', // effect 等依赖检测
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/eslintrc.rn.js:
--------------------------------------------------------------------------------
1 | // https://www.npmjs.com/package/eslint-plugin-react-native
2 | module.exports = {
3 | env: {
4 | 'react-native/react-native': true,
5 | },
6 | extends: ['plugin:react-native/all'],
7 | plugins: ['react-native'],
8 | rules: {
9 | 'react-native/no-unused-styles': 'error',
10 | 'react-native/no-inline-styles': 'warn',
11 | 'react-native/no-raw-text': 'error',
12 | 'react-native/no-single-element-style-arrays': 'error',
13 | },
14 | };
15 |
--------------------------------------------------------------------------------
/eslintrc.node.js:
--------------------------------------------------------------------------------
1 | // https://github.com/mysticatea/eslint-plugin-node
2 | module.exports = {
3 | env: {
4 | node: true,
5 | },
6 | extends: ['plugin:node/recommended'],
7 | plugins: ['node'],
8 | rules: {
9 | 'node/exports-style': ['error', 'module.exports'],
10 | 'node/prefer-global/buffer': ['error', 'always'],
11 | 'node/prefer-global/console': ['error', 'always'],
12 | 'node/prefer-global/process': ['error', 'always'],
13 | 'node/prefer-global/url-search-params': ['error', 'always'],
14 | 'node/prefer-global/url': ['error', 'always'],
15 | },
16 | };
17 |
--------------------------------------------------------------------------------
/js-ts-common.rule.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | 'no-nested-ternary': 'off', // 允许嵌套的三元表达式
3 | 'prettier/prettier': 'error',
4 | 'no-use-before-define': ['error', { functions: false, classes: false }], // 先定义后使用,函数和类除外
5 | 'consistent-return': 'off', // return 类型要一致
6 | 'max-classes-per-file': 'off', // 一个文件只有一个类
7 | 'no-console': 'warn',
8 | 'no-shadow': 'off',
9 | 'max-lines': ['error', 300], // 单文件不超过300行,
10 | 'no-plusplus': 'off',
11 | '@fengyinchao/custom/file-header-annotation': 'error',
12 | 'import/extensions': [
13 | 'error',
14 | 'ignorePackages',
15 | {
16 | js: 'never',
17 | jsx: 'never',
18 | ts: 'never',
19 | tsx: 'never',
20 | },
21 | ],
22 | };
23 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "baseUrl": "./",
5 | "outDir": "./dist",
6 | "module": "commonjs",
7 | "target": "es2015",
8 | "moduleResolution": "node",
9 | "composite": true,
10 | "sourceMap": true,
11 | "emitDecoratorMetadata": true,
12 | "experimentalDecorators": true,
13 | "importHelpers": true,
14 | "resolveJsonModule": true,
15 | "jsx": "react-jsxdev",
16 | "skipLibCheck": true,
17 | "allowSyntheticDefaultImports": true,
18 | "typeRoots": ["node_modules/@types"],
19 | "paths": {
20 | "common/*": ["src/common/*"]
21 | }
22 | },
23 | "include": ["src/*"],
24 | "exclude": ["./dist","node_modules"]
25 | }
26 |
--------------------------------------------------------------------------------
/eslintrc.javascript-base.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | parser: 'babel-eslint',
3 | env: {
4 | browser: true,
5 | es6: true,
6 | node: true,
7 | jest: true,
8 | },
9 | parserOptions: {
10 | sourceType: 'module',
11 | ecmaVersion: 2022,
12 | ecmaFeatures: {
13 | // 不允许 return 语句出现在 global 环境下
14 | globalReturn: false,
15 | // 开启全局 script 模式
16 | impliedStrict: true,
17 | // 允许 JSX
18 | jsx: true,
19 | },
20 | // 即使没有 babelrc 配置文件,也使用 babel-eslint 来解析
21 | requireConfigFile: false,
22 | },
23 | extends: ['eslint:recommended', 'eslint-config-airbnb-base', 'eslint-config-prettier'],
24 | plugins: ['prettier', 'import', 'deprecation', '@fengyinchao/custom'],
25 | rules: {
26 | ...require('./js-ts-common.rule'),
27 | },
28 | };
29 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 风之化身
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/eslintrc.typescript-base.js:
--------------------------------------------------------------------------------
1 | // https://typescript-eslint.io/rules/
2 | module.exports = {
3 | root: true,
4 | env: {
5 | browser: true,
6 | es6: true,
7 | node: true,
8 | jest: true,
9 | },
10 | parser: '@typescript-eslint/parser',
11 | parserOptions: {
12 | project: ['./tsconfig.json'],
13 | sourceType: 'module',
14 | },
15 | plugins: ['@typescript-eslint', 'prettier', '@fengyinchao/custom', 'import', 'deprecation'],
16 | extends: [
17 | 'eslint:recommended',
18 | 'plugin:@typescript-eslint/recommended',
19 | 'eslint-config-airbnb-base',
20 | 'eslint-config-prettier',
21 | ],
22 | rules: {
23 | ...require('./js-ts-common.rule'),
24 | '@typescript-eslint/explicit-member-accessibility': [
25 | 'error',
26 | {
27 | accessibility: 'no-public',
28 | },
29 | ], // 类实例属性方法必须带修饰符,public除外
30 | '@typescript-eslint/ban-types': ['error'], // 不使用 object Object String等作为类型
31 | '@typescript-eslint/consistent-type-assertions': [
32 | 'error',
33 | { assertionStyle: 'as', objectLiteralTypeAssertions: 'allow' },
34 | ], // 类型断言要一致, or as xx
35 | '@typescript-eslint/restrict-template-expressions': 'warn', // 模板表达式中只能使用某些类型
36 | '@typescript-eslint/unbound-method': 'off', // 不将未绑定 this 的函数当参数
37 | '@typescript-eslint/no-floating-promises': 'off', // promise 要有错误处理
38 | '@typescript-eslint/switch-exhaustiveness-check': 'off', // switch 必须命中一个case:https://typescript-eslint.io/rules/switch-exhaustiveness-check
39 | '@typescript-eslint/no-dynamic-delete': 'off', // 动态删除属性
40 | '@typescript-eslint/ban-ts-comment': 'off',
41 | '@typescript-eslint/no-use-before-define': ['error'],
42 | '@typescript-eslint/no-shadow': ['error'],
43 | },
44 | settings: {
45 | 'import/resolver': {
46 | node: {
47 | extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
48 | },
49 | },
50 | },
51 | };
52 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@fengyinchao/eslint-config-fed",
3 | "version": "1.0.2",
4 | "repository": {
5 | "type": "git",
6 | "url": "git@github.com:fengyinchao/fe-standard-config-seed.git"
7 | },
8 | "publishConfig": {
9 | "access": "public",
10 | "registry": "https://registry.npmjs.org/"
11 | },
12 | "author": "Feng Yinchao",
13 | "license": "MIT",
14 | "files": [
15 | "eslintrc.javascript-base.js",
16 | "eslintrc.node.js",
17 | "eslintrc.react.js",
18 | "eslintrc.vue.js",
19 | "eslintrc.rn.js",
20 | "eslintrc.typescript-base.js",
21 | "js-ts-common.rule.js",
22 | ".editorconfig",
23 | ".eslintignore",
24 | ".gitignore",
25 | ".npmrc",
26 | ".prettierrc.js",
27 | ".prettierignore",
28 | "commitlint.config.js",
29 | "tsconfig.json"
30 | ],
31 | "exports": {
32 | "./javascript-base": {
33 | "require": "./eslintrc.javascript-base.js",
34 | "default": "./eslintrc.javascript-base.js"
35 | },
36 | "./node": {
37 | "require": "./eslintrc.node.js",
38 | "default": "./eslintrc.node.js"
39 | },
40 | "./react": {
41 | "require": "./eslintrc.react.js",
42 | "default": "./eslintrc.react.js"
43 | },
44 | "./vue": {
45 | "require": "./eslintrc.vue.js",
46 | "default": "./eslintrc.vue.js"
47 | },
48 | "./rn": {
49 | "require": "./eslintrc.rn.js",
50 | "default": "./eslintrc.rn.js"
51 | },
52 | "./typescript-base": {
53 | "require": "./eslintrc.typescript-base.js",
54 | "default": "./eslintrc.typescript-base.js"
55 | }
56 | },
57 | "husky": {
58 | "hooks": {
59 | "pre-commit": "lint-staged",
60 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
61 | }
62 | },
63 | "lint-staged": {
64 | "*.{js,ts,jsx,tsx}": [
65 | "eslint",
66 | "prettier --write"
67 | ],
68 | "*.{css,less,scss}": [
69 | "prettier --write"
70 | ],
71 | "*.{html,md,json,yaml}": [
72 | "prettier --write"
73 | ]
74 | },
75 | "dependencies": {
76 | "@commitlint/cli": "9.1.2",
77 | "@commitlint/config-conventional": "12.1.4",
78 | "@typescript-eslint/eslint-plugin": "4.7.0",
79 | "@typescript-eslint/parser": "4.7.0",
80 | "@fengyinchao/eslint-plugin-custom":"0.0.6",
81 | "babel-eslint": "10.1.0",
82 | "eslint": "7.32.0",
83 | "eslint-config-airbnb-base": "14.2.1",
84 | "eslint-config-prettier": "6.15.0",
85 | "eslint-import-resolver-typescript": "2.3.0",
86 | "eslint-plugin-deprecation": "1.1.0",
87 | "eslint-plugin-import": "2.22.1",
88 | "eslint-plugin-jsdoc": "33.0.0",
89 | "eslint-plugin-node": "11.1.0",
90 | "eslint-plugin-prettier": "3.3.1",
91 | "eslint-plugin-react": "7.30.1",
92 | "eslint-plugin-react-hooks": "4.6.0",
93 | "eslint-plugin-react-native": "^4.0.0",
94 | "husky": "4.3.0",
95 | "lint-staged": "10.4.0",
96 | "prettier": "2.1.2",
97 | "typescript": "4.1.6"
98 | }
99 | }
100 |
--------------------------------------------------------------------------------