jscs-dev / node-jscs

:arrow_heading_up: JavaScript Code Style checker (unmaintained)
https://jscs-dev.github.io
MIT License
4.97k stars 515 forks source link

tabs indentation is removed by the fix option #2234

Closed bcowgill closed 8 years ago

bcowgill commented 8 years ago

I have only found two settings in the docs to do with tabs so I've got this jscs config:

// jscs-tabs.json5 { "preset": "google", "esnext": true, "disallowMixedSpacesAndTabs": false, // either true or false or smart, doesn't matter "disallowTabs": false }

and this source file: // tabbed.jst 'use strict'; var TemplateComponent = React.createClass({

Trender: function() { TTreturn ( TTT"

" TT); T} });

perl -pne 's{\A (T+)}{ "\t" x length($1) }xmsge' tabbed.jst > tabbed.js

ls-tabs.pl tabbed.js

9 lines read 0 lines with prefix spacing 5 lines with prefix tabs spacing ok for tab stop 4

jscs --fix --config=jscs-tabs.json5 tabbed.js

ls-tabs.pl tabbed.js 4 ..render: function() { 5 |..|return ( 6 |..|'

' 7 |..|);

8 ..}

9 lines read 5 lines with prefix spacing 0 lines with prefix tabs spacing which mismatches tab depth (spaces=4) found.

So it has removed the tab characters and replaced them with two spaces. Unsure how to specify a 4 character tab width and keep the tab indentation.

markelog commented 8 years ago

Sorry it is not unclear what file are you trying to lint here