皮棉较慢

时间:2020-06-20 21:31:03

标签: javascript reactjs webpack eslint prettier-eslint

创建了一个新的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
      }
    }
  ]
}

1 个答案:

答案 0 :(得分:0)

重新启动Mac并获得正常的处理时间(〜4秒):

time yarn lint
yarn lint  4.09s user 0.61s system 109% cpu 4.279 total