文章数量
37
闲言杂语
5
运行天数
1,693
访客量
259,121

保 洁 阿 姨

luzhou·sichuan

拥有60+年的前端设计经验

Web网页设计:70888820

看看自适应?

关于更多博客信息

5个视频

Video list

自己用的Eslintrc规则[存档]

IP属地:四川省 / 发布于:2 个月前 / 浏览:270

.eslintrc.js

module.exports = {
    //此项是用来告诉eslint找当前配置文件不能往父级查找
    root: true,
    parser: 'vue-eslint-parser',
    plugins: ['@typescript-eslint', 'vue'],
    extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:vue/vue3-recommended'
    ],
    env: {
        node: true
    },
    parserOptions: {
        'parser': '@typescript-eslint/parser',
        'ecmaVersion': 7,
        'sourceType': 'module',
        'ecmaFeatures': {
            'modules': true
        }
    },
    rules: {
        '@typescript-eslint/member-delimiter-style': [
            2, {
                'multiline': {
                    'delimiter': 'comma',
                    'requireLast': false
                },
                'singleline': {
                    'delimiter': 'comma',
                    'requireLast': false
                }
            }
        ],
        //return后面是否允许省略
        'array-callback-return': 1,
        //箭头函数的参数可以不使用圆括号
        'arrow-parens': ['error', 'as-needed'],
        //要求return语句要么总是指定返回的值,要么不指定
        'consistent-return': 0,
        //强制驼峰法命名
        'camelcase': 0,
        //要求或禁止使用拖尾逗号
        'comma-dangle': ['error', 'never'],
        //强制全等( === 和 !==)
        'eqeqeq': 0,
        //函数表达式必须有名字
        'func-names': 0,
        //取消对require的验证,使得可以使用require来加载图片的相对路径
        'global-require': 0,
        //取消自动解析路径,以此开启alias的别名路径设置
        'import/no-unresolved': 0,
        //取消对文件扩展名的验证
        'import/extensions': 0,
        //混合ts
        'indent': 'off',
        //缩进风格(强制使用一致的缩进)
        '@typescript-eslint/indent': ['error', 4, { 'VariableDeclarator': 4 }],
        '@typescript-eslint/explicit-function-return-type': 'off',
        //取消换行符\n或\r\n的验证()
        'linebreak-style': 0,
        //字符串最大长度
        'max-len': 0,
        //使用const和let代替var
        'no-var': 'error',
        'no-undef':'off',
        //禁止出现未使用过的变量
        'no-unused-vars': 'off',
        //合并选项
        '@typescript-eslint/no-unused-vars': 0,
        '@typescript-eslint/no-explicit-any':'off',
        //禁止多次声明同一变量
        'no-redeclare': 1,
        //禁止在变量定义之前使用它们
        'no-use-before-define': 1,
        //允许使用未使用过的表达式,以此来支持a && a()的代码形式
        'no-unused-expressions': 0,
        //禁用特定的语法
        'no-restricted-syntax': 1,
        //禁止使用++ --
        'no-plusplus': 0,
        //允许在标识符中使用下划线
        'no-underscore-dangle': 0,
        //禁止对function的参数进行重新赋值
        'no-param-reassign': 0,
        //禁止嵌套三元表达式
        'no-nested-ternary': 0,
        //禁止if语句中return语句之后有else块
        'no-else-return': 0,
        'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
        'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
        //外部作用域中的变量不能与它所包含的作用域中的变量或参数同名
        'no-shadow': [
            0, {
                'allow': ['resolve', 'reject', 'done', 'cb']
            }
        ],
        //要求使用剩余参数而不是arguments
        'prefer-rest-params': 1,
        //要求回调函数使用箭头函数
        'prefer-arrow-callback': 0,
        //首选const
        'prefer-const': 1,
        //使用分号
        'semi': [2, 'never'],
        //使用单引号
        'quotes': [2, 'single'],
        //要求或禁止模板字符串中的嵌入表达式周围空格的使用
        'template-curly-spacing': 'off',
        //运算符两边必须包含空格
        'space-infix-ops': ['error', { 'int32Hint': true }],
        //强制在花括号中使用一致的空格
        'object-curly-spacing': ['error', 'always', { 'objectsInObjects': false }],
        'array-bracket-newline': ['error', { 'multiline': true }],
        'arrow-spacing': ['error', { 'before': true, 'after': true }],
        'vue/max-attributes-per-line': [
            'error', {
                'singleline': {
                    'max': 100,
                    'allowFirstLine': true
                },
                'multiline': {
                    'max': 100,
                    'allowFirstLine': true
                }
            }
        ],
        'vue/no-v-html':'off',
        'vue/require-default-prop': 0,
        'vue/singleline-html-element-content-newline': [
            0, {
                'ignoreWhenNoAttributes': false,
                'ignoreWhenEmpty': false,
                'ignores': ['pre', 'textarea']
            }
        ],
        '@typescript-eslint/no-non-null-assertion': 'off',
        '@typescript-eslint/ban-ts-comment':'off',
        '@typescript-eslint/explicit-module-boundary-types':'off',
        'vue/html-indent': [
            'error', 4, {
                'attribute': 1,
                'baseIndent': 1,
                'closeBracket': 0,
                'alignAttributesVertically': true,
                'ignores': []
            }
        ]
    }
}
给Ta打赏

0人打赏

打赏的土豪们

Rewarded users

暂无打赏

© 未经允许禁止转载

「留下足迹」- Footprint

回复
暂无数据
There is currently no data available

用户签到

User Sign

今日未签到,点击签到!

站点公告

Announcement

3 周前 (友情链接)2023-5-5清除单项链接

2 个月前 (友情链接)2023-3-21清除单项链接

6 个月前 Web网页设计交流群:70888820

6 个月前 QQ号523179414(姓:郑)狗骗子,谢绝访问

版权申明

本站原创内容版权遵循 CC-BY-NC-SA 协议规定,转载请注明出处.本站部分资源收集于网络,只做学习和交流使用,版权归原作者所有.

豫ICP备18005747号-1