Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow when linting a single file #212

Closed
OmgImAlexis opened this issue Apr 25, 2017 · 43 comments
Closed

Slow when linting a single file #212

OmgImAlexis opened this issue Apr 25, 2017 · 43 comments

Comments

@OmgImAlexis
Copy link
Contributor

xo seems to load really slowly when linting a single file. The main issue from what I can see relies around eslint:glob-util and loading plugin:unicorn/recommended because of these two the lint can take upwards of 2 seconds to lint a 19 line file. This doesn't sound so bad until you take into account it takes the same time when running in atom with the atom-linter-xo package.

I used this to run xo DEBUG=* xo js/helpers/config.js.

This is the file I was linting.

// @TODO: Setup defaults so we can use config before the api resolves the request
export default {
    baseUrl: $('body').attr('base-url'),
    token: $('body').attr('token'),
    posterSortby: undefined,
    animeSplitHome: undefined,
    rootDirs: undefined,
    selectedRootIndex: undefined,
    layout: {
        show: {
            specials: true,
            allSeasons: true
        },
        home: 'banner',
        history: 'detailed',
        schedule: 'banner'
    }
};
xo Using local install of XO. +0ms
  eslint:config-file Loading /Users/xo/code/Medusa/node_modules/xo/config/plugins.js +0ms
  eslint:config-file Loading JS config file: /Users/xo/code/Medusa/node_modules/xo/config/plugins.js +3ms
  eslint:config-file Loading plugin:unicorn/recommended +741ms
  eslint:config-file Attempting to resolve eslint-plugin-unicorn +1ms
  eslint:config-file Loading JS config file: /Users/xo/code/Medusa/node_modules/eslint-plugin-unicorn/index.js +1ms
  eslint:config-file Loading plugin:ava/recommended +5ms
  eslint:config-file Attempting to resolve eslint-plugin-ava +1ms
  eslint:config-file Loading JS config file: /Users/xo/code/Medusa/node_modules/eslint-plugin-ava/index.js +0ms
  eslint:config-file Loading /Users/xo/code/Medusa/node_modules/xo/config/overrides.js +8ms
  eslint:config-file Loading JS config file: /Users/xo/code/Medusa/node_modules/xo/config/overrides.js +0ms
  eslint:config-file Loading xo +2ms
  eslint:config-file Attempting to resolve eslint-config-xo +0ms
  eslint:config-file Loading JS config file: /Users/xo/code/Medusa/node_modules/eslint-config-xo/index.js +1ms
  eslint:glob-util Creating list of files to process. +620ms
  eslint:ignored-paths Looking for ignore file in /Users/xo/code/Medusa +7ms
  eslint:ignored-paths Could not find ignore file in cwd +0ms
  eslint:config Constructing config for /Users/xo/code/Medusa/js/helpers/config.js +7ms
  eslint:config Not using .eslintrc or package.json files +0ms
  eslint:config Merging command line environment settings +0ms
  eslint:config Merging command line rules +1ms
  eslint:config Merging command line plugins +0ms
  eslint:config-ops Apply environment settings to config +0ms
  eslint:config-ops Creating config for environment node +1ms
  eslint:config-ops Creating config for environment es6 +0ms
  eslint:config-ops Creating config for environment browser +0ms
  eslint:config-ops Creating config for environment jquery +1ms
  eslint:cli-engine Processing /Users/xo/code/Medusa/js/helpers/config.js +12ms
  eslint:cli-engine Linting /Users/xo/code/Medusa/js/helpers/config.js +1ms
  eslint:config Constructing config for /Users/xo/code/Medusa/js/helpers/config.js +1ms
  eslint:config Using config from cache +0ms
  eslint:code-path onCodePathStart s1 +200ms
  eslint:code-path onCodePathSegmentStart s1_1 +3ms
  eslint:code-path s1_1) Program +2ms
  eslint:code-path s1_1) ExportDefaultDeclaration +46ms
  eslint:code-path s1_1) ObjectExpression +6ms
  eslint:code-path s1_1) Property +10ms
  eslint:code-path s1_1) Identifier +3ms
  eslint:code-path s1_1) Identifier:exit +2ms
  eslint:code-path s1_1) CallExpression +0ms
  eslint:code-path s1_1) MemberExpression +8ms
  eslint:code-path s1_1) CallExpression +3ms
  eslint:code-path s1_1) Identifier +2ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Literal +0ms
  eslint:code-path s1_1) Literal:exit +3ms
  eslint:code-path s1_1) CallExpression:exit +0ms
  eslint:code-path s1_1) Identifier +1ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) MemberExpression:exit +0ms
  eslint:code-path s1_1) Literal +0ms
  eslint:code-path s1_1) Literal:exit +1ms
  eslint:code-path s1_1) CallExpression:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +1ms
  eslint:code-path s1_1) CallExpression +0ms
  eslint:code-path s1_1) MemberExpression +1ms
  eslint:code-path s1_1) CallExpression +0ms
  eslint:code-path s1_1) Identifier +1ms
  eslint:code-path s1_1) Identifier:exit +1ms
  eslint:code-path s1_1) Literal +0ms
  eslint:code-path s1_1) Literal:exit +0ms
  eslint:code-path s1_1) CallExpression:exit +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +1ms
  eslint:code-path s1_1) MemberExpression:exit +0ms
  eslint:code-path s1_1) Literal +0ms
  eslint:code-path s1_1) Literal:exit +0ms
  eslint:code-path s1_1) CallExpression:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +1ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +1ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +1ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +2ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +1ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +1ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) ObjectExpression +0ms
  eslint:code-path s1_1) Property +1ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +1ms
  eslint:code-path s1_1) ObjectExpression +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Literal +1ms
  eslint:code-path s1_1) Literal:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Literal +0ms
  eslint:code-path s1_1) Literal:exit +0ms
  eslint:code-path s1_1) Property:exit +1ms
  eslint:code-path s1_1) ObjectExpression:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +0ms
  eslint:code-path s1_1) Literal +1ms
  eslint:code-path s1_1) Literal:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +0ms
  eslint:code-path s1_1) Identifier:exit +1ms
  eslint:code-path s1_1) Literal +1ms
  eslint:code-path s1_1) Literal:exit +1ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) Property +0ms
  eslint:code-path s1_1) Identifier +1ms
  eslint:code-path s1_1) Identifier:exit +7ms
  eslint:code-path s1_1) Literal +1ms
  eslint:code-path s1_1) Literal:exit +1ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) ObjectExpression:exit +0ms
  eslint:code-path s1_1) Property:exit +0ms
  eslint:code-path s1_1) ObjectExpression:exit +0ms
  eslint:code-path s1_1) ExportDefaultDeclaration:exit +0ms
  eslint:code-path s1_1) Program:exit +1ms
  eslint-plugin-import:rules:newline-after-import exit processing for /Users/xo/code/Medusa/js/helpers/config.js +17ms
  eslint-plugin-import:rules:newline-after-import got scope: [ Node {
    type: 'ExportDefaultDeclaration',
    start: 83,
    end: 482,
    loc: SourceLocation { start: [Object], end: [Object] },
    range: [ 83, 482 ],
    declaration: 
     Node {
       type: 'ObjectExpression',
       start: 98,
       end: 481,
       loc: [Object],
       range: [Object],
       properties: [Object],
       parent: [Circular] },
    leadingComments: [ [Object] ],
    parent: 
     Node {
       type: 'Program',
       start: 0,
       end: 483,
       loc: [Object],
       range: [Object],
       body: [Circular],
       sourceType: 'module',
       comments: [Object],
       tokens: [Object],
       parent: null } } ] +0ms
  eslint:code-path onCodePathSegmentEnd s1_1 +8ms
  eslint:code-path onCodePathEnd s1 +1ms
  eslint:code-path DOT 
