Prettier-atom: eslint --fix does not run with ESLint Integration

Created on 31 Dec 2017  ยท  79Comments  ยท  Source: prettier/prettier-atom

Hi,

Similar to #119, after disabling "Fix errors on save" in linter-eslint and enabling ESLint integration, saving doesn't seem to run the eslint --fix formatting.

โœ“ eslint --fix on CLI works as expected.
โœ“ prettier-eslint on CLI works as expected.
โœ“ linter-eslint Atom plugin with "Fix errors on save" works as expected.
โœ“ Prettier Atom plugin works as expected without ESLint integration.
โœ— Prettier Atom plugin does not works as expected with ESLint integration.

For this case, I created a minimal repo: https://github.com/ozum/case-prettier-atom-eslint
Please note that I also included zipped version of .atom folder (~50 MB) in the repo.

In that repo index.js should be added a dangling comma before save, but it is not added.

Kind Regards,

Atom version: 1.23.1
prettier-atom version: 0.44.0
prettier version: 1.9.2
prettier-eslint version: 8.7.0
prettier-atom configuration: {
  "formatOnSaveOptions": {
    "enabled": true,
    "respectEslintignore": true,
    "showInStatusBar": false,
    "javascriptScopes": [
      "source.js",
      "source.jsx",
      "source.js.jsx",
      "source.babel",
      "source.js-semantic",
      "text.html.basic",
      "text.html.vue"
    ],
    "typescriptScopes": [
      "source.ts",
      "source.tsx",
      "source.ts.tsx"
    ],
    "cssScopes": [
      "source.css",
      "source.less",
      "source.css.less",
      "source.scss",
      "source.css.scss",
      "source.css.postcss"
    ],
    "jsonScopes": [
      "source.json"
    ],
    "graphQlScopes": [
      "source.graphql"
    ],
    "markdownScopes": [
      "source.md",
      "source.gfm",
      "text.md"
    ],
    "excludedGlobs": [],
    "whitelistedGlobs": [],
    "isDisabledIfNotInPackageJson": false,
    "isDisabledIfNoConfigFile": false
  },
  "prettierEslintOptions": {
    "prettierLast": false
  },
  "useEslint": true,
  "useStylelint": false,
  "useEditorConfig": true,
  "prettierOptions": {
    "singleQuote": false,
    "bracketSpacing": true,
    "semi": true,
    "useTabs": false,
    "jsxBracketSameLine": false,
    "printWidth": 80,
    "tabWidth": "auto",
    "trailingComma": "none",
    "parser": "babylon"
  }
}

bug external

Most helpful comment

okay I released prettier-atom 0.48.0 with prettier-eslint 8.7.6

All 79 comments

@ozum Thanks for providing the example repo. I downloaded a clone and npm installed, and then I opened atom to that folder and opened index.js and hit save. At this point a trailing comma did get added. Are you sure you npm installed?

@robwise Thank you for the answer. Yes, I did npm install and all libraries from package.json are there.

However, it seems you were using your own .atom configuration folder, not the one I provided in repository. (.atom in the repo does not have file icons).

Could you unzip .atom.zip from that repo into an empty folder and copy your atom editor into same directory, and use that Atom to see problem. (Please note that you should create that empty folder outside of case-prettier-atom-eslint.)

I have the same issue, with the only difference that eslint --fix is not run after manually running the prettifier. Started happening after upgrading from 0.43.1 -> 0.45.0. Running eslint --fix manually produces the desired result.

I'm also experiencing this after the last update.

Specially with this rule on .eslintrc:

"arrow-parens": [2, "always"],

As you can see in the image below, it is not being fixed when saved.
image

@westmark I just downgraded prettier-eslint to 0.43.1 and am still getting the same issue. After a little digging, this looks like an issue with prettier-eslint itself, because I get the same output when I apply prettier-eslint via CLI (it ignores my .eslintrc settings).

@tquetano-r7 Yeah, prettier-eslint seems to be the culprit here.

I tracked the problem to the 8.5.0 release of prettier-eslint. Not sure which commit though

I just downgraded prettier-eslint to version 8.6.2 and it fixed my problems. It's definitely related to version 8.7.0.

I just downgraded prettier-eslint to version 8.6.2 and it fixed my problems. It's definitely related to version 8.7.0.

I can't confirm this.

I Tried installing the mentioned version and still do not work.

