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

expiring-todo-comments doesn't work when linting stand-alone files #394

Closed
garyking opened this issue Sep 25, 2019 · 1 comment · Fixed by #397
Closed

expiring-todo-comments doesn't work when linting stand-alone files #394

garyking opened this issue Sep 25, 2019 · 1 comment · Fixed by #397

Comments

@garyking
Copy link
Contributor

garyking commented Sep 25, 2019

Related to #373. Ping @lubien.

I'm using the latest version of eslint-plugin-unicorn, and eslint v5.

I'm using the latest version of the VS Code editor, and the latest version of the vscode-eslint extension.

The extension allows to lint untitled files (after changing the untitled file's lang to JavaScript), and files that don't belong to a JS project with package.json. But an error is thrown with this rule, since it checks for a package.json, and an untitled file isn't even a file at all, and therefore also has no relevant package.json. And stand-alone files don't have package.json.

Error, whenever I open an untitled or stand-alone file in VSC:

[Info  - 4:23:17 PM] ESLint server stopped.
[Info  - 4:23:18 PM] ESLint server running in node v10.11.0
[Info  - 4:23:18 PM] ESLint server is running.
[Info  - 4:23:19 PM] ESLint library loaded from: /usr/local/lib/node_modules/eslint/lib/api.js
[Error - 4:23:21 PM] ESLint stack trace:
[Error - 4:23:21 PM] TypeError: Cannot read property 'package' of undefined
    at Object.<anonymous> (/usr/local/lib/node_modules/eslint-plugin-unicorn/rules/expiring-todo-comments.js:20:29)
    at Object.<anonymous> (/usr/local/lib/node_modules/eslint-plugin-unicorn/rules/expiring-todo-comments.js:499:3)
    at Module._compile (internal/modules/cjs/loader.js:693:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at Module.require (internal/modules/cjs/loader.js:640:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at module.exports (/usr/local/lib/node_modules/eslint-plugin-unicorn/node_modules/import-modules/index.js:41:21)
@lubien
Copy link
Contributor

lubien commented Sep 25, 2019

I can totally see this happening but I couldn't reproduce the untitled file scenario.

There is a .eslintrc with our plugin. Here's the output after changing it to JS:

[Info  - 7:57:17 PM] ESLint server stopped.
[Info  - 7:57:18 PM] ESLint server running in node v12.4.0
[Info  - 7:57:18 PM] ESLint server is running.
[Info  - 7:57:19 PM] ESLint library loaded from: /home/lubien/.nvm/versions/node/v10.16.0/lib/node_modules/eslint/lib/api.js
[Warn  - 7:57:19 PM] 
No ESLint configuration (e.g .eslintrc) found for file: Untitled-1

But I can reproduce it if I save the file, for that I think I have a fix.

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

Successfully merging a pull request may close this issue.

2 participants