digraph {
node[shape=box,style="rounded,filled",fillcolor=white];
initial[label="",shape=circle,style=filled,fillcolor=black,width=0.25,height=0.25];
final[label="",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];
s1_1[label="Program\nExportDefaultDeclaration\nObjectExpression\nProperty\nIdentifier (baseUrl)\nCallExpression\nMemberExpression\nCallExpression\nIdentifier ($)\nLiteral (body)\nIdentifier (attr)\nLiteral (base-url)\nProperty\nIdentifier (token)\nCallExpression\nMemberExpression\nCallExpression\nIdentifier ($)\nLiteral (body)\nIdentifier (attr)\nLiteral (token)\nProperty\nIdentifier (posterSortby)\nIdentifier (undefined)\nProperty\nIdentifier (animeSplitHome)\nIdentifier (undefined)\nProperty\nIdentifier (rootDirs)\nIdentifier (undefined)\nProperty\nIdentifier (selectedRootIndex)\nIdentifier (undefined)\nProperty\nIdentifier (layout)\nObjectExpression\nProperty\nIdentifier (show)\nObjectExpression\nProperty\nIdentifier (specials)\nLiteral (true)\nProperty\nIdentifier (allSeasons)\nLiteral (true)\nProperty\nIdentifier (home)\nLiteral (banner)\nProperty\nIdentifier (history)\nLiteral (detailed)\nProperty\nIdentifier (schedule)\nLiteral (banner)\nIdentifier:exit (baseUrl)\nIdentifier:exit ($)\nLiteral:exit (body)\nCallExpression:exit\nIdentifier:exit (attr)\nMemberExpression:exit\nLiteral:exit (base-url)\nCallExpression:exit\nProperty:exit\nIdentifier:exit (token)\nIdentifier:exit ($)\nLiteral:exit (body)\nCallExpression:exit\nIdentifier:exit (attr)\nMemberExpression:exit\nLiteral:exit (token)\nCallExpression:exit\nProperty:exit\nIdentifier:exit (posterSortby)\nIdentifier:exit (undefined)\nProperty:exit\nIdentifier:exit (animeSplitHome)\nIdentifier:exit (undefined)\nProperty:exit\nIdentifier:exit (rootDirs)\nIdentifier:exit (undefined)\nProperty:exit\nIdentifier:exit (selectedRootIndex)\nIdentifier:exit (undefined)\nProperty:exit\nIdentifier:exit (layout)\nIdentifier:exit (show)\nIdentifier:exit (specials)\nLiteral:exit (true)\nProperty:exit\nIdentifier:exit (allSeasons)\nLiteral:exit (true)\nProperty:exit\nObjectExpression:exit\nProperty:exit\nIdentifier:exit (home)\nLiteral:exit (banner)\nProperty:exit\nIdentifier:exit (history)\nLiteral:exit (detailed)\nProperty:exit\nIdentifier:exit (schedule)\nLiteral:exit (banner)\nProperty:exit\nObjectExpression:exit\nProperty:exit\nObjectExpression:exit\nExportDefaultDeclaration:exit\nProgram:exit"];
initial->s1_1->final;
} +3ms
  eslint:cli-engine Linting complete in: 389ms +4ms