I'm using version 8.2.1

@mrandalldh I cannot confirm this either. Making sure I followed the same steps you did for this workaround:

  1. go to the package's node modules folder => cd ~/.atom/packages/prettier-atom/node_modules
  2. delete the existing dependency folder => rm -rf ./prettier-eslint
  3. install the specific version => npm i [email protected]

I validated that this included the dependency version you mentioned correctly, but the problem persists.

@planttheidea I sort of followed those same instructions. The only difference for me was I went directly into the ~/.atom/packages/prettier-atom/package.json file and changed the prettier-eslint to version 8.6.2. Then I did a npm install and restarted Atom, and it worked!

For clarification I am using version 1.23.1 and prettier-atom version 0.45.0. Also, I am using ESLint Integration with an .eslintrc.js file in my root of my app.

@planttheidea @mrandalldh After downgrade to [email protected], it works.

@bipedd this is indeed true ... but how did u arrive at this version? did u just keep trying older and older until u hit jackpot?

@planttheidea I guessed that it's the problem of prettier-eslint, so downgrade to [email protected] or lower can be a solution. I checked the dependencies of prettier-atom from latest to oldest. Finally, it turns out [email protected] is the one that I am looking for.

@bipedd thanks so much ๐Ÿ˜„ ...after a downgrade to [email protected], things are back to normal!

I've been going crazy running prettier-atom (manually) then linter-eslint (on-save) to fix files based on eslint configuration. This fixes it so far till we can get a stable fixed version out.

PS: Make sure to uninstall prettier-atom from the atom packages in settings. Then use apm install [email protected] to install the working version.

I've added functionality to prettier-eslint to infer prettier options from eslint-plugin-prettier via the eslint rule prettier/prettier.

My mistake here was maybe that this didn't go into a new major version but in a feature release.

The changed functionality is this.

In the case we infer prettier options from an eslint config we now check if there's a rule prettier/prettier if there's such a rule, extend the provided prettier options with the prettier options in prettier/prettier rule and stop inferring; don't infer from the regular eslint rules as you specifically configured prettier options in your eslint config.

Could you please verify if this is what you're seeing or if this is something else.

This functionality was added in prettier-eslint@8.6.0.

In 8.7.0 of prettier-eslint I stripped away the prettier/prettier rule from the fixable rules I give eslint when formatting in an attempt to disable prettier from running as part of eslint --fix, this did however not stop prettier from running but just made it run with its defaults, which was most likely the cause of this trouble.

An upgrade of prettier-eslint to 8.7.1 should hopefully resolve this.

@zimme Thanks for giving this your attention. However, 8.7.1 did not resolve this for me I'm afraid. Had to downgrade to 8.4.0. I stand firm in my earlier assessment that this bug was introduced in 8.5.0.

@zimme I second @westmark on this. Forcing prettier-atom to use [email protected] fixes this issue but not with [email protected].

I can confirm upgrading to [email protected] has no effect for me. Downgrading to 0.38.0 did the trick immediately.

As mentioned by @zainxyz, make sure to uninstall the current version beforehand.

This does look like a bad regression though, might be good to update the label on this issue, so people know where to go.

Hi. 0.38.0 works with .eslintrc, but .eslintrc.js is still not detected by prettier-atom

@zeakd can you make another issue for that? That's unrelated to this issue AFAICT

We seem to have found the problem with prettier-eslint that is most probably responsible for this problem.

I hope to have a fix out today.

[email protected] is out, please test with that version and see if the problem is resolved.

@zimme

I updated to [email protected], then updated "prettier-eslint": "^8.7.0", to "prettier-eslint": "8.7.2", in the prettier-atom/package.json.

Steps -

  1. rimraf node_modules && npm i
  2. Close and Re-Open Atom.app
  3. Mess up some code in an eslint configured project file
  4. Attempt to prettify Ctrl+Alt+F
  5. Result...failure

The prettier-atom did not comply to my eslintrc.js file.

Reverting back to [email protected] now.

PS: I tried it with [email protected] as well as [email protected]

Thanks.

We tracked down the problem to the logic that was filtering out unfixable eslint rules. It's now removed and things should be back to normal.

Please test the latest version of prettier-eslint.

Still, does not run.

I updated Atom, prettier-atom and related npm packages to latest versions.

See updated sample repo: https://github.com/ozum/case-prettier-atom-eslint

