1.0.5 • Published 2 years ago

dtc-eslint-config v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

dtc-eslint-config

// jest test

npm run test

Install typescript, eslint and prettier, dtc-eslint-config and put it into your .eslintrc.js.

.eslintrc.js:

module.exports = {
  extends: [
    require.resolve('dtc-eslint-config')
  ],
};

配置 package.json

"scripts": {
    "lint:fix": "eslint ./src --ext .jsx,.js,.ts,.tsx,.vue --quiet --fix --ignore-path ./.gitignore",
    "lint:format": "prettier  --loglevel warn --write \"./**/*.{js,jsx,ts,tsx,css,md,json,.vue}\" ",
    "lint": "npm run lint:format && npm run lint:fix "
  },

解决 eslintrc 与 prettire 默认规则的冲突。比如eslint 规则”semi”: “error”, “never” 结尾不需要分号,而 prettire 默认是分号结尾,所以在格式化是会冲突。解决方法是:要么修改 eslintrc, 要么修改 prettire 规则。这里以eslint的规则为主,配置.prettierrc.js

module.exports = {
  singleQuote: true,
  semi: false,
  endOfLine: 'auto',
  tabWidth: 4,
  trailingComma: 'none',
  arrowParens: 'avoid'
}