Code Monkey home page Code Monkey logo

sublimelinter-coffeelint'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-coffeelint's People

Contributors

aparajita avatar braver avatar cybolic avatar gbouthenot avatar groteworld avatar kaste avatar mokkabonna avatar tomasbarry 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sublimelinter-coffeelint's Issues

Issue linting jQuery each method

When using the each method from jquery, I alway get a "inconsistent indentation" error on the 2nd line, where says frag += in this example:

$.each content, (index, obj) ->
  frag +=
    template.replace( /{{title}}/ig, obj.title )
            .replace( /{{thumbnail}}/ig, obj.thumbnail )

Is this a compatibility issue?

Btw, this code validates without issues in http://www.coffeelint.org

Configuration

Hi,

This tool is really great, except that I have trouble configuring it in Sublime Text. Is there somewhere a detailed explanation or examples for configuration in Sublime or where to put a configuration file ?

(right now the alerts about the length of the line and the use of tabs make that the tool is unusable)

Thanks a lot !

add options to sublime-settings to ignore/override linter rules

The coffeelint linter applies every default rule when run without a configuration file. It's impractical for users to create configuration files for every project, and the SublimeLinter interface should allow global customization from within Sublime Text. SublimeLinter-coffeelint should be modified to read an ignore list from the SublimeLinter.sublime-settings file, as SublimeLinter-flake8 does, and apply these rules to coffeelint.

Doesn't build for ST3 Package Control (503 error)

From Sublime 3 console:

reloading Packages/User/Preferences.sublime-settings
found 1 files for base name Default.sublime-theme
theme loaded
Package Control: Error downloading package. HTTP error 503 downloading https://codeload.github.com/SublimeLinter/SublimeLinter-coffeelint/zip/1.1.4.
error: Package Control

Unable to download SublimeLinter-coffeelint. Please view the console for more details.
ignored packages updated to: [Vintage]
found 1 files for base name Default.sublime-theme
theme loaded
reloading Packages/User/Preferences.sublime-settings
found 1 files for base name Default.sublime-theme
theme loaded

coffeelint.json configuration files in SublimeLinter 4

As of version 4 of SublimeLinter the support for the config_file is removed (SublimeLinter/SublimeLinter#891). Therefore it is no longer possible to use the project specific coffeelint.json configuration files.

In the old implementation SL was checking the tree upwards till the file was found. But now each linter should handle this on their own.
Coffeelint does support this behavior as well but not for stdin executions.

Therefore the old behavior needs to be implemented for SL-coffeelint again (maybe similar to oschwald/SublimeLinter-perlcritic#7)

Doesn't appear to support "coffeelintConfig" in the package.json file

In the CoffeeLint documentation, it states that it supports CoffeeLint rules in the package.json file.

New in 1.0: CoffeeLint will automatically pick up config files. When linting a file (as opposed to stdin) it will walk up the directory tree looking for a coffeelint.json or a package.json that has a "coffeelintConfig" object. If neither of those are found or you're linting from stdin it will check your home for a coffeelint.json file."

This can be verified by running something like coffeelint src/ with the rules in place. This behaviour doesn't appear to work with SublimeLinter-coffeelint though.

I've trued clearing the SublimeLinter cache, but I believe this is a bug in the implementation

Linter doesn't use nearest coffeelint.json file

In summary, the linter uses the top-most coffeelint.json file it finds, instead of the nearest. That means that we can't use directory-level overrides.

Here's a repo that reproduces this case:

https://github.com/morleyzhi/sublime-coffeelint-cascade

If you clone and open forty-chars/test.coffee and save, you would expect it to use forty-chars/coffeelint.json, but it doesn't, according to the Sublime console (and the lint results):

SublimeLinter: coffeelint: test.coffee ['C:\\Users\\Morley\\AppData\\Roaming\\npm\\coffeelint.cmd', '--reporter', 'jslint', '--stdin', '-f', 'C:\\Users\\Morley\\Documents\\GitHub\\sublime-coffeelint-cascade\\forty-chars\\coffeelint.json'] 

How can I lint .cjsx files

Hi,

I'm trying to lint my .cjsx files (CoffeeScript JSX Syntax) but I don't know how can I configure sublimelinter for check those files

can you help me?

Linter doesn't respect --file arg

Whenever I try to use --file instead of -f to specify a config file in my preferences, SublimeLinter tries to run:

['/usr/local/bin/coffeelint', '--reporter', 'jslint', '--stdin', '--file', '<myfile>', '-f', '<home>/coffeelint.json'] 

Instead of replacing the -f argument with --file.

linter doesn't show warnings

When I lint a CS file, I only ever get syntax errors reported. However, I have coffeelint configured to report errors e.g. on shadowed variables, inconsistent indentation, duplicate keys and so on; running coffeelint from the command line does show these issues, but they remain unmarked in ST3. Is there a setting I'm missing?

Note: Just to be on the safe side, I copied my settings from ~/coffeelint.json to ~/npm/lib/node_modules/coffeelint/coffeelint.json, as I've read there may be issues in finding the right configuration file.

EDIT This issue can probably be closed. The problem got solved when I renamed the ~/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter-coffeelint.sublime-package file (originally I wanted to see whether I could change some code in the package). Now I wonder exactly which ST plugin gets executed to highlight errors, but on the other hand, I do get errors and warnings marked.

Allow to set configuration file in plugin settings

I'd like to change the configuration filename from coffeelint.json to .coffeelintrc

It's possible to override the entire "-f" option in plugin settings:

{
  "user": {
    "linters": {
      "coffeelint": {
        "@disable": false,
        "args": ["-f", "${project}/.coffeelintrc"],
        "excludes": []
      }
    }
  }
}

But in this case, we can't use the "bubble search" of the file performed by SublimeLinter

A better solution could be to let user specify the file name in settings, and use it in the config_file linter attribute, instead of having it hard-coded

Does it seem doable ?

Should use `coffeelint.json`

The coffeelint man page states:

New in 1.0: CoffeeLint will automatically pick up config files. When linting a file (as opposed to stdin) it will walk up the directory tree looking for a coffeelint.json or a package.json that has a "coffeelintConfig" object. If neither of those are found or you're linting from stdin it will check your home for a coffeelint.json file.

It would be nice if the plugin would find the correct coffeelint.json by traversing the directory tree of the current file and append the correct -f flag.

Doesn't honor "args"

Similar to #1, I'd like to be able to customize the linter options. This plugin should honor these settings in the SublimeLinter.sublime-settings file:

            "coffeelint": {
                "@disable": false,
                "args": "-f .coffeelint.json",
                "excludes": []
            }

Where .coffeelint.json is a file at the root of the currently open folder or project.

.zshenv cannot load nvm

I am using zsh & nvm, so I've followed the 3rd step in "Linter installation", but .zshenv cannot load nvm.
Relogin or restart the system cannot help either.

What exactly should I do?

coffeelint.json file location

I apologize if this is an obvious question, but I'm new to Node and using linters with Sublime Text 3.

I've followed the instructions to generate a config file from here: http://www.coffeelint.org/#usage. Now where do I need to place the coffeelint.json file so that ST3 reads it first?

Thank you.

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.