ztxkutils
TypeScript icon, indicating that this package has built-in type declarations

2.10.64 • Public • Published

中拓信科公用库文件

  1. 引入代码规范,ESLint、prettier

    eslint-config-prettier

    关闭所有不必要的规则或可能与Prettier冲突的规则

    eslint-plugin-prettier

    运行Prettier作为Eslint规则,并报告差异个别ESLint问题

    yarn add -D eslint prettier eslint-config-prettier eslint-plugin-prettier
    
    # .eslintrc.json
    {
    	"extends": ["plugin:prettier/recommended"]
    }
    
    # .vscode/settings.json
    {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
      "editor.formatOnSave": true,
      "eslint.validate": ["typescript"],
      "files.eol": "\n"
    }
  2. 添加ts相关配置

    @typescirpt-eslint/parser

    一个利用TypeScript ESTree 允许ESLint整理TypeScript源代码的ESLint解析器

    @typescript-eslint/eslint-plugin

    添加或扩展具有TypeScript特定功能的规则

    yarn add typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
    
    # .eslintrc.json
    {
      "parser": "@typescript-eslint/parser",
      "extends": ["plugin:prettier/recommended"],
      # 添加eslint对es6语法的识别
      "parserOptions": {
        "ecmaVersion": 6
      },
      "plugins": ["@typescript-eslint"]
    }
    
  3. 配置webpack对ts代码的解析

    yarn add ts-loader
    

Readme

Keywords

none

Package Sidebar

Install

npm i ztxkutils

Weekly Downloads

53

Version

2.10.64

License

MIT

Unpacked Size

1.08 MB

Total Files

66

Last publish

Collaborators

  • cyxwmm