Skip to content

fix(eslint): config will not use eslintrc from this project#4

Merged
kentcdodds merged 1 commit intomasterfrom
pr/fix-example
Jan 17, 2017
Merged

fix(eslint): config will not use eslintrc from this project#4
kentcdodds merged 1 commit intomasterfrom
pr/fix-example

Conversation

@kentcdodds
Copy link
Copy Markdown
Member

@kentcdodds kentcdodds commented Jan 17, 2017

There was a problem with the way that eslint fix was applied which
basically resulted in test files in this project inheriting from the
eslintConfig from this project (prettier-eslint). So I added
useEslintrc: false to the config which I believe will fix the issue
(can be overridden)

Also added a test for the README example so this doesn't happen again!

Could I get a review from @exdeniz and @demoneaux (and anyone else interested? ping @gyandeeps?)

Closes #2

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 17, 2017

Current coverage is 100% (diff: 100%)

Merging #4 into master will not change coverage

@@           master    #4   diff @@
===================================
  Files           2     2          
  Lines          48    49     +1   
  Methods         0     0          
  Messages        0     0          
  Branches        0     0          
===================================
+ Hits           48    49     +1   
  Misses          0     0          
  Partials        0     0          

Powered by Codecov. Last update c75290c...e8518fc

@kentcdodds kentcdodds mentioned this pull request Jan 17, 2017
Copy link
Copy Markdown
Member Author

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some notes to the PR to make it easier to see what's going on.

return {
'/mock/default-config': {
rules: {
semi: [2, 'never'],
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, this was actually inherited via the configuration from this project.

text: sourceCode,
eslintConfig: {
parserOptions: {
ecmaVersion: 7,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the reason that you got undefined back. Because ESLint actually failed to parse the code (because it used const).

const pretty = prettify(text, prettierOptions)
return eslintFix(pretty, eslintConfig)
const eslintFixed = eslintFix(pretty, eslintConfig)
return eslintFixed
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made this a variable name just so I can log it easier. Thinking that it could be useful to expose better logging control to log what the text is (if you want a silly amount of logs for example).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we'll do that later :)

function eslintFix(text, eslintConfig) {
const eslintOptions = {
// overrideables
useEslintrc: false,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be overridden. I don't think that it's advisable to do though or whether this would even be something you'd need to do. But I thought it'd be good to expose a way to override it.

Copy link
Copy Markdown

@gyandeeps gyandeeps Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think people would want to override this so that eslint can use their local .eslintrc files. Am i missing something here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that makes sense. Normally, I expect people to simply pass the filePath and we'll get the eslintConfig from that (see getConfig below). But if people are providing some special config in addition to what ESLint can find with the .eslintrc then that makes sense :)

},
output: defaultOutput(),
},
{
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this so we don't have trouble in the future :)

@gyandeeps
Copy link
Copy Markdown

LGTM 👍

@kentcdodds kentcdodds force-pushed the pr/fix-example branch 2 times, most recently from 9959b96 to 32c2002 Compare January 17, 2017 18:07
]
},
{
"login": "gyandeeps",
Copy link
Copy Markdown
Member Author

@kentcdodds kentcdodds Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok if I add you as a contributor @gyandeeps? See this for what it'll look like.

There was a problem with the way that eslint fix was applied which
basically resulted in test files in this project inheriting from the
`eslintConfig` from _this project_ (`prettier-eslint`). So I added
`useEslintrc: false` to the config which I believe will fix the issue
(can be overridden)

Also added a test for the README example so this doesn't happen again!
]
},
{
"login": "exdeniz",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@exdeniz, are you ok with me adding you to the contributors list? See this for what it will look like.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes/

]
},
{
"login": "demoneaux",
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@demoneaux, are you ok with me adding you to the contributors list? See this for what it will look like.

@kentcdodds
Copy link
Copy Markdown
Member Author

@exdeniz and @demoneaux, I'm going to go ahead and merge this. If you'd like to remove yourself from .all-contributorsrc go ahead and let me know (or make a PR yourself). Thanks for your contribution!

@kentcdodds kentcdodds merged commit 9048d17 into master Jan 17, 2017
@kentcdodds kentcdodds deleted the pr/fix-example branch January 17, 2017 23:43
Copy link
Copy Markdown

@bnjmnt4n bnjmnt4n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example not work

5 participants