Code Monkey home page Code Monkey logo

sublimelinter-csslint's Introduction

SublimeLinter

tests

The code linting framework for Sublime Text. No linters included: get them via Package Control.

Installation

Note

The current stable version of Sublime Text, Build 4169, has a bug and cannot install SublimeLinter without requiring a restart. You're fine if you have a later dev build, e.g. build 4173.

Note

We're in a transition phase to the newer ST4 plugin host. Unless we have more experience for the process, it may be necessary to restart Sublime Text after installing or upgrading helper packages. Just check if everything works or if the console shows permanent errors. On my machine, no restarts were necessary.

Probably don't get fancy and just install SublimeLinter via Package Control. Refer https://www.sublimelinter.com/en/latest/installation.html for further information, but, spoiler!, usually you install SublimeLinter, the plugin you're currently looking at, some command line tools, these are the actual linters (e.g. eslint or flake8), and then some plugins/adapters between both. These are typically named after the linter and should be installed via Package Control as well, examples would be SublimeLinter-eslint or SublimeLinter-flake8.

By default, SublimeLinter will run in the background and most linters support this mode so you should get squiggles immediately.

Note that you find all commands we're installing using the Command Palette (ctrl+shift+p). Just search for SublimeLinter. You may find https://github.com/kaste/SublimeLinter-addon-toggler and/or https://github.com/kaste/SublimeLinter-addon-goto-flash useful.

Settings

Settings are documented in the default settings. Open the settings using the Command Palette (ctrl+shift+p) searching for Preferences: SublimeLinter Settings (mnemonic: sls).

When you open the SublimeLinter settings you'll see the defaults on the left or top. Usually that's all that is needed for end-users but some additional information is in our docs at sublimelinter.com.

Key Bindings

SublimeLinter comes with some pre-defined keyboard shortcuts. You can customize these via the Package Settings menu.

Command Linux & Windows MacOS
Lint this view Ctrl + k, l Ctrl + + l
Open diagnostics panel Ctrl + k, a Ctrl + + a
Goto next error Ctrl + k, n Ctrl + + e
Goto prev error Ctrl + k, p Ctrl + + Shift + e

Take also a look at the default bindings because we document other commands and have usually some tricks in there too.

For example, it is very advisable to bind sublime_linter_quick_actions, e.g.

    // To trigger a quick action
    // { "keys": ["ctrl+k", "ctrl+f"],
    //   "command": "sublime_linter_quick_actions"
    // },

Quick Actions/Fixers

As we do just linting SublimeLinter naturally does not come with fixers and/or code formatters. However, we have a fixer API, see the Command Palette: SublimeLinter: Quick Action, and ship (mostly) "fix by ignoring" actions. These allow you to quickly ignore specific error messages inline and ad hoc.[1]

SublimeLinter currently ships actions for eslint, stylelint, flake8, mypy, shellcheck, codespell and phpcs.

Want to see actions for your favourite linter? Please open a PR with your addition to quick_fix.py. We have tests for them!

[1] Why this limitation though? Well it is usually easy to add a semicolon here and a space there, but the inline ignore rules and syntaxes are very cumbersome to type and to remember. And there is basically no project of any size where you don't have to ignore ad-hoc something somewhere once.

Support & Bugs

Yeah, totally! Often if it doesn't work, Sublime will have something in the console (View -> Show Console). Warnings will go there by default.

You can enable debug mode in the settings to get much more information about what's going on. Especially seeing the exact command and working dir SublimeLinter will use should be noted and helpful.

As some code only runs on startup, it is good practice to restart Sublime Text and to examine the console output for anything odd.

If your issue is specific to a particular linter, please report it on that linter's repository, otherwise open it right here.

Hack on it

Sure, you're welcome! Just clone the repository into your Packages folder (Preferences -> Browse Packages).

> git clone https://github.com/SublimeLinter/SublimeLinter.git
> subl SublimeLinter

This will overrule the installed package straight away. Just delete the folder to reverse the process. The dev requirements can be read in the pyproject.toml file. Just use rye and install them:

> rye sync

Creating a linter plugin

Use the template to get started on your plugin. It contains a how-to with all the information you need. Refer to https://www.sublimelinter.com/en/master/linter_plugin.html for more detailed information. Of course, take a look at a similar linter plugin and let it inspire you.

Also Support ❤️

SublimeLinter is the kind of software that needs active maintenance all the time. If you find SublimeLinter helpful and would like to show your appreciation, you can support its development by buying me a coffee! 😄☕ https://paypal.me/herrkaste

😏

sublimelinter-csslint's People

Contributors

aparajita avatar braver avatar groteworld avatar kaste avatar mokkabonna avatar william-voyek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimelinter-csslint's Issues

Suggestions & errors not showing up

I have followed all the installation steps, but still I am not able to see the suggestions in the sublime bar.

1. Linter installation
I installed csslint 0.10. via node.js,
screenshot 1

2. Linter configuration

path is available to SublimeLinter. using Path Editor (see previous screenshot)

3. Plugin installation

SublimeLinter is installed and of course SublimeLinter-csslint as well (also htmltidy and is working perfectly)
screenshot 2
screenshot3

So What am I missing?

Style attribute errors

I started getting the following linter error today in HTML style attributes:

Expected a `FUNCTION` or `IDENT` after colon at line x, col x.

It seems to be caused by setting the selector to source.css. I'm not sure if csslint is able to lint style attributes or not, so that may be the issue.

It shows error on <style> tag in html file

