搜尋
首頁開發工具atom淺談atom中eslint的設定與使用方法

本篇文章跟大家介紹一下eslint & atom 搭配使用。有一定的參考價值,有需要的朋友可以參考一下,希望對大家有幫助。

淺談atom中eslint的設定與使用方法

【相關推薦:《atom教學》】

下載aotm外掛程式linter-eslint

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

#需要設定如下:

  • Install locally to your project eslint and the plugin
    • $ npm i --save-dev eslint [eslint-plugins]
  • Install globally eslint and plugins
    • # $ npm i -g eslint [eslint-plugins]
    • Activate Use Global Eslint package option
    • #(Optional) Set Global Node Path with $ npm config get prefix

#提供了一些插件,可自行下載(ps: 版本差異會導致部分插件報錯誤)

  • eslint-config-airbnb
  • eslint-plugin-import
  • eslint-plugin-jsx-a11y
  • eslint-plugin -react
  • eslint-plugin-html (可解析html中的腳本, 最新的版本v4跟早期eslint有衝突)

然後在項目下
$ 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刪除

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱工具

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

這個專案正在遷移到osdn.net/projects/mingw的過程中,你可以繼續在那裡關注我們。 MinGW:GNU編譯器集合(GCC)的本機Windows移植版本,可自由分發的導入函式庫和用於建置本機Windows應用程式的頭檔;包括對MSVC執行時間的擴展,以支援C99功能。 MinGW的所有軟體都可以在64位元Windows平台上運作。

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

mPDF

mPDF

mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境