@OmgImAlexis
Copy link
Contributor Author

I noticed running xo as well as atom-linter-xo on the xo and ava repo's the xo takes quite a bit less time as well as atom-linter-xo doesn't freeze while typing or even while saving.

Maybe there's an issue with the way I'm using xo?

Here's the package.json I'm using.

{
  "name": "Medusa",
  "private": true,
  "repository": {
    "type": "git",
    "url": "git+https://github.com/PyMedusa/Medusa.git"
  },
  "bugs": {
    "url": "https://github.com/PyMedusa/Medusa/issues"
  },
  "homepage": "https://github.com/PyMedusa/Medusa#readme",
  "scripts": {
    "test": "xo && npm-run-all test:js test:css test:api && ava",
    "test:js": "xo",
    "test:css": "stylelint 'static/css/*.css'",
    "test:api": "dredd --config dredd/dredd.yml",
    "build": "grunt browserify"
  },
  "devDependencies": {
    "@ava/babel-preset-stage-4": "^1.0.0",
    "ava": "^0.19.1",
    "axios": "^0.16.1",
    "babel-core": "^6.24.1",
    "babel-loader": "^7.0.0",
    "babel-preset-es2015": "^6.24.1",
    "babelify": "^7.3.0",
    "bootstrap": "^3.3.7",
    "bootstrap-3-typeahead": "^4.0.2",
    "bootstrap-webpack": "^0.0.6",
    "browserify": "^14.3.0",
    "css-loader": "^0.28.0",
    "dredd": "^3.3.0",
    "eslint-config-xo": "^0.18.1",
    "exports-loader": "^0.6.4",
    "extract-text-webpack-plugin": "^2.1.0",
    "factor-bundle": "^2.5.0",
    "file-loader": "^0.11.1",
    "grunt": "^1.0.1",
    "grunt-browserify": "^5.0.0",
    "imagesloaded": "^4.1.1",
    "imports-loader": "^0.7.1",
    "isotope": "^1.0.0-alpha.3",
    "isotope-layout": "^3.0.4",
    "jquery": "^3.2.1",
    "jquery-backstretch": "^2.1.15",
    "jquery-confirm": "^3.2.0",
    "jquery-form": "^4.2.1",
    "jquery-tokeninput": "^1.6.0",
    "jquery-ui": "^1.12.1",
    "jquery-ui-touch-punch": "^0.2.3",
    "less": "^2.7.2",
    "less-loader": "^4.0.3",
    "lodash": "^4.17.4",
    "loglevel": "^1.4.1",
    "minifyify": "^7.3.5",
    "npm-run-all": "^4.0.2",
    "pnotify": "^3.0.1",
    "qtip2": "^3.0.3",
    "style-loader": "^0.16.1",
    "stylelint-config-standard": "^16.0.0",
    "tablesorter": "^2.28.8",
    "timeago": "^1.5.4",
    "uglifyify": "^3.0.4",
    "underscore.string": "^3.3.4",
    "url-loader": "^0.5.8",
    "vanilla-lazyload": "^7.2.1",
    "webpack": "^2.4.1",
    "xo": "^0.17.1"
  },
  "xo": {
    "space": 4,
    "rules": {
      "space-before-function-paren": [
        "error",
        "never"
      ]
    },
    "envs": [
      "browser",
      "jquery"
    ],
    "globals": [
      "PNotify",
      "LazyLoad",
      "_",
      "log",
      "MEDUSA",
      "api",
      "apiKey",
      "apiRoot",
      "s"
    ],
    "ignores": [
      "static/js/lib/**",
      "static/js/*.min.js",
      "static/js/vender.js",
      "static/js/api.js"
    ]
  },
  "stylelint": {
    "extends": "stylelint-config-standard",
    "rules": {
      "indentation": [
        4,
        {
          "ignore": [
            "inside-parens"
          ],
          "message": "Please use 4 spaces for indentation. Tabs make OmgImAlexis sad.",
          "severity": "error"
        }
      ]
    },
    "ignoreFiles": [
      "static/css/lib/**",
      "static/css/*.min.css"
    ]
  },
  "dependencies": {
    "stylelint": "^7.9.0"
  }
}

