如果您查看这些目录和引用的文件内容,您可以看到样式指南 .js 文件的结构以及它们是如何加载到 eslint 中的:
https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base
https://github.com/airbnb/javascript/tree/master/packages/eslint-config-airbnb-base/rules
//index.js
module.exports = {
extends: [
'./rules/best-practices',
'./rules/errors',
'./rules/node',
'./rules/style',
'./rules/variables',
'./rules/es6',
'./rules/imports', // (my note) not needed as uses extra plugin
].map(require.resolve),
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
strict: 'error',
},
};
// .eslintrc
{
"extends": "./index.js",
"rules": {
// disable requiring trailing commas because it might be nice to revert to
// being JSON at some point, and I don't want to make big changes now.
"comma-dangle": 0,
// we support node 4
"prefer-destructuring": 0,
},
}
我想将所有文件连接在一起,以便将其粘贴到我的 package.json 中。我怎样才能做到这一点?我不知道节点,我不需要 NPM 下载中的所有其他内容,我只想在一个文件中的一个位置永久复制当前样式指南。干杯!