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

Unable to customize certain rules via shareable config #71

Open
vadimdemedes opened this issue Jan 8, 2016 · 17 comments
Open

Unable to customize certain rules via shareable config #71

vadimdemedes opened this issue Jan 8, 2016 · 17 comments
Labels
bug 💵 Funded on Issuehunt This issue has been funded on Issuehunt help wanted

Comments

@vadimdemedes
Copy link

vadimdemedes commented Jan 8, 2016

Issuehunt badges

Using latest xo (master branch), I'm unable to customize babel/object-curly-spacing rule via shareable config.

package.json:

{
  "extends": "my-config"
}

my-config:

{
  "rules": {
    "babel/object-curly-spacing": 0
  }
}

file.js:

{ key: 'value' }

Given these files, xo throws error:

screen shot 2016-01-08 at 10 18 49 pm

If I override babel/object-curly-spacing in package.json, it works as expected and I no longer get errors:

{
  "rules": {
    "babel/object-curly-spacing": 0
  }
}

Related: https://github.com/sindresorhus/xo/blob/master/options-manager.js#L98

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

@sindresorhus
Copy link
Member

Related: https://github.com/sindresorhus/xo/blob/2d26d79ea81f893fc7b1ff9e586c1e74ad28c830/options-manager.js#L98

Hmm. We just set the default value there. It's later extended by your custom config.

@vadimdemedes
Copy link
Author

It's later extended by your custom config.

Seems like it does not for some reason. Needs investigation.

@kevva
Copy link
Contributor

kevva commented Jan 12, 2016

Those rules gets set in the root of the options sent in to eslint and will therefore take precedence over any configs. Configs will only override other configs (I think). The rules referenced in https://github.com/sindresorhus/xo/blob/2d26d79ea81f893fc7b1ff9e586c1e74ad28c830/options-manager.js#L98 are only overridable through setting rules in the package.json, or wherever your config lives.

@vadimdemedes
Copy link
Author

@jamestalmage
Copy link
Contributor

What would be the consequence of moving those defaults into another base config that we conditionally add to extends, instead of force setting them like that?

@kevva
Copy link
Contributor

kevva commented Jan 13, 2016

I don't think there are any consequences other than creating a config for it may seem unnecessary but in this case it might be needed.

@vadimdemedes
Copy link
Author

Why are those rules not in the default xo (or xo-react) config in the first place?

@sindresorhus
Copy link
Member

Why does xo forces these default rules here (https://github.com/sindresorhus/xo/blob/2d26d79ea81f893fc7b1ff9e586c1e74ad28c830/options-manager.js#L98) ?

The Babel parser and plugin have some incompatible rules. So we first need to reset the original rules, then set the Babel ones. That line just sets it to the same value as in eslint-config-xo.

What would be the consequence of moving those defaults into another base config that we conditionally add to extends, instead of force setting them like that?

That would be the way to go. Anyone wanna do a PR?

Why are those rules not in the default xo (or xo-react) config in the first place?

They are, but here we do something different as we're using the esnext rules even though the esnext option is not set. We do this so esnext features will still work without the esnext option, just not linted as such.

@sindresorhus
Copy link
Member

This should be fixed in cece3dd, but with ESLint changes and this, it would be nice if you all could take a look at the changes.

@vdemedes Can you try it out in practice?

@sindresorhus sindresorhus reopened this Feb 27, 2016
@vadimdemedes
Copy link
Author

Tried it out in a real app and now shareable configs don't work at all:

$ npm install eslint-config-vdemedes

package.json:

"xo": {
  "extends": ["vdemedes"]
}

output when running latest xo:

Error: Cannot find module 'eslint-config-vdemedes' from '/Users/vdemedes/Projects/xo/node_modules'
Referenced from:
    at Function.module.exports [as sync] (/Users/vdemedes/Projects/xo/node_modules/resolve/lib/sync.js:33:11)
    at resolve (/Users/vdemedes/Projects/xo/node_modules/eslint/lib/config/config-file.js:417:38)
    at load (/Users/vdemedes/Projects/xo/node_modules/eslint/lib/config/config-file.js:436:24)
    at /Users/vdemedes/Projects/xo/node_modules/eslint/lib/config/config-file.js:355:36
    at Array.reduceRight (native)
    at Object.applyExtends (/Users/vdemedes/Projects/xo/node_modules/eslint/lib/config/config-file.js:338:28)
    at loadConfig (/Users/vdemedes/Projects/xo/node_modules/eslint/lib/config.js:63:37)
    at new Config (/Users/vdemedes/Projects/xo/node_modules/eslint/lib/config.js:170:44)
    at CLIEngine.executeOnFiles (/Users/vdemedes/Projects/xo/node_modules/eslint/lib/cli-engine.js:492:28)
    at runEslint (/Users/vdemedes/Projects/xo/index.js:67:16)

Might be related: eslint/eslint#5411.

@vadimdemedes
Copy link
Author

Added a PR to demonstrate this issue - #83.

@sindresorhus
Copy link
Member

I ended up reverting to the previous workaround. Don't have time to fix this properly right now. New version is out btw. I still would like to see this fixed at some point.

@fregante
Copy link
Member

fregante commented Mar 4, 2017

I ended up reverting to the previous workaround

Are you saying that there is another way to have different configs for subfolders?

@sindresorhus
Copy link
Member

@bfred-it I'm not sure what you're asking? Doesn't seem relevant to this thread.

@fregante
Copy link
Member

fregante commented Mar 4, 2017

Sorry, I was referring to the overrides property. From what I understand it was disabled and it was dependent on this issue (as you said here #78 (comment))

I thought you were referring to overrides in "I ended up reverting to the previous workaround (for overrides?)"

@sindresorhus
Copy link
Member

@bfred-it I don't remember, but it ended up landing regardless: https://github.com/sindresorhus/xo#config-overrides

@IssueHuntBot
Copy link

@IssueHunt has funded $60.00 to this issue.


@issuehunt-oss issuehunt-oss bot added the 💵 Funded on Issuehunt This issue has been funded on Issuehunt label May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 💵 Funded on Issuehunt This issue has been funded on Issuehunt help wanted
Projects
None yet
Development

No branches or pull requests

6 participants