• 技术文章 >开发工具 >atom

    浅谈atom中eslint的配置和使用方法

    青灯夜游青灯夜游2021-10-20 19:29:30转载481
    本篇文章给大家介绍一下eslint & atom 配合使用。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

    【相关推荐:《atom教程》】

    下载aotm插件 linter-eslint

    https://github.com/AtomLinter/linter-eslint

    需要设置如下:

    提供了一些插件,可自行下载(ps: 版本差异会导致部分插件报错)

    然后在项目下
    $ eslint --init


    使用以下注释,关闭提示。

    /* eslint-disable */

    使用eslintignore 忽略特定的文件和目录

    创建一个 .eslintignore 文件,添加需要过滤的文件夹,或者文件

     build/*
     app/lib/*

    命令行使用 --ignore-path

    $ eslint --ignore-path .eslintignore --fix app/*

    路径是相对于 .eslintignore 的位置或当前工作目录

    更多查看 http://eslint.cn/docs/user-guide/configuring

    基础配置:

    module.exports = {
        parser: 'babel-eslint',
    
        "env": {
            "browser": true,
            "commonjs": true,
            "es6": true
        },
    
        // 以当前目录为根目录,不再向上查找 .eslintrc.js
        root: true,
    
        // 禁止使用 空格 和 tab 混合缩进
        "extends": "eslint:recommended",
    
        globals: {
            // 这里填入你的项目需要的全局变量
            // jQuery: false,
            $: false,
            wx: false,
        },
        
        // eslint-plugin-html 开启
        "plugins": [
            "html"
        ],
    
        "parserOptions": {
            "ecmaFeatures": {
                "jsx": false
            },
            "sourceType": "module"
        },
    
        "rules": {
            "indent": ["error", 'tab'],
    
            "linebreak-style": ["error","unix"],
    
            "quotes": ["error","single"],
    
            "semi": ["error","always"],
    
            "semi": ["error","always"],
    
            "arrow-spacing": ["error", { "before": true, "after": true }],
    
            "no-unused-vars": "off", //禁止提示没有使用的变量,或者函数
    
            "block-spacing": "error",
    
            "no-console": "off", //可以使用console
    
            "keyword-spacing": ["error", { "before": true }] //强制关键字周围空格的一致性
    
        }
    };

    更多编程相关知识,请访问:编程教学!!

    以上就是浅谈atom中eslint的配置和使用方法的详细内容,更多请关注php中文网其它相关文章!

    声明:本文转载于:掘金社区,如有侵犯,请联系admin@php.cn删除
    专题推荐:atom eslint
    上一篇:Atom中如果配置小程序文件,让代码高亮显示! 下一篇:没有了
    大前端线上培训班

    相关文章推荐

    • 浅谈Atom利用Markdown存放图片的方法• atom中怎么离线安装package• 浅谈Atom实现HTML实时预览的方法• Atom块注释插件multi-comment的安装和使用• 详解Atom配置Python虚拟环境的方法(Windows环境)• Atom中如果配置小程序文件,让代码高亮显示!

    全部评论我要评论

  • 取消发布评论发送
  • 1/1

    PHP中文网