-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 : {}; | ||
|
||
const pkgDependencies = { | ||
...pkg.dependencies, | ||
|
@@ -68,7 +69,7 @@ function parseArgument(argumentString) { | |
}; | ||
} | ||
|
||
if (DEPENDENCY_INCLUSION_RE.test(argumentString)) { | ||
if (hasPackage && DEPENDENCY_INCLUSION_RE.test(argumentString)) { | ||
const condition = argumentString[0] === '+' ? 'in' : 'out'; | ||
const name = argumentString.slice(1).trim(); | ||
|
||
|
@@ -81,7 +82,7 @@ function parseArgument(argumentString) { | |
}; | ||
} | ||
|
||
if (VERSION_COMPARISON_RE.test(argumentString)) { | ||
if (hasPackage && VERSION_COMPARISON_RE.test(argumentString)) { | ||
const result = VERSION_COMPARISON_RE.exec(argumentString); | ||
const name = result[1].trim(); | ||
const condition = result[2].trim(); | ||
|
@@ -112,7 +113,7 @@ function parseArgument(argumentString) { | |
} | ||
} | ||
|
||
if (PKG_VERSION_RE.test(argumentString)) { | ||
if (hasPackage && PKG_VERSION_RE.test(argumentString)) { | ||
const result = PKG_VERSION_RE.exec(argumentString); | ||
const condition = result[1].trim(); | ||
const version = result[2].trim(); | ||
|
@@ -173,11 +174,7 @@ function semverComparisonForOperator(operator) { | |
|
||
const create = context => { | ||
const options = { | ||
terms: [ | ||
'todo', | ||
'fixme', | ||
'xxx' | ||
], | ||
terms: ['todo', 'fixme', 'xxx'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future, don't do unrelated changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
ignoreDatesOnPullRequests: true, | ||
allowWarningComments: false, | ||
...context.options[0] | ||
|
@@ -347,9 +344,7 @@ const create = context => { | |
loc: comment.loc, | ||
messageId: MESSAGE_ID_VERSION_MATCHES, | ||
data: { | ||
comparison: `${dependency.name} ${dependency.condition} ${ | ||
dependency.version | ||
}`, | ||
comparison: `${dependency.name} ${dependency.condition} ${dependency.version}`, | ||
message: parseTodoMessage(comment.value) | ||
} | ||
}); | ||
|
@@ -394,7 +389,10 @@ const create = context => { | |
const comparisonIndex = unknown.indexOf('>'); | ||
|
||
if (!hasAt && comparisonIndex !== -1) { | ||
const testString = `${unknown.slice(0, comparisonIndex)}@${unknown.slice(comparisonIndex)}`; | ||
const testString = `${unknown.slice( | ||
0, | ||
comparisonIndex | ||
)}@${unknown.slice(comparisonIndex)}`; | ||
|
||
if (parseArgument(testString).type !== 'unknowns') { | ||
uses++; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first thinking
next might better, but extra line
or maybe this one
@lubien what do you think
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#399