To test it unzip .atom.zip from that repo into an empty folder and copy your atom editor into same directory, and use that Atom to see problem. (Please note that you should create that empty folder outside of case-prettier-atom-eslint folder.)

Versions I tested:
Atom: 1.23.3
prettier-atom: 046.0

From package.json:
"eslint": "^4.15.0",
"prettier-eslint": "^8.7.4",
"prettier-eslint-cli": "^4.7.0"

@zimme - I have to agree with @ozum.

I updated to the latest version of [email protected] inside the [email protected] package, and it still did not resolve the issue.

Still using [email protected] since that seems to be the perfect one so far. Disregarding any additional updates afterwords.

Thanks.

Hmm, so I see that [email protected] is using version ^6 of prettier-eslint. Which is before prettier-eslint even supported prettier config files.

I'm so confused, is the problem coming from prettier-atom or prettier-eslint? prettier-atom 38 was released half a year ago but people only started having this problem 2 weeks ago.

@robwise, I'm thinking that people started to have some problems with [email protected]+, and I guess after a while people started to notice that the order how the config resolution was done didn't meet expectations.

I do believe this was reinforced with [email protected] where some people might start to have problems because they have a prettier/prettier eslint rule, which results in inferring prettier options from that rule and no other eslint rules.

On top of that 8.6.0 also stripped away any eslint rules that weren't fixable, but this logic was broken, so that's been removed now and that fixed the problem for some people.

I still believe I need to refactor the handling of config resolution in prettier-eslint and involve its consumers in the process of that to be able to solve all cases.

@zimme Okay so nothing I need to fix on this end? Everyone was either experiencing the prettier-eslint bug or was thinking there was a bug when really they just didn't totally understand how their config worked?

@robwise That's what I'm thinking, however it would be good with some verification from the people following this issue.

Alright so I'm going to add even more confusion into things. Just for giggles I decided to completely uninstall and then reinstall the plugin (latest version, 0.46.0) ... and it works now. Respects my .eslintrc, handles it like a champ. :man_shrugging:

My only thought was maybe there was a sub-dependency of some nested package that has too loose of versioning that, upon re-installation, caught the latest version of itself which righted the ship. But for those continuing to experience pains, try completely uninstalling and re-installing the plugin. Maybe you'll have the same luck I did.

EDIT: Spoke too soon. Suddenly it started not working again. Why must it toy with me so? :sob:

@robwise @zimme I'm not sure I understand your conclusion.
At the moment, my config is still not working while it has been for a few month before that.
My setup is as follow:
Atom 1.22.1
prettier-atom 0.46.0
I've deleted node_modules and ran yarn to install all dependencies from scratch in the package folder, here is an extract of the yarn.lock:

prettier-eslint-cli@^4.7.0:
  version "4.7.0"
  resolved "https://registry.yarnpkg.com/prettier-eslint-cli/-/prettier-eslint-cli-4.7.0.tgz#66421dd8e03ea67d6ba28d9e16b0de01559bc8ad"
  dependencies:
    arrify "^1.0.1"
    babel-runtime "^6.23.0"
    boolify "^1.0.0"
    camelcase-keys "^4.1.0"
    chalk "2.3.0"
    common-tags "^1.4.0"
    eslint "^4.5.0"
    find-up "^2.1.0"
    get-stdin "^5.0.1"
    glob "^7.1.1"
    ignore "^3.2.7"
    indent-string "^3.1.0"
    lodash.memoize "^4.1.2"
    loglevel-colored-level-prefix "^1.0.0"
    messageformat "^1.0.2"
    prettier-eslint "^8.5.0"
    rxjs "^5.3.0"
    yargs "10.0.3"

prettier-eslint@^8.5.0, prettier-eslint@^8.7.0:
  version "8.7.0"
  resolved "https://registry.yarnpkg.com/prettier-eslint/-/prettier-eslint-8.7.0.tgz#c54ce5affee129674958bd40a7899f97128c975a"
  dependencies:
    babel-runtime "^6.26.0"
    common-tags "^1.4.0"
    dlv "^1.1.0"
    eslint "^4.0.0"
    indent-string "^3.2.0"
    lodash.merge "^4.6.0"
    loglevel-colored-level-prefix "^1.0.0"
    prettier "^1.7.0"
    pretty-format "^22.0.3"
    require-relative "^0.8.7"
    typescript "^2.5.1"
    typescript-eslint-parser "^11.0.0"