@OmgImAlexis
Copy link
Contributor Author

OmgImAlexis commented Apr 25, 2017

I'm not sure if this issue is mainly with xo or atom but since it's slow both in the atom plugin as well as the cli I've kept the issue here.

Here's a screenshot of me hitting save 3 times in that config.js file. You can see that it freezes the whole UI as soon as I hit save. The red bars are showing up as "long frames".
screen shot 2017-04-25 at 5 35 38 pm

@sindresorhus
Copy link
Member

sindresorhus commented Apr 28, 2017

eslint:config-file Loading plugin:unicorn/recommended +741ms

I got +250ms. When I replaced the index.js in eslint-plugin-unicorn with module.exports = {};, it still ended up taking +225ms.

This means the problem is somewhere between these:

eslint:config-file Loading JS config file: /Users/sindresorhus/dev/xo/config/plugins.js +2ms
eslint:config-file Loading plugin:unicorn/recommended +259ms

@OmgImAlexis
Copy link
Contributor Author

OmgImAlexis commented May 2, 2017

Not sure if this is related but after the last update for linter-xo I'm now getting no linting issues shown but the time is down to less than 100ms sometimes even as low as 17ms.

@OmgImAlexis
Copy link
Contributor Author

Ignore that it seems somewhere in my testing I removed xo from the deps section. It'd be nice if xo ran as long as there was an "xo" field in the package.json or even in atom and xo itself it'd warn that it's not installed as a dep.

@sindresorhus
Copy link
Member

Note that it will only lint when XO is a dependency/devDependency in package.json.
This is to ensure it doesn't activate and conflict on projects using another linter, like ESLint. - https://github.com/sindresorhus/atom-linter-xo

@OmgImAlexis
Copy link
Contributor Author

Could it not check if "xo" is a field though? If there's a "xo" field in the package.json it most likely wouldn't have been added for any other package just the same as having a "jshint" field.

@sindresorhus
Copy link
Member

@OmgImAlexis Not sure I want to support that. There's a very good reason to have XO locally in your devDependencies; You can have different XO versions for different projects. This is really the beauty of the npm dependency system.

@OmgImAlexis
Copy link
Contributor Author

