xdan / vscode-stylint

Enables Stylint on VS Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

VS Code Stylint extension

Version Downloads Ratings Stars
License Build Status
David David PRs Welcome
Donate

Description

Integrates Stylint into VS Code. If you are new to Stylint check the documentation.

The extension uses the Stylint library installed in the opened workspace folder. If the folder doesn't provide one the extension looks for a global install version. If you haven't installed Stylint either locally or globally do so by running npm install stylint in the workspace folder for a local install or npm install -g stylint for a global install.

On new folders you might also need to create a .stylintrc configuration file. The extension will search for an .stylintrc file on the workspace folder root.

This extension was heavily inspired by Dirk Baeumer's ESLint extension.

Installation

Via Visual Studio Code

  1. Press Ctrl + P to open the Go to File... view
  2. Type ext install HaaLeo.vscode-stylint and press Enter

From VSIX

  1. Download the .vsix file of the latest release from GitHub
  2. Run code --install-extension vscode-stylint-*.*.*.vsix in the command line (reference)

Settings Options

This extension contributes the following variables to the settings:

  • stylint.enable: enable/disable stylint. Is enabled by default.

  • stylint.stylintrcPath: The path to the .stylintrc file. When no .stylintrc file is found the default options are used.

  • stylint.packageManager: controls the package manager to be used to resolve the Stylint library. This has only an influence if the Stylint library is resolved globally. Valid values are "npm" or "yarn".

  • stylint.run: run the linter onSave or onType, default is onType.

  • stylint.nodePath: use this setting if an installed Stylint package can't be detected, for example /myGlobalNodePackages/node_modules.

  • stylint.alwaysShowStatus: Always show the Stylint status bar item.

  • stylint.trace.server: Traces the communication between VSCode and the stylint linter service.

  • stylint.workingDirectories - an array for working directories to be used. Stylint resolves configuration files relative to a working directory. This new settings allows users to control which working directory is used for which files. Consider the following setups:

    client/
      .stylintignore
      .stylintrc
      client.styl
    server/
      .stylintignore
      .stylintrc
      server.styl
    

    Then using the setting:

      "stylint.workingDirectories": [
        "./client", "./server"
      ]

    will validate files inside the server directory with the server directory as the current working directory. Same for files in the client directory. If the setting is omitted the working directory is the workspace folder.

    The setting also supports literals of the form { "directory": string, "changeProcessCWD": boolean } as elements. Use this form if you want to instruct Stylint to change the current working directory of the Stylint validation process to the value of directory as well.

Commands:

This extension contributes the following commands to the Command palette.

  • Disable Stylint for this Workspace: disables Stylint extension for this workspace.
  • Enable Stylint for this Workspace: enable Stylint extension for this workspace.
  • stylint.showOutputChannel: show the output channel of the Stylint extension.

Known Issues

When updating VS Code to a version that ships with a new Node.js version (like v1.31.0 did), a bug can occur that causes the extension host to crash. This happens, because the extension depends on native Node.js modules.
When you face this bug please refer to issue #7 for further details and a possible fix.

Contribution

If you found a bug or are missing a feature do not hesitate to file an issue.
Pull Requests are welcome!

Support

When you like this extension make sure to star the repo and write a review. I am always looking for new ideas and feedback.
In addition, it is possible to donate via paypal.

About

Enables Stylint on VS Code

License:MIT License


Languages

Language:TypeScript 100.0%