创建了一个新的 React 项目。那里几乎什么都没有——只有 SSR、代码拆分和几个“hello world!”。页。在 eslint 之上添加了更漂亮。在我添加更漂亮之前,棉绒通常需要 10-15 秒。现在我为几乎空的项目获得了 +2 分钟:
time yarn lint
yarn lint 3.19s user 0.49s system 2% cpu 2:35.39 total
以为我在整理 node_modules。为了检查更新的 2 个文件:
// node_modules/eslint/lib/rules/no-unused-vars.js
...
create(context) {
const sourceCode = context.getSourceCode();
// ########### LOG #############
console.log(`eslint processing file [${+new Date()}] ${context.getFilename()}`);
const REST_PROPERTY_TYPE = /^(?:RestElement|(?:Experimental)?RestProperty)$/u;
和
// node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js
...
const prettierFileInfo = prettier.getFileInfo.sync(
filepath,
Object.assign(
{},
{ resolveConfig: true, ignorePath: '.prettierignore' },
eslintFileInfoOptions
)
);
// ############## LOG ########################
console.log('Prettier processing file', filepath);
// Skip if file is ignored using a .prettierignore file
if (prettierFileInfo.ignored) {
如果您能告诉我一种列出已处理文件的更好方法,我将不胜感激。一个技巧
"scripts": {
...
"lint": " DEBUG=eslint:* eslint --ext .js --fix server src tools",
给了太多数据。
不知道我什至需要这个文件
# .prettierignore
# Ignore everything:
/*
# Good guys
!/src
!/server
!/tools
输出显示第一个文件和最后一个文件的时间戳之间的差异约为 1.5 秒。
eslint processing file [1592686834050] /Users/...
Prettier processing file...
....
eslint processing file [1592686835724] /Users/...
Prettier processing file ...
只是想知道,剩下的 1500 秒用来做什么?
.eslintrc 文件
{
"parser": "babel-eslint",
"extends": [
"airbnb",
"plugin:prettier/recommended"
],
"env": {
"browser" : true,
"jest": true
},
"plugins": [
"prettier",
"react-hooks",
"jsdoc",
"jest"
],
"rules": {
"max-len": [2, 120],
"react/jsx-wrap-multilines": ["error", {"declaration": false, "assignment": false}],
"import/prefer-default-export": 0,
"react/jsx-filename-extension": 0,
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"arrow-body-style": ["error", "as-needed"],
"curly": ["error", "all"],
"jsdoc/check-indentation": "error",
"jsdoc/check-param-names": "error",
"jsdoc/check-property-names": "error",
"jsdoc/check-tag-names": "error",
"jsdoc/require-hyphen-before-param-description": ["error", "never"],
"jsdoc/require-param-description": "error",
"jsdoc/require-param-name": "error",
"jsdoc/require-param-type": "error",
"jsdoc/require-param": "error",
"jsdoc/require-property": "error",
"jsdoc/require-property-name": "error",
"jsdoc/require-property-type": "error",
"jsdoc/require-returns-description": "error",
"jsdoc/require-returns-type": "error",
"jsdoc/require-returns": "error"
},
"settings": {
"import/resolver": {
"node": {
"paths": ["src", "server", "tools"]
}
}
},
"overrides": [
{
"files": [ "**/*.stories.js", "**/*.story.js" ],
"rules": {
"import/no-extraneous-dependencies": 0
}
}
]
}