sds / scss-lint

Configurable tool for writing clean, consistent SCSS
MIT License
3.66k stars 465 forks source link

Windows path not resolved correctly #601

Closed mlarcher closed 9 years ago

mlarcher commented 9 years ago

According to https://github.com/juanfran/gulp-scss-lint/issues/51#issuecomment-142983831 it seems there is an issue in the way command line are handled in scss-lint. Here is the command line input:

scss-lint C:\UwAmp\www\Nouveau_dossier\Nouveau_dossier\Nouveau_dossier\Nouveau_dossier\project_folder\src\styles\**\*.scss C:\UwAmp\www\Nouveau_dossier\Nouveau_dossier\Nouveau_dossier\Nouveau_dossier\project_folder\src\project-root\**\*.scss --format=JSON

and the corresponding output:

Invalid argument @ rb_sysopen - C:UwAmpwwwNouveau_dossierNouveau_dossierNouveau_dossierNouveau_dossierproject_foldersrcstyles***.scss
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-3.4.18/lib/sass/engine.rb:239:in `read'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sass-3.4.18/lib/sass/engine.rb:239:in `for_file'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/engine.rb:47:in `build_from_file'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/engine.rb:21:in `initialize'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/runner.rb:27:in `new'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/runner.rb:27:in `find_lints'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/runner.rb:19:in `block in run'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/runner.rb:18:in `each'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/runner.rb:18:in `run'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/cli.rb:57:in `scan_for_lints'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/cli.rb:50:in `act_on_options'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/lib/scss_lint/cli.rb:27:in `run'
c:/outils/Ruby22-x64/lib/ruby/gems/2.2.0/gems/scss_lint-0.42.0/bin/scss-lint:6:in `<top (required)>'
c:/outils/Ruby22-x64/bin/scss-lint:23:in `load'
c:/outils/Ruby22-x64/bin/scss-lint:23:in `<main>'
Report this bug at https://github.com/brigade/scss-lint/issues

To help fix this issue, please include:
- The above stack trace
- SCSS-Lint version: 0.42.0
- Sass version: 3.4.18
- Ruby version: 2.2.1
- Contents of C:/UwAmp/www/Nouveau_dossier/Nouveau_dossier/Nouveau_dossier/Nouveau_dossier/project_folder/.scss-lint.yml

The content of .scss-lint.yml is:

# Default application configuration that all configurations inherit from.

scss_files: "**/*.scss"

linters:
  BangFormat:
    enabled: true
    space_before_bang: true
    space_after_bang: false
    severity: error

  BorderZero:
    enabled: true
    convention: zero # or `none`
    severity: error

  ColorKeyword:
    enabled: true
    severity: warning

  ColorVariable:
    enabled: true
    severity: warning

  Comment:
    enabled: false
    severity: warning

  DebugStatement:
    enabled: true
    severity: error

  DeclarationOrder:
    enabled: true
    severity: warning

  DuplicateProperty:
    enabled: true
    severity: error

  ElsePlacement:
    enabled: true
    style: same_line # or 'new_line'
    severity: error

  EmptyLineBetweenBlocks:
    enabled: true
    ignore_single_line_blocks: true
    severity: error

  EmptyRule:
    enabled: true
    severity: warning

  FinalNewline:
    enabled: true
    present: true
    severity: error

  HexLength:
    enabled: false
    style: short # or 'long'
    severity: warning

  HexNotation:
    enabled: true
    style: lowercase # or 'uppercase'
    severity: error

  HexValidation:
    enabled: true
    severity: error

  IdSelector:
    enabled: true
    severity: error

  ImportantRule:
    enabled: true
    severity: warning

  ImportPath:
    enabled: false
    leading_underscore: true
    filename_extension: false
    severity: warning

  Indentation:
    enabled: true
    allow_non_nested_indentation: false
    character: space # or 'tab'
    width: 2
    severity: error

  LeadingZero:
    enabled: true
    style: exclude_zero # or 'include_zero'
    severity: error

  MergeableSelector:
    enabled: true
    force_nesting: false
    severity: warning

  NameFormat:
    enabled: false
    allow_leading_underscore: true
    convention: hyphenated_lowercase # or 'BEM', or a regex pattern
    severity: error

  NestingDepth:
    enabled: true
    max_depth: 3
    severity: error

  PlaceholderInExtend:
    enabled: true
    severity: warning

  PropertyCount:
    enabled: false
    include_nested: false
    max_properties: 10
    severity: warning

  PropertySortOrder:
    enabled: false
    order: concentric
    ignore_unspecified: false
    separate_groups: false
    severity: warning

  PropertySpelling:
    enabled: true
    extra_properties: []
    severity: error

  QualifyingElement:
    enabled: true
    allow_element_with_attribute: false
    allow_element_with_class: false
    allow_element_with_id: false
    severity: warning

  SelectorDepth:
    enabled: true
    max_depth: 3
    severity: error

  SelectorFormat:
    enabled: true
    convention: ^([a-zA-Z]([a-zA-Z0-9])+(_[a-zA-Z]+)*(--[a-zA-Z])*)|(_(is|has)_([a-zA-Z0-9]){2,})$ #hyphenated_lowercase # or 'BEM', or 'hyphenated_BEM', or 'snake_case', or 'camel_case', or a regex pattern
    severity: warning

  Shorthand:
    enabled: true
    severity: warning

  SingleLinePerProperty:
    enabled: true
    allow_single_line_rule_sets: true
    severity: warning

  SingleLinePerSelector:
    enabled: true
    severity: error

  SpaceAfterComma:
    enabled: true
    severity: error

  SpaceAfterPropertyColon:
    enabled: true
    style: one_space # or 'no_space', or 'at_least_one_space', or 'aligned'
    severity: error

  SpaceAfterPropertyName:
    enabled: true
    severity: error

  SpaceBeforeBrace:
    enabled: true
    style: space # or 'new_line'
    allow_single_line_padding: false
    severity: error

  SpaceBetweenParens:
    enabled: true
    spaces: 0
    severity: error

  StringQuotes:
    enabled: true
    style: single_quotes # or double_quotes
    severity: warning

  TrailingSemicolon:
    enabled: true
    severity: error

  TrailingZero:
    enabled: false
    severity: warning

  UnnecessaryMantissa:
    enabled: true
    severity: warning

  UnnecessaryParentReference:
    enabled: true
    severity: warning

  UrlFormat:
    enabled: true
    severity: warning

  UrlQuotes:
    enabled: true
    severity: warning

  VariableForProperty:
    enabled: true
    properties: []
    severity: warning

  VendorPrefixes:
    enabled: false
    severity: warning

  VendorPrefix:
    enabled: false
    identifier_list: base
    additional_identifiers: []
    excluded_identifiers: []
    severity: warning

  ZeroUnit:
    enabled: true
    severity: warning

  Compass::*:
    enabled: false
    severity: warning

Could you please tell us if this is a bug in the package, a misuse of the CLI, or something wrong in the yaml file, so that we know what needs fixing ?

sds commented 9 years ago

Hey @mlarcher,

I don't develop on Windows, but it appears that you are passing a glob pattern (i.e. **/*.scss) to scss-lint via the command line and it is receiving those literal strings. This tells me you aren't using a shell to expand those patterns ahead of time.

In case you aren't familiar, any glob pattern is expanded by your shell (e.g. typically bash/zsh if you're on some *nix distribution; for Windows it's cmd.exe). Since cmd.exe does not support wildcard expansion, this explains why the literal string is being passed along.

scss-lint doesn't expand these patterns for you because asterisks are valid characters in file names. Thus whatever is invoking scss-lint needs to expand the pattern and pass the list of files to scss-lint.

Hope that helps.

mlarcher commented 9 years ago

Thanks for the quick reply. The initial problem is that scss-lint needs to operate on a large collection of scss files, and the windows command line is limited to 8192 characters, which is quickly reached when listing a collection of file paths. Would it be possible to provide an alternative way for scss-lint to get to the actual files ? Surely there must be some options available, don't you think ?

sds commented 9 years ago

As long as all you're trying to do is lint files in a directory, you can just pass the directory. scss-lint will recursively scan for any files ending with .scss and lint them.

scss-lint /path/to/project/dir
mlarcher commented 9 years ago

Great, thank you.