GithubHelp home page GithubHelp logo

vscode-jscs's Introduction

alt text

alt text

JSCS Support for Visual Studio Code

JSCS support for Visual Studio Code.

❗IMPORTANT: JSCS is deprecated and has merged with ESLint.

Please migrate your projects to ESLint and use the VS Code ESLint extension.

Installation and Usage

The JSCS Linter is available in the Visual Studio Code Gallery. To install, press F1 and select Extensions: Install Extensions and then search for and select JSCS Linting.

Install JSCS in your workspace (or globally using the -g switch).

# install locally to the workspace
npm install jscs

Once installed, the JSCS Linter will automatically analyze your JavaScript files and return style warnings based on the rules you define in a .jscsrc file or in your settings.

Configuring the JSCS Linter

The best way to configure how the linter flags issues in your code is to create a .jscsrc file in the root of your workspace. The VS Code JSCS Linter will look for this file first and if no .jscsrc file is found it will look into your custom Settings.

Here are the available settings options:

Enable or disable the JSCS Linter for JavaScript files in this workspace.

"jscs.enable": boolean

The JSCS preset to use, possible values: airbnb, crockford, google, grunt, idiomatic, jquery, mdcs, node-style-guide, wikimedia, wordpress, yandex.

"jscs.preset": string

Disable the JSCS Linter if no .jscsrc configuration file is found, default is false.

"jscs.disableIfNoConfig": boolean

Set JSCS configuration rules in your settings file directly.

"jscs.configuration": object

Development

The JSCS Linter is a great way to learn how to create extensions for VS Code. We also love enhancements and bug fixes! Here's how to get started:

git clone https://github.com/microsoft/vscode-jscs
cd vscode-jscs/jscs
npm install
cd ../jscs-server
npm install

Developing the Server

  • Open VS Code on the jscs-server folder
  • Run npm run compile or npm run watch to build the server and copy it into the jscs folder
  • To debug, press F5 once the extension is loaded, this will attach the debugger to the server. If you try to attach too soon you will get a timeout error from the debugger.

Developing the Extension

  • Open VS Code on the jscs folder
  • To run, press F5 to build the app, launch the extension environment, and attach a debugger

Enjoy!

License

MIT

vscode-jscs's People

Contributors

angrieco avatar chrisdias avatar dbaeumer avatar egamma avatar mjbvz avatar scottaddie avatar spaceshot 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

Watchers

 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

vscode-jscs's Issues

JSON schema support for .jscsrc

From @scottaddie on November 22, 2015 4:23

Prior to the 0.10.1 release, the following settings were baked into the editor:

    // Control whether jshint is enabled for JavaScript files or not.
"jshint.enable": true,

// The jshint options object to provide args to the jshint command.
"jshint.options": {},

Now that there's an official JSHint extension, the following schema support should be added by it rather than including it into the editor:

    {
        "fileMatch": [
            "/.jshintrc"
        ],
        "url": "http://json.schemastore.org/jshintrc"
    },

I'd argue the same point regarding the JSCS extension. It should add the following to the settings, rather than baking it into the editor:

    {
        "fileMatch": [
            "/.jscsrc"
        ],
        "url": "http://json.schemastore.org/jscsrc"
    }

Copied from original issue: microsoft/vscode#433

JSCS should clear errors if a file gets closed

We removed some bogus code in 1.3.x from the core which cleared markers on buffer close. We had to remove that to get to a consistent project build story. No the producer of markers must ensure to clear them if not needed anymore.

If you don't do anything fancy you can use the following snippet:
// Clear diagnostics on close.
documents.onDidClose((event) => {
connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
});

Security warnings - bad links on extension detail page

For reference, extension page: https://marketplace.visualstudio.com/items?itemName=ms-vscode.jscs

Issue 1: Security warning discovered

The link provided by Microsoft's extension page starts with insecure http. One of the first links leads to

http://jscs.info

Evidence screenshot of a bad link - VSCode
Code_uI4CEqUIcR

Issue 2: The site is now owned by someone else

Originally reported by @md2perpe, issue: #23

  1. The site is no longer relevant to the extension description.
  2. Some links made by the extension readme lead to 404s after the link got taken by new owners.

Browser screenshot of the link. The screenshot was taken at the writing of this post.
chrome_nUiPhdFEju

How to enable this for jsx files?

I've been trying to get this to work for jsx files, but it doesn't (no errors or anything).

My settings are as following (both in user and workspace settings):

    "jscs.enable":true,
    "jscs.preset": "airbnb",
    "jscs.disableIfNoConfig": false,
    "jscs.configuration": {
        "validateLineBreaks": "CRLF",
        "requireCamelCaseOrUpperCaseIdentifiers": true,
        "fileExtensions": [".js", ".jsx"]
    }

