-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Re-add EditorConfig support (undo #3213) #3255
Merged
Merged
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9892602
Revert "Revert "Respect EditorConfig settings" (#3213)"
josephfrazier ddfa529
Comment out EditorConfig docs
josephfrazier 6dbd67f
editorconfig: Support `indent_size = 0`
josephfrazier b2637d7
Revert "Comment out EditorConfig docs"
josephfrazier 2f643e9
Mark EditorConfig functionality as v1.9.0+
josephfrazier aac81c4
Merge branch 'master' into editorconfig-2
josephfrazier d0beb79
editorconfig: Upgrade editorconfig-to-prettier to 0.0.4
josephfrazier bcf6f03
editorconfig: Only enable for CLI, by default
josephfrazier f9c8cc3
editorconfig: Add tests confirming that editorconfig is ignored by de…
josephfrazier d5dcbfa
Merge branch 'master' into editorconfig-2
josephfrazier 7597be5
editorconfig: Add/fix CLI option parsing
josephfrazier 89bf8bd
editorconfig: Move docs from configuration.md to options.md
josephfrazier 64a4413
editorconfig: Add `oppositeDescription` to show docs for `--no-editor…
josephfrazier 1ba5e6c
editorconfig: Update test snapshots
josephfrazier 53013cb
editorconfig: Remove unnecessary options parsing code
josephfrazier a36f9b9
editorconfig: Move docs from options.md to api.md and cli.md
josephfrazier e3460b8
resolveConfig: return null if both .prettierrc and .editorconfig are …
josephfrazier a2c81fc
Don't add now-failing tests
josephfrazier 0fda128
Merge branch 'master' into editorconfig-2
azz f74aa23
Merge branch 'master' into editorconfig-2
azz File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
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
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
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,47 @@ | ||
"use strict"; | ||
|
||
const editorconfig = require("editorconfig"); | ||
const mem = require("mem"); | ||
const pathRoot = require("path-root"); | ||
const editorConfigToPrettier = require("editorconfig-to-prettier"); | ||
|
||
const maybeParse = (filePath, config, parse) => { | ||
const root = filePath && pathRoot(filePath); | ||
return filePath && !config && parse(filePath, { root }); | ||
}; | ||
|
||
const editorconfigAsyncNoCache = (filePath, config) => { | ||
return Promise.resolve(maybeParse(filePath, config, editorconfig.parse)).then( | ||
editorConfigToPrettier | ||
); | ||
}; | ||
const editorconfigAsyncWithCache = mem(editorconfigAsyncNoCache); | ||
|
||
const editorconfigSyncNoCache = (filePath, config) => { | ||
return editorConfigToPrettier( | ||
maybeParse(filePath, config, editorconfig.parseSync) | ||
); | ||
}; | ||
const editorconfigSyncWithCache = mem(editorconfigSyncNoCache); | ||
|
||
function getLoadFunction(opts) { | ||
if (!opts.editorconfig) { | ||
return () => null; | ||
} | ||
|
||
if (opts.sync) { | ||
return opts.cache ? editorconfigSyncWithCache : editorconfigSyncNoCache; | ||
} | ||
|
||
return opts.cache ? editorconfigAsyncWithCache : editorconfigAsyncNoCache; | ||
} | ||
|
||
function clearCache() { | ||
mem.clear(editorconfigSyncWithCache); | ||
mem.clear(editorconfigAsyncWithCache); | ||
} | ||
|
||
module.exports = { | ||
getLoadFunction, | ||
clearCache | ||
}; |
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
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
Oops, something went wrong.
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.
We should also add
oppositeDescription
to show docs for--no-editorconfig
.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.
Good point, that makes the
--help
message much better! Fixed in 64a4413