Giter VIP home page Giter VIP logo

Comments (12)

echenley avatar echenley commented on May 17, 2024 10

@enriquecaballero Are you trying to get trailing commas for all function arguments? If so, you need to set your eslint config to:

{
  "rules": {
    "comma-dangle": [2, {
      "arrays": "always-multiline",
      "objects": "always-multiline",
      "imports": "always-multiline",
      "exports": "always-multiline",
      "functions": "always-multiline"
    }]
  }
}

Either of the following will give you trailing commas for everything EXCEPT functions:

{
  "rules": {
    "comma-dangle": [2, "always-multiline"]
  }
}

// OR

{
  "rules": {
    "comma-dangle": [2, {
      "arrays": "always-multiline",
      "objects": "always-multiline",
      "imports": "always-multiline",
      "exports": "always-multiline",
      "functions": "ignore"
    }]
  }
}

Pretty sure setting this in your eslintrc should get you the same results for both prettier-eslint and prettier-eslint-cli. Could be wrong though.

from prettier-eslint.

kentcdodds avatar kentcdodds commented on May 17, 2024 5

Here's the code that should change, here's where you'd add a test case, here's a free course on how to contribute to OSS (if you're new to contributing), and here's our CONTRIBUTING.md.

Cheers!

from prettier-eslint.

kentcdodds avatar kentcdodds commented on May 17, 2024

Thanks for digging into this. Could you look into submitting a pull request?

from prettier-eslint.

enriquecaballero avatar enriquecaballero commented on May 17, 2024

I'm still having this issue. I don't think PR#71 fixes this.

from prettier-eslint.

kentcdodds avatar kentcdodds commented on May 17, 2024

Thanks for reaching out @enriquecaballero. Could you make a pull request to fix the issue you're seeing?

from prettier-eslint.

enriquecaballero avatar enriquecaballero commented on May 17, 2024

I would, but there seems to be some confusion here as to what the expected behavior is for this issue. The Prettier README defaults trailing commas to "none" and single quotes to false. Yet, for some reason, when I use Prettier via Atom, that uses prettier-eslint whenever the ESLint Integration box is checked, I don't have this problem. It's only when I use the prettier-eslint-cli that turns on single quotes and trailing commas by default. I would assume it should be the other way around? One should expect Prettier defaults to apply? It doesn't make sense to turn them on one-by-one. Also, I don't know if this is a eslint-prettier issue or an eslint-prettier-cli issue.

from prettier-eslint.

enriquecaballero avatar enriquecaballero commented on May 17, 2024

@echenley All I'm trying to understand is why prettier-eslint-cli's defaults aren't matching either Prettier's or ESLint's. Like I said in my earlier comment, Prettier defaults trailing commas to "never" and single quotes to false. ESLint's comma-dangle rule defaults to "never". It just feels like prettier-eslint-cli is overriding Prettier and ESLint whenever those rules aren't set, forcing one to (unnecessarily) manually add those rules. To get comma-dangles to work, I have to do do prettier-eslint ―prettier.trailingComma none which shouldn't be the case.

from prettier-eslint.

enriquecaballero avatar enriquecaballero commented on May 17, 2024

@echenley It just seems that prettier-eslint-cli and prettier-atom use prettier-eslint differently. prettier-atom has Prettier's defaults correctly set up, but prettier-eslint-cli does not.

from prettier-eslint.

enriquecaballero avatar enriquecaballero commented on May 17, 2024

When you install prettier-atom, in its settings it provides the Prettier "defaults" correctly, as you can see below:

screen shot 2017-05-09 at 9 12 08 pm

prettier-atom depends on that form to create internal defaults:

// prettier-atom/src/options.js
trailingComma: getPrettierOption('trailingComma')
const getPrettierOption = (key: string) => getConfigOption(`prettierOptions.${key}`);

// prettier-atom/src/helpers.js
const getConfigOption = (key: string) => atom.config.get(`prettier-atom.${key}`);

Here's what I'm running into:

Using prettier-eslint-cli : prettier-eslint --write "src/**/*.@(js|jsx)"

const test = [
  'hello',
  'world',
  'hello',
  'world',
  'hello',
  'world',
  'hello',
  'world',
  'hello',
  'world',
];

Using prettier-atom with ESLint Integration enabled and the settings from the image above:

const test = [
  "hello",
  "world",
  "hello",
  "world",
  "hello",
  "world",
  "hello",
  "world",
  "hello",
  "world"
];

There seems to be a disconnect between both modules, and that's bad because it affects those with git hooks that use prettier-eslint-cli and prettier-atom's Format on Save option.

from prettier-eslint.

kentcdodds avatar kentcdodds commented on May 17, 2024

Thanks for digging further. What do you propose?

from prettier-eslint.

enriquecaballero avatar enriquecaballero commented on May 17, 2024

I found the problem. The defaultValue param's are not matching Prettier's defaults in these lines:

Working on a PR now.

from prettier-eslint.

kentcdodds avatar kentcdodds commented on May 17, 2024

Ah! Nice, thanks for looking into that. A PR will be accepted. Now to decide whether this should be a breaking change or not... πŸ€”

I think it wont be. Things are a little tricky with this package πŸ™ƒ

from prettier-eslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.