Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that the `space` value, if present, is either a number or a boolean before passing it to the main API. The space option is intended to act as either a boolean or a number option, but it is implemented as a string option out of necessity, which resulted in some bugs. This commit fixes bugs demonstrated by the following invocations: `xo --space=4` Before fix: Expect 2-space indents. * The value of `space` is the *string* '4'. * The value is truthy, resulting in the space option being activated. * The value is not a number, resulting in the default of 2 being used. Now: Expect 4-space indents. * The value of `space` is the *number* 4. `xo --space file.js` Before fix: Check all files in the CWD and expect 2-space indents. * The value of `space` is 'file.js'. * The value is truthy and not a number, so expect 2-space indents. * There are no positional arguments recognized, so check all files. - This is a subtle bug, since the desired file *is* usually checked, it's just not checked exclusively. Now: Check only file.js and expect 2-space indents. `xo --space` Before fix: Expect tab indents. - The value of `space` is the empty string. - The value is falsey, so it is not used, instead defaulting to tabs. Now: Expect 2-space indents.
- Loading branch information