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

Unexpected ESLint error "Newline required at end of file but not found." #198

Open
anatoliyarkhipov opened this issue Sep 2, 2016 · 5 comments

Comments

@anatoliyarkhipov
Copy link

anatoliyarkhipov commented Sep 2, 2016

Hi!

I run the plato with this command:

plato -r -d report -e .eslintrc src

In the .eslintrc I have this rule:

"eol-last": 2,

And ESLInt passes on all files in the codebase when I run it manually. But nearly every file in the plato report is marked with the "Newline required at end of file but not found." error:

image

And here is a screenshot of the same file from IDE:

image

How exactly does Plato run ESLint? How is it possible that results are diffrent from the manual running for the same config?

Thanks in advance!

@JSlain
Copy link

JSlain commented Sep 2, 2016

This seems like a bug.
Here is how the source file is read before being inspected by eslint:

var source = fs.readFileSync(file).toString().trim();

@anatoliyarkhipov
Copy link
Author

anatoliyarkhipov commented Sep 2, 2016

Thanks for the response, @JSlain! Any ideas how we can fix it?

Also, in the first message I said "nearly every file", but I checked them again, and found that ESLint was disabled for the files without the error. So actually the problem exists in every file.

Maybe it somehow relates to the fact that we use Windows for development?

@JSlain
Copy link

JSlain commented Sep 2, 2016

It's not Windows related.
Il'd replace (in lib/plato.js // line 103):

        var source = fs.readFileSync(file).toString().trim();
        if (!source) {
          log.info('Not parsing empty file "%s"', file);
          return;
        }

with:

        var source = fs.readFileSync(file).toString();
        if (!source.trim()) {
          log.info('Not parsing empty file "%s"', file);
          return;
        }

I'll make a pull request when i have time

JSlain added a commit to JSlain/plato that referenced this issue Sep 5, 2016
@brentsmith-dev
Copy link

Until @JSlain 's PR is integrated (has Plato found a maintainer?) I'm working around it by using his other workaround for how Plato loads the configs
var config = new CLIEngine().getConfigForFile(yourFile);
and following it with
config.rules['eol-last'] = 0;
since we run the CLI linter anyway which should catch missing newlines.

Really hope someone with some time picks up this project. JSlain have you found a good replacement for this sort of analysis?

@JSlain
Copy link

JSlain commented Sep 6, 2017

Not really. we run our analysis tools in Jenkins, and uses checkstyle reporter to show eslint results.
I didn't fix that bug for a personal purpose, this wasn't really an issue for me.

kyungilpark pushed a commit to kyungilpark/plato that referenced this issue Jun 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants