1.0.3 • Published 3 years ago

@dianmi-fe/lint v1.0.3

Weekly downloads
98
License
MIT
Repository
github
Last release
3 years ago

@dianmi-fe/lint · GitHub license npm version GitHub Release GitHub Actions

npm install --save-dev @dianmi-fe/lint

使用方式

在你的项目的根目录下

// 创建一个 .prettierrc.js 文件, 并将以下内容复制进去:
module.exports = require('@dianmi-fe/lint/prettier')

// 创建一个 .stylelintrc.js 文件, 并将以下内容复制进去:
module.exports = require('@dianmi-fe/lint/stylelint')

Vue

Vue + TypeScript 待实现

// 在你的 Vue 项目的根目录下创建一个 .eslintrc.js 文件, 并将以下内容复制进去:
module.exports = require('@dianmi-fe/lint/eslint/vue')

Vue3

Vue3 + TypeScript 待实现

// 在你的 Vue3 项目的根目录下创建一个 .eslintrc.js 文件, 并将以下内容复制进去:
module.exports = require('@dianmi-fe/lint/eslint/vue3')

React

React + TypeScript 待实现

// 在你的 React 项目的根目录下创建一个 .eslintrc.js 文件, 并将以下内容复制进去:
module.exports = require('@dianmi-fe/lint/eslint/react')

为了增加更好的开发体验

必不可少的 vscode 插件

点击图标进入插件详情页

必不可少的 vscode 配置

1. 项目根目录创建 .vscode/settings.json, 粘贴以下 json
{
    "files.eol": "\n",
    "editor.tabSize": 4,
    // "editor.formatOnSave": true,
    // "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.codeActionsOnSave": { // 保存时的代码操作
        "source.fixAll": true
        // or(或者)
        // "source.fixAll.eslint": true,
        // "source.fixAll.stylelint": true
    },
    // multi-command 插件配置项, 用于一键执行 eslint/stylelint 格式化
    "multiCommand.commands": [ 
        {
            "command": "multiCommand.fixAll",
            "sequence": [
                "eslint.executeAutofix",
                "stylelint.executeAutofix"
            ]
        },
    ]
}
2. 根据下面的视频打开文件位置, 粘贴以下 json
[
    {
        "key": "ctrl+f", // 可修改为自己的快捷键
        "command": "multiCommand.fixAll"
    }
]