Coder Social home page Coder Social logo

vscode-stylint's Introduction

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.

vscode-stylint's People

Contributors

dependabot[bot] avatar haaleo avatar maranomynet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

maranomynet xdan

vscode-stylint's Issues

Local .stylintrc in project-root isn't used/detected

I have a .stylintrc in my project root (next to my package.json) but vscode-stylint doesn't pick it up.
Instead vscode-stylint only looks in the VSCode workspace root.

I believe the expected behavior would be for vscode-stylint to resolve the .stylintrc file by traversing up the directory tree from each open *.styl file, all the way up to the file-system root folder.

Crashes when too many errors

When stylint reports a lot of errors, this extension appears to cut off the stylint's JSON output, resulting in invalid JSON and a fatal error.

Steps to reproduce:

  1. Attempt to lint this file:

     .main
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
         height 1
     
  2. This error appears:
    Stylint: Unexpected end of JSON input. Please see the 'Stylint' output channel for details.

Unexpected end of JSON input

VS Code Version vscode-stylint Version Installed Stylint Version OS
1.39.2 0.1.3 2.0.0 macOS Catalina 10.15

Description

Each time the Stylint check is triggered (e.g. keystroke), a notification is triggered with "Stylint: Unexpected end of JSON input. Please see the 'Stylint' output channel for details."

Attempted to restart VSCode, attempted various settings in settings.json including different working directories and stylintrc locations, attempted different chmod settings for .stylintrc.

Contents of .stylintrc in the project root is valid and complete JSON.

Expected Behavior

Notification should not occur. Stylint check should run.

Actual Behavior

Notification occurs. Stylint does not run.

Steps to Reproduce

I installed Visual Code Studio, and the plug-in onto a brand new Mac.

Logs

Filename at textDocument.uri and actual Stylus input at contentChanges.text redacted in the logs below.


[Trace - 12:50:08 AM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///Users/groenroos/Repositories/(...).styl",
        "version": 8
    },
    "contentChanges": [
        {
            "text": "(big block of Stylus here)"
        }
    ]
}

[Trace - 12:50:08 AM] Received request 'window/showMessageRequest - (30)'.
Params: {
"type": 1,
"message": "Stylint: Unexpected end of JSON input. Please see the 'Stylint' output channel for details.",
"actions": []
}

[Trace - 12:50:08 AM] Received notification 'window/logMessage'.
Params: {
"type": 1,
"message": "Stylint stack trace:"
}

[Error - 12:50:08 AM] Stylint stack trace:
[Trace - 12:50:08 AM] Received notification 'window/logMessage'.
Params: {
"type": 1,
"message": "SyntaxError: Unexpected end of JSON input\n at JSON.parse ()\n at StylintModule. (/Users/groenroos/.vscode/extensions/haaleo.vscode-stylint-0.1.3/server/out/stylintModule.js:44:25)\n at Generator.next ()\n at fulfilled (/Users/groenroos/.vscode/extensions/haaleo.vscode-stylint-0.1.3/server/out/stylintModule.js:8:58)"
}

[Error - 12:50:08 AM] SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at StylintModule. (/Users/groenroos/.vscode/extensions/haaleo.vscode-stylint-0.1.3/server/out/stylintModule.js:44:25)
at Generator.next ()
at fulfilled (/Users/groenroos/.vscode/extensions/haaleo.vscode-stylint-0.1.3/server/out/stylintModule.js:8:58)
[Trace - 12:50:08 AM] Received notification 'stylint/status'.
Params: {
"state": 3
}

Settings


{
    "stylint.stylintrcPath": ".stylintrc",
    "stylint.trace.server": "verbose",
    "files.associations": {
        "*.vue": "stylus"
    }
}

Lazy symbol binding failed

VS Code Version: vscode-stylint Version: Installed Stylint Version:
1.31.0 0.1.1 1.5.9

Description

I am getting the following error when Stylint runs on a typed change. I do have have a .stylintrc file configured and in the root of my project

Stylint: dyld: lazy symbol binding failed: Symbol not found: 

Expected Behavior

It should lint the file and not throw a notification error

Actual Behavior

Steps to Reproduce

  1. Install Stylint
  2. Install VS Code extension
  3. Configure .stylintrc
  4. Open VSCode and edit a .styl file
  5. Notification appears
    image

Logs



__ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE Referenced from: /Users/bzeffren/code/rms-one-app/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node Expected in: flat namespace dyld: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE Referenced from: /Users/bzeffren/code/rms-one-app/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node Expected in: flat namespace. Please see the 'Stylint' output channel for details.

Settings



{
  "stylint.alwaysShowStatus": true,
  "stylint.trace.server": "verbose"
}

Exec path not found

VS Code Version vscode-stylint Version Installed Stylint Version OS
1.41.1 && 1.42.0-insider 0.1.3 [email protected] macOS 10.15.2

Description

Error message notification appears immediately upon opening a .styl file.

Screen Shot 2019-12-27 at 10 12 35 AM

Expected Behavior

Actual Behavior

Extension appears to be working despite the error message constantly popping up.

Steps to Reproduce

  1. Error message appears as soon as a .styl file is opened in the editor.

Logs



[Info  - 10:26:09 AM] Stylint server stopped.
[Info  - 10:26:10 AM] Stylint server is running.
[Info  - 10:26:10 AM] Stylint exec path set to /usr/local/lib/node_modules/stylint/bin/stylint
[Error - 10:26:11 AM] Stylint stack trace:
[Error - 10:26:11 AM] Error: /usr/local/lib/node_modules/stylint/src/core/read.js:32
			throw Error( 'Stylint Error: No such file or dir exists!' )
			^

Error: Stylint Error: No such file or dir exists!
at F. (/usr/local/lib/node_modules/stylint/src/core/read.js:32:10)
at FSReqCallback.oncomplete (fs.js:165:21)
at ChildProcess. (/Users/philipsinatra/.vscode-insiders/extensions/haaleo.vscode-stylint-0.1.3/server/node_modules/sb-exec/lib/index.js:56:20)
at ChildProcess.emit (events.js:200:13)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)

Settings



None.

Where is the status bar button?

Hi, I'm trying to get your extension working but need help troubleshooting.
I have stylint.alwaysShowStatus enabled but I don't see any buttons.

Also, I have trace:server set to verbose but don't see Stylint in the OUTPUT list.

image

Thanks for any help!

dyld: lazy symbol binding failed: Symbol not found

VS Code Version vscode-stylint Version Installed Stylint Version OS
1.33.1 0.1.3 1.5.9 MacOS

Description

I'm getting error like in #7

Stylint: dyld: lazy symbol binding failed: Symbol not found:

Steps to reproduce are absolutely the same. But reinstalling fsevents (#7 (comment)) doesn't work for me.

Logs



Stylint: dyld: lazy symbol binding failed: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE   Referenced from: /Users/vovaspace/dev/project-starter/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node   Expected in: flat namespace  dyld: Symbol not found: __ZN2v816FunctionTemplate3NewEPNS_7IsolateEPFvRKNS_20FunctionCallbackInfoINS_5ValueEEEENS_5LocalIS4_EENSA_INS_9SignatureEEEiNS_19ConstructorBehaviorENS_14SideEffectTypeE   Referenced from: /Users/vovaspace/dev/project-starter/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node   Expected in: flat namespace. Please see the 'Stylint' output channel for details.

Settings



"stylint.trace.server": "verbose"

Auto-detect stylint installed by `yarn global`

Hi. I like the plugin.
It would be nice if it could automatically pick up stylint installed via yarn global add stylint so we don't need to hard-code the file path into stylint.nodePath.

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.