prettier-stylelint@^0.4.2:
  version "0.4.2"
  resolved "https://registry.yarnpkg.com/prettier-stylelint/-/prettier-stylelint-0.4.2.tgz#62845e342f786218b008da69eef14f0a5c05bcfb"
  dependencies:
    cosmiconfig "^3.0.1"
    debug "^3.0.1"
    get-stdin "^5.0.1"
    globby "^6.1.0"
    ignore "^3.3.5"
    import-local "^0.1.1"
    meow "^3.7.0"
    pify "^3.0.0"
    prettier "^1.7.0"
    resolve-from "^4.0.0"
    stylelint "^8.1.1"
    temp-write "^3.3.0"
    tempy "^0.2.1"
    update-notifier "^2.2.0"

[email protected]:
  version "1.9.2"
  resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.9.2.tgz#96bc2132f7a32338e6078aeb29727178c6335827"

prettier@^1.7.0:
  version "1.7.0"
  resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.0.tgz#47481588f41f7c90f63938feb202ac82554e7150"

And my project .eslintrc has a single extend: https://github.com/vizeat/eslint-config-vizeat

{
  "root": true,
  "extends": [
    "vizeat/react"
  ],
}

None of the rules coming from my .eslintrc that used to override prettier's behavior are working.
But if I run prettier-eslint-cli manually, everything works as expected.

Am I missing something that would make it all work again ?

My config also broke recently and I just found this issue.

Am I missing something that would make it all work again ?

@p-j can you use the version of prettier-eslint that has the fix in it (8.7.4)?

@p-j can you use the version of prettier-eslint that has the fix in it (8.7.4)?

@robwise Example repo (https://github.com/ozum/case-prettier-atom-eslint) has 8.7.4 and has same problem.

Same here, just updated prettier-eslint to 8.7.4 and I still experience the problem

I upgraded prettier-atom and verified that it comes with the latest prettier-eslint.
No luck, still removing spaces and messing with quotes and indentation here an there...

Redundant "_same here_" to note that I too am still seeing the issue.

@robwise I think the most emergency is that the prettier-atom should lock the dependency of prettier-eslint and release a new version to make the plugin work properly. This serious issue has been existing for over 2 weeks, and even though it is not the fault of prettier-atom itself, a solution (even a temporary solution or hack) should be presented ASAP.

I think I've tracked this issue down to the point in prettier-eslint where we're calling eslint's getConfigForFile and for some reason it can't find a config, at which point it sets the eslint config to be { rules: {} } and that's why the eslint config isn't respected....

@robwise I think the most emergency is that the prettier-atom should lock the dependency of prettier-eslint and release a new version to make the plugin work properly. This serious issue has been existing for over 2 weeks, and even though it is not the fault of prettier-atom itself, a solution (even a temporary solution or hack) should be presented ASAP.

@hustKiwi The problem is that there is a huge amount of confusion as to what is causing the problem and what will help fix it. If I knew what temporary solution or hack would solve it, I would have done it a long time ago (?). I usually fix bugs within hours of them coming up as long as I'm able to reproduce and they are actually coming from prettier-atom.

I can cut a release with a new prettier-eslint version, but note that even right after your comment, the maintainer of prettier-eslint says there's still a problem with that repo, so I'm not sure that would help. I don't even know what version of prettier-eslint we could roll back to as there's even confusion on that; many people are claiming you have to rollback prettier-eslint _and_ prettier-atom to versions that were released no more recently than half a year ago, despite the problem only occurring two weeks ago. I'm not blaming those people (I'm grateful for their help in diagnosing the problem), I'm just pointing out that I don't know how to do what you're asking.

Well @robwise, FWIW, I just downgraded prettier-eslint back to version 8.6.2 again, and it worked for me, again. I did not rollback prettier-atom to a previous version; to be clear, I only rolled back prettier-eslint, ran an npm i in the prettier-atom directory, _restarted atom_, and it worked.

I am using Atom 1.23.3 x64, on a Mac, now with version 0.47.0 of prettier-atom. I am not suggesting that the other users are mistaken, but I would like to confirm that the process they should take to fix this issue is the following:

  • In the prettier-atom folder, in package.json change the value of prettier-eslint to 8.6.2
  • Run npm install in that same folder
  • Confirm that the package.json of the prettier-eslint is now 8.6.2
  • Restart Atom

