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

Handle lack of package.json in expiring-todo-comments rule #397

Merged
merged 1 commit into from
Sep 26, 2019

Conversation

lubien
Copy link
Contributor

@lubien lubien commented Sep 26, 2019

@garyking came with this scenario of a packageless project. For this my choice would be not to allow package related triggers to work at least until a proper package.json file is set up.

Even tho the original issue says eslint 5, this happens also in version 6.

Fixes #394

@sindresorhus sindresorhus changed the title Closes #394: Respect lack of package.json on TODOs Handle lack of package.json in expiring-todo-comments rule Sep 26, 2019
@sindresorhus sindresorhus merged commit f9f6ee6 into sindresorhus:master Sep 26, 2019
@lubien lubien deleted the issue-394 branch September 26, 2019 04:15
@@ -17,7 +17,8 @@ const MESSAGE_ID_ENGINE_MATCHES = 'engineMatches';
const MESSAGE_ID_REMOVE_WHITESPACES = 'removeWhitespaces';
const MESSAGE_ID_MISSING_AT_SYMBOL = 'missingAtSymbol';

const pkg = readPkgUp.sync().package;
const hasPackage = readPkgUp.sync();
const pkg = hasPackage ? hasPackage.package : {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

This two line seems weird.

Copy link
Collaborator

Choose a reason for hiding this comment

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

first thinking

const {package: pkg = {}} = readPkgUp.sync() || {};
const hasPackage = ??? // can't detect

next might better, but extra line

const result= readPkgUp.sync();
const hasPackage = Boolean(result)
const pkg = hasPackage ? result.package : {};

or maybe this one

const {
  package: pkg = {}, 
  hasPackage = true
} = readPkgUp.sync() || {hasPackage: false}

@lubien what do you think

Copy link
Owner

Choose a reason for hiding this comment

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

I agree. I just needed to get this out.

Should probably have been:

const packageResult = readPkgUp.sync();
const hasPackage = Boolean(packageResult);
const packageJson = hasPackage ? packageResult.package : {};

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did we comment at the same time? LOL
what do you think my last code

Copy link
Owner

Choose a reason for hiding this comment

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

Hehe. Seems so. I didn't see your comment until now. Let's go with mine, which is your second one, just with more verbose naming.

Copy link
Collaborator

Choose a reason for hiding this comment

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

/cc @lubien Could you please send another PR to apply this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! But I need a few hours before I can do this if it's not an issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'fixme',
'xxx'
],
terms: ['todo', 'fixme', 'xxx'],
Copy link
Owner

Choose a reason for hiding this comment

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

In the future, don't do unrelated changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh. Might have been the linter but might bad for leaving it, sorry. Won't happen again.

lubien added a commit to lubien/eslint-plugin-unicorn that referenced this pull request Sep 27, 2019
lubien added a commit to lubien/eslint-plugin-unicorn that referenced this pull request Sep 27, 2019
NickPoulden pushed a commit to NickPoulden/eslint-unicorn that referenced this pull request Jun 13, 2022
AlexGuz23 pushed a commit to AlexGuz23/eslint-plugin-unicorn that referenced this pull request Nov 3, 2022
devlancer-lucas added a commit to devlancer-lucas/eslint-plugin-unicorn that referenced this pull request Mar 16, 2023
AwfulDarkness0110 added a commit to AwfulDarkness0110/eslint-plugin-unicorn that referenced this pull request Jun 28, 2023
mattstern31 added a commit to mattstern31/eslint-plugin-unicorn that referenced this pull request Nov 11, 2023
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 this pull request may close these issues.

expiring-todo-comments doesn't work when linting stand-alone files
3 participants