# eslint-config-js **Repository Path**: agile-development-system/eslint-config-js ## Basic Information - **Project Name**: eslint-config-js - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-05-24 - **Last Updated**: 2022-06-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

logo

# @agds/eslint-config-js **版本** :1.0.8 agds的js eslint配置,支持js、json、markdown的js代码 ## 快速开始 ### 安装 ```bash npm i -D @agds/eslint-config-js ``` ### 引入 ```js // .eslintrc.js module.exports = { extends: [ '@agds/js', ], }; ``` ### 添加lint脚本 在`package.json`的`scripts`下添加lint命令; ```json { "scripts": { "lint": "eslint --ext .js,.json,.md src", "lint:fix": "eslint --ext .js,.json,.md src --fix" } } ``` ### 基于`lint-staged`提供增量lint脚本 - 安装`lint-staged`包 ``` npm i -D lint-staged ``` - 在`package.json`中添加`pkg['lint-staged']`脚本 ```json { "lint-staged": { "src/**/*.{js,json,md}": [ "eslint --fix" ] } } ``` ### 使用`yorkie`在git声明周期内检测代码格式 - 安装`yorkie`包 ``` npm i -D yorkie ``` - 在`package.json`中添加`pkg.gitHooks`脚本 ```json { "gitHooks": { "pre-commit": "lint-staged" } } ``` ## 配置源码 ```js const { FastPath, FastFs } = require('@agds/node-utils'); const cwdBabelConfigPath = FastPath.getCwdPath('./babel.config.js'); const hasCwdBabelConfg = FastFs.getPathStatSync(cwdBabelConfigPath); module.exports = { env: { commonjs: true, es2021: true, node: true, }, extends: [ 'standard', 'plugin:markdown/recommended', ], plugins: [ 'json-format', ], settings: { 'json/sort-package-json': false, 'json/json-with-comments-files': [], 'json/ignore-files': [], }, parser: hasCwdBabelConfg ? '@babel/eslint-parser' : undefined, parserOptions: { ecmaVersion: 12, babelOptions: { configFile: hasCwdBabelConfg ? cwdBabelConfigPath : undefined, }, }, rules: { indent: ['error', 4, { SwitchCase: 1 }], semi: ['error', 'always'], 'comma-dangle': ['error', 'always-multiline'], 'space-before-function-paren': [ 'error', { anonymous: 'always', named: 'never', asyncArrow: 'always' }, ], }, overrides: [ { files: ['**/*.md/*.{js,json}', 'docs/**', 'test/**'], rules: { 'no-console': 'off', 'import/no-unresolved': 'off', 'no-undef': 'off', 'no-unused-expressions': 'off', 'no-unused-vars': 'off', 'padded-blocks': 'off', 'eol-last': 'off', }, }, ], }; ``` ## 许可证 [MIT License](https://gitee.com/agile-development-system/eslint-config-js/blob/master/LICENSE) Copyright (c) 2021 锦阳 ## 请维护者喝杯咖啡
## 加入钉钉群讨论或加入开发