Giter Site home page Giter Site logo

whitematrixtech / eslint-config-ts Goto Github PK

View Code? Open in Web Editor NEW
0.0 12.0 1.0 16 KB

@whitematrix/eslint-config 基于 Typescript 的 ESLint 配置 (Based on Airbnb Javascript Style)

License: Apache License 2.0

JavaScript 100.00%
eslint typescript airbnb style lint

eslint-config-ts's Introduction

@white-matrix/eslint-config-ts

npm npm npm

规则说明

参考 Airbnb JavaScript 代码规范: https://github.com/airbnb/javascript

安装说明

依赖项:

  • typescript
  • prettier
  • eslint
  • eslint-plugin-import

依赖项安装示例:

npm install --save-dev typescript prettier eslint eslint-plugin-import

安装:

npm install --save-dev @white-matrix/eslint-config-ts

配置

.eslintrc.yml

root: true
extends:
  - '@white-matrix/eslint-config-ts'
  - plugin:@typescript-eslint/recommended-requiring-type-checking
parserOptions:
  project: ./tsconfig.json

注意: 同时需要在项目根目录下配置 tsconfig.json, 一个参考的示例配置:

{
  "compilerOptions": {
    "target": "es2017",
    "module": "commonjs",
    "esModuleInterop": true,
    "noImplicitAny": true,
    "removeComments": true,
    "strict": true,
    "strictNullChecks": true,
    "preserveConstEnums": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "pretty": true,
    "sourceMap": true,
    "forceConsistentCasingInFileNames": true,
    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "moduleResolution": "node",
    "outDir": "lib",
    "strictFunctionTypes": true,
    "strictPropertyInitialization": true,
    "strictBindCallApply": true,
    "alwaysStrict": true,
    "lib": ["es2017"]
  },
  "include": ["src/**/*.ts"],
  "exclude": ["node_modules"]
}

更多 tsconfig 详情请参阅: http://www.typescriptlang.org/docs/handbook/tsconfig-json.html

.prettier.yml

tabWidth: 2
semi: true
singleQuote: true
jsxSingleQuote: true
trailingComma: none

在 VS Code 中使用

VS Code 中搜索并添加以下两个插件

  • esbenp.prettier-vscode
  • dbaeumer.vscode-eslint

然后在用户配置中参考以下方案进行配置:

{
  "editor.tabSize": 2,
  "editor.insertSpaces": true,
  "editor.formatOnType": true,
  "editor.formatOnSave": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.minimap.enabled": true,
  "files.autoSave": "afterDelay",
  "files.eol": "\n",
  "eslint.autoFixOnSave": true,
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "typescript",
    "typescriptreact",
    "vue",
    "html"
  ],
  "typescript.updateImportsOnFileMove.enabled": "always",
  "typescript.validate.enable": false,
  "javascript.validate.enable": false,
  "javascript.format.enable": false,
  "javascript.preferences.quoteStyle": "single",
  "prettier.jsxSingleQuote": true,
  "prettier.singleQuote": true,
  "prettier.trailingComma": "none",
  "prettier.semi": true,
  "prettier.tabWidth": 2
}

License

Apache 2.0

eslint-config-ts's People

Contributors

kilru avatar willin avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

wklili

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.