New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

@ghlandy/eslint-config-prettier

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ghlandy/eslint-config-prettier

eslint-config-prettier

latest
Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

@ghlandy/eslint-config-prettier

使用

pnpm i -D @ghlandy/eslint-config-prettier eslint@8 prettier@2
pnpm i -D eslint-config-prettier@8 eslint-plugin-prettier@4

在 eslint 配置文件 (.eslintrc.cjs 或 .eslintrc.js) 中引入使用

module.exports = {
  // ... 其他配置
  extends: [
    'eslint:recommended'
    // ... 其他配置
    '@ghlandy/eslint-config-prettier', // 放在最后
  ],
  // ... 其他配置
};

配置详细

module.exports = {
  extends: ['plugin:prettier/recommended'],
  rules: {
    'prettier/prettier': 'warn',
  },
};

plugin:prettier/recommended 的实际作用如下:

module.exports = {
  extends: ['prettier'],
  plugins: ['prettier'],
  rules: {
    'prettier/prettier': 'error',
    'arrow-body-style': 'off',
    'prefer-arrow-callback': 'off',
  },
};

设置规则 prettier/prettier': 'warn',另外去设置保存自动 prettier 格式化或者 pre-commit 钩子去格式化即可

更多阅读

  • https://eslint.org/docs/latest/extend/shareable-configs
  • https://github.com/prettier/eslint-plugin-prettier/#recommended-configuration

License

MIT

Keywords

eslint

FAQs

Package last updated on 07 Jan 2024

Related posts