@mrandalldh If this is the case, then I can maybe lock the bundle prettier-eslint version to exactly 8.6.2 and cut a new release like that? I'm not sure if people would still have to manually reinstall the package to pick that change up though (as opposed to a simple update) but maybe it's better than nothing?

I thought that if you lock the prettier-eslint version and push an update (to version 0.48.0), it would notice the change and reinstall that dependency. This should work, and at this point, you're right, it is better than nothing.

@mrandalldh i followed these steps to the letter, this does not work for me. I am using Arch Linux rather than Mac, so maybe it is a platform thing ... but no dice for me. :(

@tquetano-r7 Which version do you have to downgrade to for it to work?

PR for locking down prettier-eslint to 8.6.2 is here: https://github.com/prettier/prettier-atom/pull/353

Will cut a release as soon as we pass CI

@robwise like everyone else, ive been downgrading to 0.38.0 and it works again. I havent meticulously gone through each subsequent version to see where my cutoff is, but I can if so desired.

@tquetano-r7 yeah that would be super helpful since the regression would have had to have been much more recent than that. In the meantime, I've release 0.47.1 of prettier-atom so some people could try updating and restarting atom and seeing if it makes a difference.

Using the repo @ozum provided the error that I find is that the eslint config isn't found.

I'm hoping it's because of this change https://github.com/prettier/prettier-eslint/commit/49b762b, where I tried to make the config resolve code a bit simpler by using the version of prettier and eslint that prettier-eslint provides for resolving the configs instead of resolving and requiring the project's version of prettier and eslint.

However, this doesn't seem to play well with eslint as it no longer can find the project's eslint config file.

I'll test this theory out tonight.

@robwise that was quick ... 0.39.0 (the next version) does not work. I was able to confirm, though, that the version of prettier-eslint that was installed with 0.39.0 was 8.7.5 ... which is probably why people say 0.38.0 is the last version to work, as its version of prettier-eslint is 6.4.3.

@tquetano-r7 Could you try with version 8.4.0 of prettier-eslint in prettier-atoms node_modules, please.

@zimme huzzah! using [email protected] with [email protected] exact version seems to do the trick!

@tquetano-r7 Nice, then my thinking is pretty much confirmed. I'll do a release later tonight, still at work for another 3-4 hours.

Should I release another version of prettier-atom that locks to 8.4.0?

@robwise yes please

@robwise it's up to you, but I'll have a new release of prettier-eslint out in 2-6 hours and by all indications here that version should resolve the issue.

@robwise I think you should do that too

I don't mind, I'll lock to 8.4.0 now and then let me know when the next prettier-eslint is out and I'll release a third time.

Okay prettier-atom 0.47.2 is released with a lock down version of prettier-eslint 8.4.0

[email protected] is out and should fix this error, finally.

@robwise You should be able to unpin 8.4.0 now.

Thanks, @zimme! I will give it a shot now.

@robwise I can confirm that version 8.7.6 is working as expected for me. Thanks again, @zimme!

@robwise - I can confirm that [email protected] works now, and is respecting the rules in the eslintrc.js file. ๐Ÿ‘

@zimme - I can confirm that [email protected] along with [email protected] seems to be working now. ๐Ÿ‘ ... I installed [email protected] and upped the package from 8.4.0 to ^8.7.0 as it was earlier. Works fine.

Thanks guys. ๐Ÿ’ฏ

okay I released prettier-atom 0.48.0 with prettier-eslint 8.7.6

0.48.0 seems working for me. (Also it works in repo created for this case)

My .eslintrc.js is not read and debug gives this info:

Atom version: 1.25.0 prettier-atom version: 0.53.0 prettier: bundled prettier version: 1.11.1 prettier-eslint version: 8.8.1 prettier-atom configuration: { "formatOnSaveOptions": { "enabled": true, "respectEslintignore": true, "showInStatusBar": false, "excludedGlobs": [], "whitelistedGlobs": [], "isDisabledIfNotInPackageJson": false, "isDisabledIfNoConfigFile": false }, "useEslint": false, "useStylelint": false, "useEditorConfig": true, "prettierOptions": { "singleQuote": false, "bracketSpacing": true, "semi": true, "useTabs": false, "jsxBracketSameLine": false, "printWidth": 80, "tabWidth": "auto", "trailingComma": "none", "parser": "babylon", "arrowParens": "avoid" }, "prettierEslintOptions": { "prettierLast": false }, "scopes": { "javascript": [ "source.js", "source.jsx", "source.js.jsx", "source.babel", "source.js-semantic", "text.html.basic", "text.html.vue" ], "typescript": [ "source.ts", "source.tsx", "source.ts.tsx" ], "css": [ "source.css", "source.less", "source.css.less", "source.scss", "source.css.scss", "source.css.postcss" ], "json": [ "source.json" ], "graphQl": [ "source.graphql" ], "markdown": [ "source.md", "source.gfm", "text.md" ], "vue": [ "text.html.vue" ] } }

I ran into this while updating vscode and atom to use prettier & eslint.

Apparently atom does not actually run eslint --fix (determined by changing the indent, for example .. prettier at 4, eslint at 2 .. 4 is the result)

Running prettier and eslint --fix via their clis works perfectly.

Is it possible prettier-atom or prettier-eslint is not finding the config files? I don't do local npm installs of eslint and prettier. Would that fix this?

Debug looks like:

Atom version: 1.26.1
prettier-atom version: 0.53.0
prettier: /Users/owen/npm/lib/node_modules/prettier/index.js
prettier version: 1.11.1
prettier-eslint version: 8.8.1
prettier-atom configuration: {
  "formatOnSaveOptions": {
    "enabled": true,
    "showInStatusBar": true,
    "respectEslintignore": true,
    "excludedGlobs": [],
    "whitelistedGlobs": [],
    "isDisabledIfNotInPackageJson": false,
    "isDisabledIfNoConfigFile": false
  },
  "prettierOptions": {
    "bracketSpacing": false,
    "semi": false,
    "singleQuote": false,
    "useTabs": false,
    "jsxBracketSameLine": false,
    "printWidth": 80,
    "tabWidth": "auto",
    "trailingComma": "none",
    "parser": "babylon",
    "arrowParens": "avoid"
  },
  "useEditorConfig": false,
  "useEslint": true,
  "useStylelint": false,
  "prettierEslintOptions": {
    "prettierLast": false
  },
  "scopes": {
    "javascript": [
      "source.js",
      "source.jsx",
      "source.js.jsx",
      "source.babel",
      "source.js-semantic",
      "text.html.basic",
      "text.html.vue"
    ],
    "typescript": [
      "source.ts",
      "source.tsx",
      "source.ts.tsx"
    ],
    "css": [
      "source.css",
      "source.less",
      "source.css.less",
      "source.scss",
      "source.css.scss",
      "source.css.postcss"
    ],
    "json": [
      "source.json"
    ],
    "graphQl": [
      "source.graphql"
    ],
    "markdown": [
      "source.md",
      "source.gfm",
      "text.md"
    ],
    "vue": [
      "text.html.vue"
    ]
  }
}

The config files for prettier and eslint (both are .js versions, not .json) look like:

// .prettierrc.js
module.exports = {
  semi: false,
  singleQuote: true,
  tabWidth: 4,
  trailingComma: 'es5',
}
// .eslintrc.js
module.exports = {
    env: {
        browser: true,
        es6: true,
    },
    extends: 'standard',
    parserOptions: {
        sourceType: 'module',
    },
    rules: {
        curly: [0],
        'comma-dangle': ['error', 'always-multiline'],
        'prefer-const': ['error'],
        indent: ['error', 2],
    },
}

Apparently atom does not actually run eslint --fix

@mxrguspxrt prettier-atom's eslint integration uses prettier-eslint under the hood. It will check your prettier configuration first and prefer those rules over eslint's, so setting the two to different values as a test doesn't make sense. Test by changing something that prettier has no effect on but eslint does, that will tell you if eslint --fix is being run.

DOH! Thanks.

So I just tried a new experiment which apparently also fails:
https://eslint.org/docs/rules/space-before-function-paren

I tried this first by using standard style (always as a space between name/parens). This results in:

    clone(array) {
        return array.slice(0)
    }

using prettier-atom. I also tried adding this explicitly in .eslintrc.js:
space-before-function-paren: "error"
..which is the eslint default for "always". Same results.

Using vscode's prettier/eslint and using both prettier/eslint clis result in the expected results:

    clone (array) {
        return array.slice(0)
    }

As a final test, I disabled prettier-atom, enabled eslint, and got the expected results.

Sorry to be a pain but I'd like to get this working. My bet is that I have a config problem of some sort.

I tried the suggestion above to downgrade to 0.48.0. I first uninstalled prettier-atom then:

apm install [email protected]

Results in

Atom version: 1.26.1
prettier-atom version: 0.48.0
prettier version: 1.10.2
prettier-eslint version: 8.8.1

Complete Debug below.

It did not fix the problem. Config files here:

// .prettierrc.js
module.exports = {
  semi: false,
  singleQuote: true,
  tabWidth: 4,
  trailingComma: 'es5',
}

// .eslintrc.js
module.exports = {
    env: {
        browser: true,
        es6: true,
    },
    extends: 'standard',
    parserOptions: {
        sourceType: 'module',
    },
    rules: {
        curly: [0],
        'prefer-const': [2],
        'space-before-function-paren': 'error',
        // Here to match our Prettier options
        semi: ['error', 'never'],
        quotes: ['error', 'single'],
        indent: ['error', 4],
        'comma-dangle': ['error', 'always-multiline'],
    },
}

Debug:

Atom version: 1.26.1
prettier-atom version: 0.48.0
prettier version: 1.10.2
prettier-eslint version: 8.8.1
prettier-atom configuration: {
  "formatOnSaveOptions": {
    "enabled": true,
    "showInStatusBar": true,
    "respectEslintignore": true,
    "javascriptScopes": [
      "source.js",
      "source.jsx",
      "source.js.jsx",
      "source.babel",
      "source.js-semantic",
      "text.html.basic",
      "text.html.vue"
    ],
    "typescriptScopes": [
      "source.ts",
      "source.tsx",
      "source.ts.tsx"
    ],
    "cssScopes": [
      "source.css",
      "source.less",
      "source.css.less",
      "source.scss",
      "source.css.scss",
      "source.css.postcss"
    ],
    "jsonScopes": [
      "source.json"
    ],
    "graphQlScopes": [
      "source.graphql"
    ],
    "markdownScopes": [
      "source.md",
      "source.gfm",
      "text.md"
    ],
    "vueScopes": [
      "text.html.vue"
    ],
    "excludedGlobs": [],
    "whitelistedGlobs": [],
    "isDisabledIfNotInPackageJson": false,
    "isDisabledIfNoConfigFile": false
  },
  "prettierEslintOptions": {
    "prettierLast": false
  },
  "prettierOptions": {
    "bracketSpacing": false,
    "semi": false,
    "singleQuote": false,
    "useTabs": false,
    "jsxBracketSameLine": false,
    "printWidth": 80,
    "tabWidth": "auto",
    "trailingComma": "none",
    "parser": "babylon",
    "arrowParens": "avoid"
  },
  "useEditorConfig": false,
  "useEslint": true,
  "useStylelint": false
}

Downgrading is not considered a viable solution in the long term. In most cases we only recommend you downgrade temporarily until a patch for a regression can be created and shipped.

Is it worthwhile to reopen this one @robwise? I could take a stab at this over the next week and find the culprit.

@SavePointSam the bug at the root of this issue was fixed a long time ago. We should make a new issue.

I'm unable to reproduce, unfortunately:

So it is possible to run prettier and ESLint so they will work together within atom automatically? I am having hard times to make it work together.

Versions:

Atom: 1.27.0
linter: 2.2.0
linter-eslint: 8.4.1
prettier-atom: 0.53.0

I am expecting that after save my code gets formatted according to the rules I set for my eslint, like:

{
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended"
  ],
  "rules": {
    "semi": ["error", "always"],
    "no-unused-vars": "error"
  },
  "parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
        "jsx": true
    }
  },
  "settings": {
    "react": {
      "createClass": "createReactClass",
      "pragma": "React",
      "version": "16.0"
    },
    "propWrapperFunctions": [ "forbidExtraProps" ]
  }
}

Any ideas? What it currently happening is that for some reason prettier remove all ; while my ESLint encourge to have them, so I need to disable Prettier to make this work :(

@duranmla you need to add the prettier plugin to have proper compatibility. You can read more about it here.

@SavePointSam thanks very much for taking the time to answer I'll take a look!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kentcdodds picture kentcdodds  ยท  5Comments

valscion picture valscion  ยท  4Comments

mgrip picture mgrip  ยท  5Comments

zimme picture zimme  ยท  6Comments

vyrruss picture vyrruss  ยท  5Comments