Skip to main content

代码规范

ESLint + Prettier

node#

yarn add -D prettier eslint-plugin-prettier eslint-config-prettier eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin

.eslintrc.js

/* eslint-disable no-undef */module.exports = {  env: {    browser: true,    es2021: true,  },  extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],  parser: '@typescript-eslint/parser',  parserOptions: {    ecmaVersion: 12,    sourceType: 'module',  },  plugins: ['@typescript-eslint', 'prettier'],  rules: {    '@typescript-eslint/explicit-module-boundary-types': 'off',  },}

.prettierrc

{  "tabWidth": 2,  "printWidth": 100,  "singleQuote": true,  "trailingComma": "es5",  "semi": false,  "jsxSingleQuote": true}