Skip to content

Commit

Permalink
fix(#196): fix prettier unspecified printWidth
Browse files Browse the repository at this point in the history
issue introduced in #195.
was causing inline decorators to move to the line above because
`Number(undefined)` is 0, and having a printWidth of 0 breaks
all sorts of formatting.
  • Loading branch information
NullVoxPopuli committed Nov 9, 2020
1 parent dca0294 commit 2c327c8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/rules/decorator-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ function lineLength(userOptions, filePath) {
const isEnabled = eslintPrettierRules[0] === 'error';

if (!isEnabled) {
return {};
return { printWidth: Infinity };
}

const eslintPrettierOptions = eslintPrettierRules[1] || {};
Expand All @@ -332,13 +332,15 @@ function lineLength(userOptions, filePath) {
filePath,
});

console.log({
usePrettierrc,
eslintPrettierOptions,
eslintPrettierRules,
prettierOptions,
prettierRcOptions,
});
if (!('printWidth' in prettierOptions)) {
// 80 is prettier default
// eslint-disable-next-line no-console
console.warn(
'WARNING(eslint-plugin-decorator-position): printWidth not set in the prettier config, defaulting to 80'
);

return { ...prettierOptions, ...userOptions, printWidth: 80 };
}

return Object.assign({}, prettierOptions, userOptions);
}
Expand Down

0 comments on commit 2c327c8

Please sign in to comment.