Commit fe24d808 authored by lei's avatar lei

eslintrc添加注释

parent daba6cf8
// ESlint 检查配置
// ESLint配置文件 - 用于定义JavaScript/Vue项目的代码规范
module.exports = {
// 标记为根配置文件,ESLint将停止在父目录中查找其他配置文件
root: true,
// 解析器配置
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
parser: 'babel-eslint', // 使用babel-eslint解析器,支持ES6+语法
sourceType: 'module' // 使用ES模块语法
},
// 指定代码运行环境
env: {
browser: true,
node: true,
es6: true,
browser: true, // 浏览器全局变量
node: true, // Node.js全局变量
es6: true // 启用ES6语法支持
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
// 继承的基础配置
extends: [
'plugin:vue/recommended', // Vue官方推荐的规则
'eslint:recommended' // ESLint内置的推荐规则
],
// 自定义规则配置
rules: {
"vue/max-attributes-per-line": [2, {
"singleline": 10,
"multiline": {
"max": 1,
"allowFirstLine": false
// Vue相关规则
"vue/max-attributes-per-line": [2, { // 每行最多属性数
"singleline": 10, // 单行最多10个属性
"multiline": { // 多行属性配置
"max": 1, // 每行1个属性
"allowFirstLine": false // 不允许属性与标签名同行
}
}],
"vue/singleline-html-element-content-newline": "off",
"vue/multiline-html-element-content-newline":"off",
"vue/name-property-casing": ["error", "PascalCase"],
"vue/no-v-html": "off",
'accessor-pairs': 2,
'arrow-spacing': [2, {
'before': true,
'after': true
"vue/singleline-html-element-content-newline": "off", // 关闭单行元素内容换行要求
"vue/multiline-html-element-content-newline": "off", // 关闭多行元素内容换行要求
"vue/name-property-casing": ["error", "PascalCase"], // 组件名使用帕斯卡命名法
"vue/no-v-html": "off", // 允许使用v-html指令
// JavaScript基础规则
'accessor-pairs': 2, // 强制getter/setter成对出现
'arrow-spacing': [2, { // 箭头函数空格
'before': true, // 箭头前空格
'after': true // 箭头后空格
}],
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {
'allowSingleLine': true
......@@ -48,7 +62,7 @@ module.exports = {
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 2,
'eqeqeq': ["error", "always", {"null": "ignore"}],
'eqeqeq': ["error", "always", { "null": "ignore" }],
'generator-star-spacing': [2, {
'before': true,
'after': true
......@@ -163,37 +177,20 @@ module.exports = {
}
}],
'padded-blocks': [2, 'never'],
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
// 代码风格规则
'quotes': [2, 'single', { // 使用单引号
'avoidEscape': true, // 允许字符串中包含其他引号
'allowTemplateLiterals': true // 允许使用模板字符串
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
'semi': [2, 'never'], // 不使用分号
// 生产环境特殊规则
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, // 生产环境禁用debugger
// 对象和数组格式规则
'object-curly-spacing': [2, 'always', { // 对象大括号内空格
objectsInObjects: false // 对象属性与括号间无空格
}],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, {
'words': true,
'nonwords': false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
'yoda': [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [2, 'always', {
objectsInObjects: false
}],
'array-bracket-spacing': [2, 'never']
'array-bracket-spacing': [2, 'never'] // 数组括号内无空格
}
}
User-agent: *
Disallow: /
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment