xo icon indicating copy to clipboard operation
xo copied to clipboard

v0.13.0 crashes on plugin shared config

Open jamestalmage opened this issue 10 years ago • 12 comments

Issuehunt badges

I tried to use:

"overrides": [
  {
    "files": ["test.js"],
    "extends": ["plugin:ava/recommended"]
  }
]

And things crashed.

TypeError: Cannot read property 'charAt' of null
    at posix (/Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/path-is-absolute/index.js:4:13)
    at isFilePath (/Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/eslint/lib/config/config-file.js:80:12)
    at /Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/eslint/lib/config/config-file.js:344:20
    at Array.reduceRight (native)
    at Object.applyExtends (/Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/eslint/lib/config/config-file.js:338:28)
    at loadConfig (/Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/eslint/lib/config.js:63:37)
    at new Config (/Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/eslint/lib/config.js:171:44)
    at CLIEngine.executeOnFiles (/Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/eslint/lib/cli-engine.js:493:28)
    at runEslint (/Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/xo/index.js:67:16)
    at /Users/jamestalmage/WebstormProjects/async-task-pool/node_modules/xo/index.js:40:11

I am not sure if it is overrides specific

There is a $80.00 open bounty on this issue. Add more on Issuehunt.

jamestalmage avatar Mar 22 '16 04:03 jamestalmage

I am not sure if it is overrides specific

It does not appear to be

jamestalmage avatar Mar 26 '16 22:03 jamestalmage

@jamestalmage Probably https://github.com/sindresorhus/xo/blob/bfb1b4fed0e6b8d946c341bdc06f65d63265a0db/options-manager.js#L105-L116 Maybe we should ask ESLint to expose that method?

sindresorhus avatar Apr 08 '16 19:04 sindresorhus

I'm getting the same error when I do this in the package.json:

  "xo": {
    "space": 2,
    "plugin": ["lodash-fp"],
    "extends": ["plugin:lodash-fp/recommended"]
  }

or with the cli

xo --plugin lodash-fp --extend plugin:eslint-plugin-lodash-fp/recommended

but it works fine when I go and modify xo configuration in the node_modules

module.exports = {
    plugins: [
        'lodash-fp',
        'no-use-extend-native',
        'import-order',
        'ava',
        'xo',
        'promise'
    ],
    extends: [
        'plugin:lodash-fp/recommended',
        'plugin:ava/recommended',
        'plugin:xo/recommended'
    ],
    rules: {
        'no-use-extend-native/no-use-extend-native': 2,
        'import-order/import-order': 2,
        'promise/param-names': 2
    }
};

(v0.15)

jfmengels avatar May 05 '16 14:05 jfmengels

https://github.com/sindresorhus/xo/blob/6ec33e9776bb0da6b79529969c1c32aa098f0efc/options-manager.js#L122-L136

v0.16

Just got this. If you try to use a plugin, it results in the options array passed to eslint having a null in the extends array (because resolve-from doesn't find it). Tried a few other ways, but couldn't get a plugin's recommended config to work in any way.. Any steps forward with this?

Tapppi avatar Jun 22 '16 00:06 Tapppi

Any steps forward with this?

Opening an issue on ESLint asking them to expose the method for resolving extends, so we don't have to implement a "broken" version ourselves. https://github.com/eslint/eslint/issues

sindresorhus avatar Jun 22 '16 00:06 sindresorhus

Any steps backward with this to make it work i.e. any previous version of xo or eslint which can fix this issue?

abhisekp avatar Sep 22 '16 23:09 abhisekp

ESLint issue opened: https://github.com/eslint/eslint/issues/7328

sindresorhus avatar Oct 09 '16 16:10 sindresorhus

The ESLint team says the underlying problem has been fixed in ESLint, so we should be able to rip out our custom resolve logic: https://github.com/xojs/xo/blob/510d02e3c4d26d07a7ba9bdcbd03f93987d596bb/lib/options-manager.js#L254-L282

We need to add a lot of test to confirm everything is still working though.

sindresorhus avatar Jan 09 '19 08:01 sindresorhus

@issuehuntfest has funded $80.00 to this issue. See it on IssueHunt

IssueHuntBot avatar Jan 09 '19 16:01 IssueHuntBot

I think current resolve logic on shared config still don't include baseConfig.cwd

yaodingyd avatar Jan 18 '19 20:01 yaodingyd

Eslint has a rfc https://github.com/eslint/rfcs/pull/7 to simplify the resolution of sharable configs. Maybe we wait on this first.

yaodingyd avatar Jan 20 '19 02:01 yaodingyd

Yeah, probably smart.

sindresorhus avatar Jan 20 '19 13:01 sindresorhus