Max length
RobbieTheWagner opened this issue ยท comments
Is there a way to configure a max length? For example, if you had something like:
@alias('foo.bar.baz.someReallyLongPropertyNameThatIsTooLongToBeInlineOrItBreaksPrettier')
myProp;
I would like to make alias
inline always, unless it is too long and would conflict with prettier formatting, basically.
Is there currently a way to do that?
afaik, not without specifying a length option in the config.
I would love to integrate with eslint-plugin-prettier and just get the line width passed in some object here: https://github.com/NullVoxPopuli/eslint-plugin-decorator-position/blob/master/lib/rules/decorator-position.js#L120
but I don't know if that's possible.
I think the best way to achieve this now is to do something like:
const prettierConfig = require('./.prettierrc');
rules: {
'decorator-position/decorator-position': ['error', { lineWidth: prettierConfig.whicheverOptionThisIs }]
}
idk
@NullVoxPopuli I am fine with specifying a length, It looks like from your suggestion lineWidth
is what I am after? I didn't see options documented anywhere, but maybe I missed them.
lineWidth
isn't implemented (yet), but I'd happily accept a PR for it ;)
also, looks like printWidth
is the prettier config name -- https://prettier.io/docs/en/options.html
maybe we should align with that?
Ah, gotcha. I'm not sure I currently have the time to dive into it, but perhaps sometime this week.
@rwwagner90 can you share an example config for eslint and prettier?
I just tried setting printWidth to 100, and got this output:
- @alias('foo.bar.baz.someReallyLongPropertyNameThatIsTooLongToBeInlineOrItBreaksPrettier.Prettier.is.Set.to.100')
+ @alias(
+ 'foo.bar.baz.someReallyLongPropertyNameThatIsTooLongToBeInlineOrItBreaksPrettier.Prettier.is.Set.to.100'
+ )
myProp;
ah, cause it's the difference between this:
- @belongsTo('.... long args ...') myProp;
+ @belongsTo(
+ '... long args ....'
+ )
+ myProp; # <- causes another lint error, expected to be inline
it could be that @tylerturdenpants has a fix working! and that's why I can't reproduce.
@rwwagner90 can you review this test-case change (and maybe everything in smoke-tests/-rules/position-prettier/default.js
), to see if it covers your scenario?
tylerturdenpants#1
๐ This issue has been resolved in version 2.2.0 ๐
The release is available on:
Your semantic-release bot ๐ฆ๐