notslang / editorconfig-tools

Tools for verifying/fixing code style based on an EditorConfig file
https://npmjs.com/package/editorconfig-tools
GNU General Public License v3.0
54 stars 6 forks source link

Automatically ignore binary files #9

Open mcandre opened 9 years ago

mcandre commented 9 years ago

I like to run editorconfig-tools **/* on large projects, to see rules violations for all files. However, I want editorconfig-tools to automatically skip binary files, so that I don't see results like:

applescript/EmptyTrash.scpt failed end_of_line on line 3: found setting 'lf', should be 'cr'
applescript/EmptyTrash.scpt failed max_line_length on line 10: line is 122 chars, it should be 80
applescript/EmptyTrash.scpt failed trim_trailing_whitespace on line 4: found setting 'false', should be 'true'
applescript/Firefox-dev.scpt failed end_of_line on line 3: found setting 'lf', should be 'cr'
applescript/Firefox-dev.scpt failed max_line_length on line 5: line is 118 chars, it should be 80
applescript/Firefox-dev.scpt failed trim_trailing_whitespace on line 6: found setting 'false', should be 'true'
applescript/SwitchProxy.scpt failed end_of_line on line 3: found setting 'lf', should be 'cr'
applescript/SwitchProxy.scpt failed max_line_length on line 10: line is 108 chars, it should be 80
applescript/SwitchProxy.scpt failed trim_trailing_whitespace on line 2: found setting 'false', should be 'true'
applescript/VisorTerminal.scpt failed end_of_line on line 4: found setting 'lf', should be 'cr'
applescript/VisorTerminal.scpt failed max_line_length on line 21: line is 486 chars, it should be 80
applescript/VisorTerminal.scpt failed trim_trailing_whitespace on line 3: found setting 'false', should be 'true'
applescript/VisoriTerm.scpt failed end_of_line on line 4: found setting 'lf', should be 'cr'
applescript/VisoriTerm.scpt failed max_line_length on line 28: line is 450 chars, it should be 80
applescript/VisoriTerm.scpt failed trim_trailing_whitespace on line 3: found setting 'false', should be 'true'

AppleScript code files (.scpt) are stored in binary, not text, so please have editorconfig-tools skip them out of the box.

As a workaround, I can use Unix find to eliminate .scpt, .exe, and a few other binary files:

find . -type f -name Thumbs.db -prune -o -type f -name .DS_Store -prune -o -type d -name .git -prune -o -type f -name .gitmodules -prune -o -type d -name .hg -prune -o -type d -name .svn -prune -o -type d -name tmp -prune -o -type d -name bin -prune -o -type d -name target -prune -o -name "*.app*" -prune -o -type d -name node_modules -prune -o -type d -name bower_components -prune -o -type f -name "*[-.]min.js" -prune -o -type d -name "*.dSYM" -prune -o -type f -name "*.scpt" -prune -o -type d -name "*.xcodeproj" -prune -o -type d -name .vagrant -prune -o -type f -name .exe -prune -o -type f -name "*.o" -prune -o -type f -name "*.pyc" -prune -o -type f -name "*.hi" -prune -o -type f -name "*.beam" -prune -o -type f -name "*.png" -prune -o -type f -name "*.gif" -prune -o -type f -name "*.jp*g" -prune -o -type f -name "*.ico" -prune -o -type f -name "*.ttf" -prune -o -type f -name "*.zip" -prune -o -type f -name "*.jar" -prune -o -type f -name "*.dot" -prune -o -type f -name "*.pdf" -prune -o -type f -name "*.wav" -prune -o -type f -name "*.mp[34]" -prune -o -type f -name "*.svg" -prune -o -type f -name "*.flip" -prune -o -type f -name "*.class" -prune -o -type f -name "*.cmi" -prune -o -type f -name "*.cmo" -prune -o -type f -name "*.gem" -prune -o -type f -name "*.jad" -prune -o -type d -name .idea -prune -o -type f -name "*.iml" -prune -o -type f -name "*.log" -prune -o -type f -name "*" -exec node_modules/editorconfig-tools/bin/index.js check {} \;

But I would prefer that editorconfig-tools do this out of the box.

jednano commented 9 years ago

eclint is a Gulp plugin, so it accepts globs as input, including glob negation; however, those require a special [!]glob syntax in the CLI if you have Bash, because Bash has its own use for the ! symbol. Anyway, give it a try! Let me know if you have any questions.

notslang commented 9 years ago

I think globbing should be handled by the shell, not the tool. Anyway, this can be solved with https://www.npmjs.com/package/isbinaryfile or something like that