CSSLint / csslint

Automated linting of Cascading Stylesheets
http://csslint.net
Other
4.77k stars 483 forks source link

Missing global options #679

Closed kevincolten closed 7 years ago

kevincolten commented 8 years ago

I've installed csslint via npm.

In my .csslintrc, (here's a sample)

{
    "adjoining-classes": false
}

I get this error

$ csslint ./**/*.css
adjoining-classes is not a valid option. Exiting...

When I console.log(globalOptions), I only see

{ help: { format: '', description: 'Displays this information.' },
  format:
   { format: '<format>',
     description: 'Indicate which format to use for output.' },
  'list-rules':
   { format: '',
     description: 'Outputs all of the rules available.' },
  quiet:
   { format: '',
     description: 'Only output when errors are present.' },
  errors:
   { format: '<rule[,rule]+>',
     description: 'Indicate which rules to include as errors.' },
  warnings:
   { format: '<rule[,rule]+>',
     description: 'Indicate which rules to include as warnings.' },
  ignore:
   { format: '<rule[,rule]+>',
     description: 'Indicate which rules to ignore completely.' },
  'exclude-list':
   { format: '<file|dir[,file|dir]+>',
     description: 'Indicate which files/directories to exclude from being linted.' },
  config:
   { format: '<file>',
     description: 'Reads csslint options from specified file.' },
  version:
   { format: '',
     description: 'Outputs the current version number.' } }

Which is, in fact, missing adjoining-classes and every other option found in the sample .csslintrc.

Am I missing something an install step somewhere?

michaelalhilly commented 7 years ago

I'm experiencing the same.

rbecheras commented 7 years ago

Me too, and even with command line options

rbecheras commented 7 years ago

Ok I just solved my problem. The format of the .csslintrc has changed.

It isn't a JSON file anymore. Instead you must use the command line options format, one line by option.

Here an example:

--errors=bulletproof-font-face,display-property-grouping,duplicate-background-images,duplicate-properties,empty-rules,floats,outline-none,font-faces,ids,import,important,known-properties,qualified-headings,regex-selectors,shorthand,star-property-hack,text-indent,underscore-property-hack,unique-headings,vendor-prefix,zero-units
--warnings=compatible-vendor-prefixes,fallback-colors,font-sizes,gradients,non-link-hover,overqualified-elements
--ignore=adjoining-classes,box-model,box-sizing,unqualified-attributes,universal-selector

Now it works for me.

rbecheras commented 7 years ago

@XhmikosR , I guess this issue can be closed now.

adambullmer commented 7 years ago

Looks like they still support .csslintrc files, but with the added granularity of ignore, error, warning means you will need to add those grouping keys to your config file. E.x.

{
  "ignore": [
    "adjoining-classes"
  ],
  "warnings": [
  ],
  "errors": [
  ]
}

Because of the 3 possible levels per option, they just want a list of things, rather than requiring what is used under the hood.

trisys3 commented 7 years ago

When I change this, I now get:

/home/smoran/lib/node_modules/csslint/dist/csslint-node.js:3286
                output += "\n" + message.evidence;
                               ^

RangeError: Invalid string length
    at /home/smoran/lib/node_modules/csslint/dist/csslint-node.js:3286:32
    at Array.forEach (native)
    at Object.CSSLint.Util.forEach (/home/smoran/lib/node_modules/csslint/dist/csslint-node.js:577:27)
    at Object.CSSLint.addFormatter.formatResults (/home/smoran/lib/node_modules/csslint/dist/csslint-node.js:3278:22)
    at processFile (/home/smoran/lib/node_modules/csslint/dist/cli.js:183:32)
    at /home/smoran/lib/node_modules/csslint/dist/cli.js:264:36
    at Array.forEach (native)
    at processFiles (/home/smoran/lib/node_modules/csslint/dist/cli.js:262:23)
    at cli (/home/smoran/lib/node_modules/csslint/dist/cli.js:401:14)
    at Object.<anonymous> (/home/smoran/lib/node_modules/csslint/dist/cli.js:417:1)

My .csslintrc file is:

{
    "errors": [
        ...errors
    ],
    "ignore": [
        ...ignored rules
    ],
    "warnings": [
        ...warnings
    ]
}
trisys3 commented 7 years ago

This is probably irrelevant, but I get the same error when I have no .csslintrc file.

Kristinita commented 7 years ago

@XhmikosR , @eriwen , @tomasz-oponowicz , @nschonni , please, update wiki page, that old .csslintrc format don't work now.

Thanks.