This repository was archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Optionally omit globals warning #10
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fce13c9
Optionally omit globals warning
nbredikhin cdeddbf
Merge branch 'master' into master
nbredikhin 856ac3c
Fixed configSchema in package.json
nbredikhin dee8884
Add setting observing, fix the condition issue
nbredikhin e81e482
Merge branch 'master' of https://github.com/dcr30/linter-moonscript
nbredikhin 6111cdc
Remove atom.config.get
nbredikhin 544329a
Fixed "if" being the only statement in the block
nbredikhin 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 |
---|---|---|
|
@@ -7,6 +7,7 @@ import * as helpers from 'atom-linter'; | |
import { CompositeDisposable } from 'atom'; | ||
|
||
const parseRegex = /^(?:line)? \[?(\d+)]?(?:: (.+))?/gm; | ||
const globalRegex = /accessing global/g; | ||
let executablePath; | ||
|
||
export default { | ||
|
@@ -58,6 +59,7 @@ export default { | |
|
||
const messages = []; | ||
let match = parseRegex.exec(result); | ||
let globalsOmitted = atom.config.get('linter-moonscript.omitGlobalCheck'); | ||
while (match !== null) { | ||
// Convert the line to 0-indexed for Atom | ||
const line = Number.parseInt(match[1], 10) - 1; | ||
|
@@ -78,13 +80,15 @@ export default { | |
}); | ||
} else { | ||
// Regular lint warning | ||
messages.push({ | ||
type: 'Warning', | ||
severity: 'warning', | ||
filePath, | ||
text: match[2], | ||
range: helpers.rangeFromLineNumber(textEditor, line), | ||
}); | ||
if (!globalRegex.test(match[2]) && !globalsOmitted) { | ||
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. This should be As it currently stands, if |
||
messages.push({ | ||
type: 'Warning', | ||
severity: 'warning', | ||
filePath, | ||
text: match[2], | ||
range: helpers.rangeFromLineNumber(textEditor, line), | ||
}); | ||
} | ||
} | ||
|
||
// Grab the next match in the output | ||
|
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 |
---|---|---|
|
@@ -12,6 +12,11 @@ | |
"type": "string", | ||
"default": "moonc", | ||
"description": "Full path to the moonscript compiler." | ||
}, | ||
"omitGlobalCheck": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Omit \"accessing global\" warning." | ||
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. "warnings" |
||
} | ||
}, | ||
"license": "MIT", | ||
|
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.
Please observe this setting like this, there's no need to go through the complexity of determining what it is and what the current value is on every call 😉.