🎶 Sym - 一款用 Java 实现的现代化社区(论坛/BBS/社交网络/博客)平台

📕 思源笔记 - 一款桌面端笔记应用,支持 Windows、Mac 和 Linux

🎸 Solo - B3log 分布式社区的博客端节点,欢迎加入下一代社区网络

♏ Vditor - 一款浏览器端的 Markdown 编辑器

React Native 系列【三】代码校验 (eslint)

SymApp Demo

ToC

添加依赖

"devDependencies": {
  "babel-eslint": "^7.2.3",
  "eslint": "^4.0.0",
  "eslint-config-airbnb-base": "^11.2.0",
  "eslint-formatter-pretty": "^1.1.0",
  "eslint-plugin-import": "^2.3.0",
  "eslint-plugin-react": "^7.1.0",
  "eslint-plugin-react-native": "^2.3.2"
},

添加命令

"scripts": {
  "lint": "eslint . --fix --format=node_modules/eslint-formatter-pretty --quiet"
  }

添加规则 .eslintrc

{
  "parser": "babel-eslint",
  "extends": "airbnb-base",
  "env": {
    "jest": true
  },
  "plugins": [
    "react",
  "react-native"
  ],
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
  }
  },
  "rules": {
    "react/jsx-uses-vars": 2,
  "react/jsx-uses-react": 2,
  "comma-dangle": [
      "error",
  {
        "arrays": "never",
  "objects": "never"
  }
    ],
  "no-underscore-dangle": [
      "error",
  {
        "allowAfterThis": true
  }
    ]
  },
  "globals": {
    "fetch": true
  }
}

添加不需要检测的文件 .eslintignore

__tests__/

具体修改可参见 :rotating_light: add eslint · b3log/SymApp@f8505e7


欢迎注册黑客派社区,开启你的博客之旅。让学习和分享成为一种习惯!

留下你的脚步