Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linter): update circular file path message to wrap onto multiple lines #9033

Merged
merged 1 commit into from Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1198,7 +1198,10 @@ Circular file chain:
Circular file chain:
- libs/mylib/src/main.ts
- libs/badcirclelib/src/main.ts
- [libs/anotherlib/src/main.ts,libs/anotherlib/src/index.ts]`;
- [
libs/anotherlib/src/main.ts,
libs/anotherlib/src/index.ts
]`;
expect(failures.length).toEqual(2);
expect(failures[0].message).toEqual(message);
expect(failures[1].message).toEqual(message);
Expand Down
Expand Up @@ -302,6 +302,10 @@ export default createESLintRule<Options, MessageIds>({
if (circularPath.length !== 0) {
const circularFilePath = findFilesInCircularPath(circularPath);

// spacer text used for indirect dependencies when printing one line per file.
// without this, we can end up with a very long line that does not display well in the terminal.
const spacer = '\n ';

context.report({
node,
messageId: 'noCircularDependencies',
Expand All @@ -314,7 +318,9 @@ export default createESLintRule<Options, MessageIds>({
),
filePaths: circularFilePath
.map((files) =>
files.length > 1 ? `[${files.join(',')}]` : files[0]
files.length > 1
? `[${spacer}${files.join(`,${spacer}`)}\n ]`
: files[0]
)
.reduce(
(acc, files) => `${acc}\n- ${files}`,
Expand Down