Currently, if an unsupported file format is set on a collection (format: ini), we simply assume that it should be saved as YAML front-matter (see #748 and #776). I think in this case, when the user has explicitly set a format, and we are not inferring at all, it makes more sense to just throw an "Invalid Config" error. @erquhart @Benaiah?
Expanded discussion: https://github.com/netlify/netlify-cms/issues/776#issuecomment-347731448
We could throw on extension as well, but there may be a valid use case where someone needs to have a different extension than the normal one for a filetype. It does make it hader for the user to know that we are inferring, though.
I think throwing on an unsupported format is a good idea. I think we should also throw if the extension is unsupported and there _isn't_ a valid format set. We shouldn't error if there is an unknown extension but a valid format.
Good point, then if people want to force an abnormal extension, they have to explicitly set the format.
Current status (after #796):
| format | extension | File | Formatter | |
|----------|-------------|-------|---------|-|
| | | md | md |
| known | | known | known |
| unknown| | md | md | Should throw.
| | known | known | known |
| | unknown | undefined | md | Broken + Should throw.
| unknown| known | md | md | Should throw.
| unknown| unknown | unknown | md | Should throw.
@Benaiah @erquhart Or should we not even try to infer from the extension at all -- just throw if a format is not set along with the extension?
@tech4him1 nice table! This conversation is happening in a few places, is there a canonical issue or PR that we can condense down to?
Sure, most of the discussion here relates to https://github.com/netlify/netlify-cms/issues/776, I'll move it there.
The core of this issue is still just throwing on an unsupported format, so I'll leave it open until that gets merged. I moved the other discussion to #776.
@Benaiah @erquhart Should we account for "common misspellings" on the formats? yml vs yaml, md vs markdown? Right now it's really weird -- we account for the misspellings, but the extension is saved as undefined. We either need to throw on misspellings and provide a list of supported options, or just accept them as normal options.
@tech4him1 Yes, I think those alternative format names should be aliases for the ones we use.
We just can't change the extension on existing entries (don't want to bother with the tree manipulation to produce a rename). But yeah, that should work.
@erquhart What about the format: frontmatter option? https://github.com/netlify/netlify-cms/blob/2ecc5355d9fe55c84e78f5f315d6b822dfbfa0de/src/formats/formats.js#L43 Is there a reason that needs be be in there, instead of using format: markdown, since right now the default file extension for it is undefined?
If we don't need it, let's drop it.