Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

其他规范 #5

Open
mason369 opened this issue Dec 1, 2022 · 0 comments
Open

其他规范 #5

mason369 opened this issue Dec 1, 2022 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@mason369
Copy link
Member

mason369 commented Dec 1, 2022

其他规范

使用 prettier 格式化工具以及 eslint 校验

prettier格式化工具请自行全局安装后格式化

.eslintrc.js 规则:

module.exports = {
	root: true,
	env : {
		browser: true,
		node   : true,
		es2021 : true,
		es6    : true
	},
	extends: ["plugin:vue/essential"],

	plugins: ["@typescript-eslint"],

	parserOptions: { parser: "babel-eslint" },
	plugins      : ["vue"],
	// 在此处添加自定义规则
	rules        : {
		eqeqeq: "off", // 要求使用 `===` 和 `!==`

		curly: "error", // 强制所有控制语句使用一致的括号风格

		quotes: ["error", "double"], // 引号

		"arrow-parens": 0, // allow paren-less arrow functions

		"generator-star-spacing": 0, // allow async-await

		"no-unused-vars": "error", // disabled no ununsed var  `V1.1`

		"no-debugger": process.env.NODE_ENV === "production" ? "error" : "off", // no use debugger in production

		indent: [2, 4, { SwitchCase: 1 }], // 4 space for tab for perttier

		"space-before-function-paren": ["error", "never"], // no space in function name for perttier

		// # Possible Errors
		//
		"no-constant-condition": ["warn"],

		// 允许 if(...){带有花括号的空代码}
		"no-empty": ["off"],

		// 数组, 对象 逗号后面强制一空格
		"comma-spacing": ["error", { after: true }],

		// 对象单行 多行对齐模式
		"key-spacing": [
			"error",
			{
				singleLine: {},
				multiLine : { align: "colon" }
			}
		],

		// # Best Practices
		// 对象换行策略 , 如果多行, `{`和`}` 前后不能跟值
		"object-curly-newline" : ["error", { multiline: true }],
		"array-bracket-newline": ["error", { multiline: true }],

		// if后面强制花括号
		curly: ["error", "all"],

		// # Strict Mode
		// # Variables
		"no-unused-vars": ["warn"],

		// # Stylistic Issues

		quotes           : ["error", "double"],
		indent           : ["error", "tab"],
		"linebreak-style": ["error", "windows"],

		// if else try catch 换行
		"brace-style": ["error", "stroustrup", { allowSingleLine: false }],

		// 操作符周围前后必须空格
		"space-infix-ops": ["error"],
        
		// 提醒尾逗号 , 微信浏览器 , uc浏览器的问题
		"comma-dangle": ["warn", "never"]
		// # ECMAScript 6
		// # Deprecated
		// # Removed
	},
	overrides: [
		{
			files: ["*.vue"],
			rules: { "vue/multi-word-component-names": 0 }
		}
	]
};

.eslintignore 规则:

# /node_modules/* and /bower_components/* ignored by default

# Ignore built files except build/index.js
build/*
!build/index.js
@mason369 mason369 added documentation Improvements or additions to documentation help wanted Extra attention is needed labels Dec 1, 2022
@mason369 mason369 added this to STARART Dec 1, 2022
@mason369 mason369 moved this to 🆕 New in STARART Feb 1, 2023
@mason369 mason369 added this to the 0.0.1开发总体需求 milestone Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
Status: 🆕 New
Development

No branches or pull requests

4 participants