This repository has been archived by the owner on Aug 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Default Config & Disable If No Project Config settings #101
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"max_line_length": { | ||
"value": 10, | ||
"level": "warn" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This is a very long line that will trigger max_line_length if the default config is used | ||
a = 1 |
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
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,6 +17,19 @@ const loadDeps = () => { | |
}; | ||
|
||
module.exports = { | ||
config: { | ||
defaultConfig: { | ||
title: 'Default Config Path', | ||
type: 'string', | ||
default: atom.getConfigDirPath(), | ||
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. I would just leave this blank, if a user wants to fill this in they can enter the path to wherever it should be themselves. The default value as is is wrong and just encourages people to put non-Atom configuration files in there. |
||
}, | ||
disableIfNoConfig: { | ||
title: 'Disable If No Project Config File Is Found', | ||
type: 'boolean', | ||
default: false, | ||
}, | ||
}, | ||
|
||
activate() { | ||
this.idleCallbacks = new Set(); | ||
let depsCallbackID; | ||
|
@@ -66,6 +79,9 @@ module.exports = { | |
cursor.getScopeDescriptor().getScopesArray().some(scope => | ||
scope === 'source.litcoffee')); | ||
|
||
const defaultConfig = atom.config.get('linter-coffeelint.defaultConfig'); | ||
const disableIfNoConfig = atom.config.get('linter-coffeelint.disableIfNoConfig'); | ||
|
||
const transform = ({ | ||
level, message, rule, lineNumber, context, | ||
}) => { | ||
|
@@ -88,14 +104,22 @@ module.exports = { | |
loadDeps(); | ||
|
||
return new Promise((resolve, reject) => { | ||
const task = Task.once(workerFile, filePath, source, isLiterate, (results) => { | ||
this.workers.delete(task); | ||
try { | ||
resolve(results.map(transform)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}); | ||
const task = Task.once( | ||
workerFile, | ||
filePath, | ||
source, | ||
isLiterate, | ||
defaultConfig, | ||
disableIfNoConfig, | ||
(results) => { | ||
this.workers.delete(task); | ||
try { | ||
resolve(results.map(transform)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
}, | ||
); | ||
this.workers.add(task); | ||
task.on('task:error', e => reject(e)); | ||
}); | ||
|
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
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.
I'd add a description clarifying that this is only used if
coffeelint
can't find a configuration on it's own.