Community
Participate
Working Groups
It can be pretty annoying to load up files and have the spacing whitespace chars all mixed up. We should provide the following two rules from eslint: http://eslint.org/docs/rules/no-irregular-whitespace.html http://eslint.org/docs/rules/no-mixed-spaces-and-tabs.html
IMO 'smart-tabs' is the best setting for the no-mixed-spaces-and-tabs rule. ESLint chose a more aggressive setting by default, not sure why. [1] http://www.emacswiki.org/emacs/SmartTabs
I will use this bug report to focus on the rule for no-mixed-spaces-and-tabs. I opened bug report 482616 to take care of the second case for no-irregular-whitespaces.
My biggest issue with this rule is that it has an option called smart-tabs. Smart-tabs basically let you have spaces after tabs in order to align field names or other things. Check this link for further details: http://www.emacswiki.org/emacs/SmartTabs I think smart-tabs is what all developers want. So we have two ways to handle it: 1) consider implicitly smart-tabs to be true 2) add an extra preference in the preference page to handle smart-tabs with a "on/off" option. I would add the no-mixed-spaces-and-tabs option in the Settings>Javascript validation page under the code style section. I would go with (1). Any comment on that? If we provide such an option, it should be disabled by default as it requires to check each line of the whole source file. Also it would be good to provide a way to fix existing files. Something like Control + I in the Eclipse Java editor.
(In reply to Olivier Thomann from comment #3) > My biggest issue with this rule is that it has an option called smart-tabs. > Smart-tabs basically let you have spaces after tabs in order to align field > names or other things. Check this link for further details: > http://www.emacswiki.org/emacs/SmartTabs > > I think smart-tabs is what all developers want. So we have two ways to > handle it: > 1) consider implicitly smart-tabs to be true > 2) add an extra preference in the preference page to handle smart-tabs with > a "on/off" option. > I would add the no-mixed-spaces-and-tabs option in the Settings>Javascript > validation page under the code style section. > I would go with (1). > > Any comment on that? > For now, I think we have to go with (1), until we figure out a story for related preferences. > If we provide such an option, it should be disabled by default as it > requires to check each line of the whole source file. > Also it would be good to provide a way to fix existing files. Something like > Control + I in the Eclipse Java editor. See bug 475852, we are currently working on the 'fix all' story.
As part of the fix for bug 468188 I extracted out the default rule values from validator.js and put them in rules.json (this was so I could share them in the worker code without loading more scripts + dependents). So when you add the new rule, you will have to update the rules.json file (the same way you would have had to update validator.js).
I am working on making the filtering for mixed spaces and tabs within comments. Do we agree that these mixed spaces and tabs should not be reported when located inside comments? I made the change for the rules.json file. It works fine.
(In reply to Olivier Thomann from comment #6) > I am working on making the filtering for mixed spaces and tabs within > comments. Do we agree that these mixed spaces and tabs should not be > reported when located inside comments? > I made the change for the rules.json file. It works fine. Yes, I agree comments should be ignored. We should probably also ignore String / RegEx literals.
(In reply to Michael Rennie from comment #7) > Yes, I agree comments should be ignored. > We should probably also ignore String / RegEx literals. I thought about that, but since my regex to match wrong lines starts with the line start (^) I don't see how I could match a line that contains a mixed tabs and spaces inside a string literal or a regex. Is this possible?
(In reply to Olivier Thomann from comment #8) > (In reply to Michael Rennie from comment #7) > > Yes, I agree comments should be ignored. > > We should probably also ignore String / RegEx literals. > I thought about that, but since my regex to match wrong lines starts with > the line start (^) I don't see how I could match a line that contains a > mixed tabs and spaces inside a string literal or a regex. Is this possible? We should only care about mixed tab/space at the start of the line. Trailing whitespace is a separate issue and I would assume any unusual whitespace inside a line is for some specific aligning.
Created attachment 258227 [details] Proposed patch including a regression test This patch doesn't implement the smart-tabs feature. It only checks that spaces and tabs cannot be mixed at the beginning of a line. I am working on implementing the smart-tabs feature. With it enabled, we should not complain when tabs are followed by spaces.
Created attachment 258228 [details] Proposed patch including a regression test This patch implements the smart-tabs feature. The only thing I don't like is that I don't detect "spaces" that are not required for indentations. Not sure if we should actually check for that for performance reasons. Michael, let me know if you have any comments on that patch. I tried to add comments where needed.
Created attachment 258230 [details] Proposed patch including a regression test Remove the sorting of comments are the collection of comments is already sorted.
This was fixed with commit: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=d0bf46fae8044c58037329b8f77765a4faad51cf