Skip to content

Commit

Permalink
chore: add eof in generated eslint file (#303)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
seahindeniz and antfu authored Feb 16, 2023
1 parent b03f6ed commit 5471479
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/ctx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function createContext(options: Options = {}, root = process.cwd()) {
promises.push(
generateESLint().then((content) => {
if (content !== lastESLint) {
lastESLint = content
lastESLint = `${content}\n`
return writeFile(eslintrc.filepath!, content)
}
}),
Expand Down

1 comment on commit 5471479

@samuveth
Copy link
Contributor

@samuveth samuveth commented on 5471479 May 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug in this code section that prevents it from appending an End-Of-File (EOF) to the generated file as intended. Instead, it only appends the EOF to the lastESLint variable.

Here's the problematic section of the code:

promises.push(
  generateESLint().then((content) => {
    if (content !== lastESLint) {
      lastESLint = `${content}\n`; // The EOF is added only to the lastESLint variable and not the actual file
      return writeFile(eslintrc.filepath!, content); // The content written to the file does not have the EOF
    }
  }),
);

I've made a fix for it here: #371

Please sign in to comment.