When I insert a style tag in my html file, It always shows error on the tag
qq 20150817161203

html code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>

    <style type="text/css">

    </style>
</head>
<body>
</body>
</html>

file extension option

Hi,

i have custom files with an "rjss" extension. Those files are actually css files. Could you add custom file extension support?

Thanks

Deprecation warning

WARNING: csslint: Implicit appending a filename to cmd has been deprecated, add '${temp_file}' explicitly.

working directory of the plugin needed to place .csslintrc

I am following the instructions at the csslint documentation and set up my .csslintrc configuration file. However, the file is only considered by csslint, when there is located in the working directory. With the CLI, this is easily done, but where is the working directory of the SublimeLinter-csslint-plugin?

It does not seem to be my home directory ~/ or any other Sublime-related path I tried out. There is no information in the documentation where to place .csslintrc?

indent warnig

Hello,
Is there any way to ignore indent warning?? I like to indent the code with 4 spaces, so most of my css files have warnings around and is more difficult to identify other problems. Using Linux.
Thanks in advance

How to configure rules to exclude/ignore

I have Googled around and can't find any sample files or docs on how to correctly set SublimeLinter prefs file as to which csslint rules should be ignored. I currently have this:

"csslint": {
                "@disable": false,
                "args": [],
                "errors": "",
                "excludes": [
                    "ids",
                    "box-model",
                    "font-sizes",
                    "unique-headings",
                    "import",
                    "qualified-headings",
                    "adjoining-classes",
                    "overqualified-elements"
                ],
                "ignore": "",
                "ignored": [],
                "warnings": ""
            },

I have tried exclude and ignored, but the errors are still flagged.

Errors in HTML files

The linter won't lint the stuff inside of <style> tags only, but rather the stuff inside of <style> tags PLUS the <style> tags themselves, resulting in:

SublimeLinter: csslint: index.html ['/usr/local/share/npm/bin/csslint', '--format=compact'] 
SublimeLinter: csslint output:
/var/folders/6w/c6f6tzcd5c5f__5hymgym3080000gn/T/tmpw1z3i6.css: line 1, col 5, Error - Unexpected token '<' at line 1, col 5.
/var/folders/6w/c6f6tzcd5c5f__5hymgym3080000gn/T/tmpw1z3i6.css: line 7, col 5, Error - Unexpected token '<' at line 7, col 5.
/var/folders/6w/c6f6tzcd5c5f__5hymgym3080000gn/T/tmpw1z3i6.css: line 7, col 6, Error - Unexpected token '/' at line 7, col 6.
/var/folders/6w/c6f6tzcd5c5f__5hymgym3080000gn/T/tmpw1z3i6.css: line 8, col 1, Error - Unexpected token 'null' at line 8, col 1.
/var/folders/6w/c6f6tzcd5c5f__5hymgym3080000gn/T/tmpw1z3i6.css: line 8, col 1, Error - Unexpected token 'null' at line 8, col 1. 

csslint works only until restart

After being automatically upgraded to SublimeLinter 4.0, I have only been able to get csslint working for me if I remove and reinstall the package. And then, it only works until I restart Sublime Text. Is this an issue with SublimeLinter, csslint, or something unique to my environment? Thanks!

syntax error - expecting end of input

For reasons unclear to me at the moment, I noticed ST3 wasn't linting my SCSS files anymore. So I openend the console and saw the following.

Writing file /C/Program Files (x86)/xampp/htdocs/maxfactor/scss/components/_lists.scss with encoding UTF-8 (atomic)
SublimeLinter: scss: _lists.scss ['C:\\Ruby200-x64\\bin\\ruby.exe', 'C:\\Ruby200-x64\\bin\\scss-lint.bat', '--config', 'C:\\Program Files (x86)\\xampp\\htdocs\\maxfactor\\.scss-lint.yml'] 
SublimeLinter: scss output:
C:/Ruby200-x64/bin/scss-lint.bat:1: syntax error, unexpected tCONSTANT, expecting end-of-input 

Linting on the command line works fine so it doesn't seem like it's an issue with the scss-lint gem. Also linting with another 3rd party which uses the gem gulp-scsslint works fine.

Any thoughts?

Plugin linting html style tag and forcing errors.

"This linter plugin for SublimeLinter provides an interface to csslint. It will be used with files that have the 'CSS' syntax, or within style tags in HTML files"
The plugin doesn't only lint the CSS inside the style tag, but also the style tag itself, causing some errors.

An empty style tag only throws one error, trimming empty, which is fine.

But a not empty style tag

<style type="text/css">
 /\* some actual css */
</style>
throws 9 errors:

Unexpected token '<' at line 1, col 1;
Expected LBRACE at line 1, col 12;
Unexpected token '=' at line 1, col 12;
Unexpected token '"text/css"' at line 1, col 13;
Unexpected token '>' at line 1, col 23;
Unexpected token '<' at line 3, col 1;
Unexpected token '/' at line 3, col 2;
Unexpected token 'null' at line 4, col 1;
Unexpected token 'null' at line 4, col 1;

image

Preprocessors?

What’s the stance on support for preprocessors? Are any preprocessors supported by csslint out of the box, or even by extension?

LESS/SCSS syntax is just normal CSS with some extensions, so the content of these files should be parseable by csslint (at least when it is just normal CSS). However, this linter package only appears to lint files that have their syntax set to “CSS”. In my case, I have the syntax set to “LESS”.

Can I get the linter to recognise my LESS files?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.