That's why I was suggesting to possibly show a warning that xo is missing in the deps if they have a xo field. For example I can still run the xo cli if I don't add the dep but have the xo field yet the atom plugin doesn't do anything and I can see others having the same issue without knowing the cause.

@OmgImAlexis
Copy link
Contributor Author

Or maybe even warn in the xo cli tool that the field was found but the dep was missing.

@pixelass
Copy link

pixelass commented Jun 1, 2017

I am having insane issues using https://github.com/avajs/ava and XO. Both packages use https://github.com/sindresorhus/globby, not sure if this in any way related.

I encounterd this problem in BIG projects. the number of targeted files doesn't matter but the size of the project itself.

ROOT
  - foo (3200 files)
  - bar (5900 files)
  - baz (10 files)

ROOT/baz/*.js

avajs/ava#1329

@OmgImAlexis
Copy link
Contributor Author

After doing some testing @pixelass you're definitely right about the source of the problem. @sindresorhus it looks like globby is causing the slow downs. For example using the atom plugin if I move my file into a new directory with nothing but a package.json file with xo setup everything is buttery smooth yet if I move the file back into my repo it can take upwards of 2 seconds to lint a file.

@pixelass
Copy link

I also worked around the issue by moving my testing and linting suite into the specific folder.

It comes with drawbacks but currently the only solution that works.

@niftylettuce
Copy link

Also incredibly slow on my end to lint a single file that is 2987 lines long. It freezes on me, and I have to resort to using eslint directly instead.

@niftylettuce
Copy link

XO is still incredibly slow, I have a file that is 548 lines of code and XO hits 100% CPU and doesn't even finish running on it.

@Qix-
Copy link

Qix- commented Sep 24, 2018

@niftylettuce Just saying "things are slow" doesn't help anything. Please give us more information. Can you give us a repository to test with? What is your system information? Which version of Node? Can you dump the module tree you have?

We can only help you as much as you help us.

@niftylettuce
Copy link

@Qix- here you go - this file does not lint and xo hits 100% cpu and hangs. I have anonymized the code for security. as soon as you comment out the conditionals the code will run by xo perfectly fine. the same exact issue happens with other files with lots of complexity/conditionals. the code never finishes running, I even left it run for 10+ minutes at one time. https://gist.github.com/niftylettuce/b6b308b06c5e6c834841d1f5516acbbf

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

Thanks for the details. Out of curiosity did you test that code with eslint?
It might be one of the rule that we use that is slow in that context.

@niftylettuce
Copy link

niftylettuce commented Sep 28, 2018

I believe it's xo/prettier causing it, eslint runs fine on the file

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

Ok. If you have already done the analysis and figured out it's Prettier, can you open an issue in the Prettier repo then?

@niftylettuce
Copy link

niftylettuce commented Sep 28, 2018

I just ran it with prettier by itself and it runs fine as well.

Here's my relevant xo config from package.json:

  "xo": {
    "extends": "prettier",
    "plugins": [
      "prettier"
    ],
    "rules": {
      "unicorn/catch-error-name": [
        "error",
        {
          "name": "err"
        }
      ],
      "prefer-destructuring": [
        "error",
        {
          "array": true
        },
        {
          "enforceForRenamedProperties": false
        }
      ],
      "prettier/prettier": "error",
      "max-len": "off",
      "no-use-extend-native/no-use-extend-native": "off",
      "max-nested-callbacks": [
        "error",
        5
      ],
      "capitalized-comments": "off",
      "camelcase": "off",
      "no-warning-comments": "off",
      "complexity": [
        "error",
        36
      ],
      "no-multi-assign": "off",
      "max-depth": [
        "error",
        5
      ],
      "max-params": [
        "error",
        5
      ]
    },
    "envs": [
      "node"
    ],
    "space": true,
    "overrides": [
      {
        "plugins": [
          "prettier"
        ],
        "files": [
          "scripts/*.js",
          "scripts/**/*.js",
          "app.js"
        ],
        "rules": {
          "unicorn/no-process-exit": "off"
        }
      },
      {
        "plugins": [
          "prettier"
        ],
        "files": [
          "test/*.js",
          "test/**/*.js"
        ],
        "envs": [
          "node"
        ]
      },
      {
        "plugins": [
          "prettier",
          "compat"
        ],
        "parserOptions": {
          "sourceType": "script"
        },
        "files": [
          "assets/public/js/*.js"
        ],
        "envs": [
          "browser",
          "jquery"
        ],
        "rules": {
          "compat/compat": "error",
          "promise/prefer-await-to-then": "off"
        }
      }
    ]
  }