Otherwise, my jscsrc is as following:

{
    "preset": "airbnb",
    "validateLineBreaks": "CRLF",
    "requireCamelCaseOrUpperCaseIdentifiers": true,
    "fileExtensions": [".js", ".jsx"]
}

But it doesn't seem to be following this at all (or somehow not) although I expect that to be the default, since it would be useful not to be bound to an editor for a team to have the same style settings.

unable to build and debug

I grabbed the code yesterday (3/14) and following the instructions, could not get the project to build or run.

One issue was VSCode complaining it wanted an absolute path for outDir in launch.json. I eventually discovered TypeScript was not installed for the client and it was hanging on that compilation.

I noticed this project mimics the "language server" sample and that was a big help to determining what was wrong.

PR incoming. I think I have it but am going to test pulling fresh and seeing if I've got it.

Extension Deprecation and Unpublishing from marketplace

The JSCS Linter was deprecated and merged with ESLint in 2016. Projects should migrate ESLint and use the VS Code ESLint extension.

Given that JSCS has been deprecated for a number of years now and due to the very low usage numbers on this extension, we have decided to deprecate the extension. We will also be unpublishing it from the marketplace and archiving this repository.

If you need JSCS support in VS Code for a legacy project, you can build this extension using vsce to create a vsix

Bump version so config fix updates

It looks like there was a fix that was merged in about a month ago that fixes the VSCode settings.json warning for "jscs.configuration". However it looks like this fix was never pushed to Microsoft's extension library to update the warning on the users end. I suspect this is because the version wasn't bumped so VSCode doesn't know there's a new version.

Does the version need to be bumped in the package.json file so VSCode knows there is a new version?

Alternative location of .jscsrc file

It would be nice if we could define a custom location of the .jscsrc file. If the file is not in the root of a project the linter will not pick it up.

the jshint linter has this fixed like this:

 "jshint.options" : { "config" : "path/to/.jshintrc" }

Would it be possible to do the same for this linter?

"excludeFiles" setting is not respected

The addon does not respect the "excludeFiles" property in .jscsrc (also not when put in jscs.configuration object in settings.json):

"excludeFiles": ["data/**"]

If a file in the data/ folder is passed to the jscs command line tool, no errors appear.

If the file is opened in Visual Studio Code, jscs errors are shown. Similarly if individual files are excluded in "excludeFiles".

Support for global JSCS

This plugin requires that JSCS be installed locally but npm prefers that the plugin be installed globally instead. Any plans to update this to support global JSCS?

Thanks!

How its work?

I have installed jscs
image
And jscs for vscode.

My .jscsrc in project root

{
  "preset": "google",
  "esnext": true,
  "fileExtensions": [
    ".js",
    ".jsx"
  ],
  "requireSemicolons": true,
  "requireParenthesesAroundIIFE": true,
  "maximumLineLength": 120,
  "validateLineBreaks": "LF",
  "validateIndentation": 2,
  "disallowTrailingComma": true,
  "disallowUnusedParams": true,
  "disallowSpacesInsideObjectBrackets": null,
  "disallowImplicitTypeConversion": [
    "string"
  ],
  "safeContextKeyword": "_this",
  "jsDoc": {
    "checkAnnotations": "closurecompiler",
    "checkParamNames": true,
    "requireParamTypes": true,
    "checkRedundantParams": true,
    "checkReturnTypes": true,
    "checkRedundantReturns": true,
    "requireReturnTypes": true,
    "checkTypes": "capitalizedNativeCase",
    "checkRedundantAccess": true,
    "requireNewlineAfterDescription": true
  },
  "excludeFiles": [
    ".meteor/*"
  ]
}

But vscode did not lint jsx and js files

Invalid links

The domain jscs.info seems to have been taken over by a domain name agency. Therefore, the links from the README file are no longer valid.

Extension host crashes

I have no idea what causes this. Does not happen on all projects.

Here's the devtools console log:

/Users/rolle/.vscode/extensions/ms-vscode.jscs-0.1.9/node_modules/vscode-jsonrpc/lib/messageReader.js:155                    throw new Error('Header must provide a Content-Length property.'); 

Error: Header must provide a Content-Length property.
at StreamMessageReader.onData (/Users/rolle/.vscode/extensions/ms-vscode.jscs-0.1.9/node_modules/vscode-jsonrpc/lib/messageReader.js:155:27)
at Socket.<anonymous> (/Users/rolle/.vscode/extensions/ms-vscode.jscs-0.1.9/node_modules/vscode-jsonrpc/lib/messageReader.js:140:19)
at Socket.emit (events.js:223:5)
at Socket.EventEmitter.emit (domain.js:475:20)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:290:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:181:23)

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.