Comments (12)
@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.
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.
Thanks for digging into this. Could you look into submitting a pull request?
from prettier-eslint.
I'm still having this issue. I don't think PR#71 fixes this.
from prettier-eslint.
Thanks for reaching out @enriquecaballero. Could you make a pull request to fix the issue you're seeing?
from prettier-eslint.
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.
@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.
@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.
When you install prettier-atom
, in its settings it provides the Prettier "defaults" correctly, as you can see below:
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.
Thanks for digging further. What do you propose?
from prettier-eslint.
I found the problem. The defaultValue param's are not matching Prettier's defaults in these lines:
- https://github.com/prettier/prettier-eslint/blob/master/src/utils.js#L198 (should be
false
) - https://github.com/prettier/prettier-eslint/blob/master/src/utils.js#L215 (should be 'none')
- https://github.com/prettier/prettier-eslint/blob/master/src/utils.js#L243 (should be
true
)
Working on a PR now.
from prettier-eslint.
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)
- It doesn't work with eslint v8 HOT 12
- how to integrate with prettier vscode extension? no longer has "prettier.eslintIntegration" option HOT 5
- ability to capture (non-fixable) eslint errors/warnings? HOT 5
- Integration with CI/CD (gitlab) HOT 1
- Error: Failed to load plugin '@next/next' declared in 'CLIOptions': The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '' HOT 2
- Remove `--prettier-last` option because it's out scope HOT 2
- Support for `padded-blocks` corner cases HOT 3
- Error: `reportUnusedDisableDirectives` must be any of "error", "warn", "off", and null HOT 2
- prettier-eslint fails due to an eslint config error; eslint works if called directly. Typescript overrides issue? HOT 1
- Only Prettier (but not ESLint) formatting is applied to `.cjs` files HOT 7
- prettier-eslint installs vue-eslint-parser 8.30, instead of 9.1.0 HOT 3
- `prettier-eslint` command fails due to unknown environment key `jest/globals` HOT 4
- Configuring reportUnusedDisableDirectives to true in .eslintrc will cause prettier-eslint to not work properly. HOT 1
- TypeError: Expected `input` to be a `string`, got `object` HOT 5
- Is this tool still needed? HOT 1
- Shouldn't this be the other way around? "This formats your code via prettier, and then passes the result of that to eslint --fix." HOT 6
- Status of capturing eslint warnings/errors? HOT 1
- feat: support flat config with `FlatESLint` HOT 7
- [meta] a new OpenCollective home for all `prettier` + `eslint` integration tools HOT 6
- How to use it? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prettier-eslint.