@niftylettuce
Copy link

Just to confirm node_modules/.bin/eslint some-file.js and node_modules/.bin/prettier some-file.js both work fine. It is only when node_modules/.bin/xo some-file.js that it hangs.

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

node_modules/.bin/eslint some-file.js is not a relevant test until you create and .eslintrc file with the rules that XO use.

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

So from my tests the problematic rule is 'require-atomic-updates': 'error'. If you disable this one it runs in around 1s.

@niftylettuce
Copy link

@pvdlg Interesting find. Correct me if I'm wrong or missing the right config, here are contents of .eslintrc - do we have some sample .eslintrc file for testing eslint as used by xo by default. I'm guessing I'm missing plugins or something from https://github.com/xojs/xo/blob/master/config/plugins.js as well?

{
  "extends": "xo"
}

@niftylettuce
Copy link

Looks like this is filed here already eslint/eslint#10893

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

It was release today in 5.6.1 so I guess if you update your dependency tree you'll get the new version.

I just tested after doing a yarn install and it works fine (~1s to lint that file).
You have to delete your lock files to make sure you don't use an outdated eslint version.

@niftylettuce
Copy link

Should we also version bump here https://github.com/xojs/xo/blob/master/package.json#L55? Not sure if we need a deprecation notice to alert users of bug.

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

No, it's defined as a range (^5.5.0) so every version within that range will be installed automatically. Unless you make the choice to have a lock file which lock your dependencies to outdated versions.

We are not going to update each dependency definition every time there is a minor or patch release. That's the point of using npm and dependency range, you get the fix automatically (again, unless you use a lock file)

@niftylettuce
Copy link

I just upgraded and tried to rm -rf node_modules and reinstall via yarn, using v5.6.1 and still seems to have the same issue. Will try once more... not sure if you could test too on your end?

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

Yep I tested and it works fine. I created some-file.js with the code you provied in the Gist and dropped that in a project that use XO. Then I run xo some-file.js which returns a bunch or linrting errors in 1 second.

My XO config is:

  "xo": {
    "prettier": true,
    "space": true
  }

Maybe you have a different config, but as you didn't provide it cannot test in the same exact circumstances.

@niftylettuce
Copy link

@pvdlg I provided my config above here - can you try it out? #212 (comment)

@niftylettuce
Copy link

You could omit the overrides block - not necessary btw.

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

Oops missed that one. I'm checking

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

Same, it runs in around 1 second. Which version of XO are you using?

@niftylettuce
Copy link

@pvdlg here is a narrowed down xo config that fails consistently for me:

  "xo": {
    "extends": "prettier",
    "plugins": [
      "prettier"
    ],
    "envs": [
      "node"
    ],
    "space": true
  }

here are versions:

xo --version
0.23.0

eslint --version
v5.6.1

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

Same result. Works in 1s.
Why using the prettier plugin in your config?
XO is integrated with Prettier via the prettier option.

Do you have a lock file?
What do you get from node_modules/.bin/eslint --version?

@niftylettuce
Copy link

I did a clean of npm/yarn cache, completely removed yarn.lock and rm -rf node_modules and it works 🎉

That was painful - thank you so much @pvdlg for your time and patience here. Do you have a Patreon or way to donate for your help?

@pvdlg
Copy link
Contributor

pvdlg commented Sep 28, 2018

That was probably due to yarn.lock containing an outdated version of eslint.

That was painful - thank you so much @pvdlg for your time and patience here. Do you have a Patreon or way to donate for your help?

Sindre the creator of XO has a Patreon. I personally don't need money for my OSS work.
Contributions to XO are always welcome and appreciated and can take many form: bug fixes, new features, issue reporting, documentation improvement, support to other users here or on Gitter, etc... Promoting the XO project is also a nice way to support it.

@Qix-
Copy link

Qix- commented Sep 28, 2018

Sindre the creator of XO has a Patreon.

12% of all NPM downloads are of @sindresorhus's code. You can find his well-deserved Patreon here.

@niftylettuce
Copy link

@OmgImAlexis please close issue

@OmgImAlexis
Copy link
Contributor Author

@OmgImAlexis please close issue

Why? Still an issue for me.

@niftylettuce
Copy link

This seems to be fixed on my side (after updating)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants