Coder Social home page Coder Social logo

brackets-jscs's Introduction

brackets-jscs

A Brackets extension that enables JSCS validation for Javascript files. For more information about JSCS see https://github.com/jscs-dev/node-jscs.

JSCS can be configured by a .jscsrc or .jscs.json file located somewhere in your project.

THIS EXTENSION IS BEING DEPRECATED

This extension is going to be deprecated soon. JSCS is being merged into ESLint. As such, there is going to be no more need it. Use the wonderful brackets-eslint extension instead.

I will still happily accept Pull Requests if you wish to fix issues, but I will no longer be actively working on it.

Requirements

Installation

  • Install the extension from the Brackets Extension registry
  • Go to Help > Show Extensions Folder
  • In the extensions folder navigate to /user/globexdesigns.brackets-jscs
  • Open a terminal to this folder and run npm install
  • Restart Brackets

Configuration

If you have disabled the default Brackets JSLint service, you will need to manually enable JSCS in your prefs file:

  • Go to Debug > Open Preferences File
  • Make sure your language.javascript.linting.prefer definition includes "JSCS" as such:
"language": {
	"javascript": {
		"linting.prefer": [
			"JSHint",
			"JSCS"
		]
	}
},

Using with JSX

JSCS (and brackets-jscs) can be used to validate JSX files. To enable this, add this line to your .jscsrc file:

"esprima": "babel-jscs"

Note about Additional Rules

The extension supports the additionalRules for JSCS however, changes/additions/removals of additional rules will require your to close and restart Brackets before the extension will respect the changes.

Building This Extension

npm install
grunt build

A new ZIP package will be created in /build/.

Credit

Based heavily on brackets-jshint and brackets-eslint.

brackets-jscs's People

Contributors

hirse avatar xlitter 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

Watchers

 avatar  avatar  avatar  avatar

brackets-jscs's Issues

Gives no hints at all

I tried to create a simple .jscs.json file and added it to my projects root-dir:

{
    "preset": "jquery",
    "excludeFiles": ["node_modules/**"]
}

The jscs command line tool gives me errors. But Brackets gives me no hints at all.
Other Brackets hinting extensions works fine like jsonhint and jshint.
I am using Brackets 1.1.

Any idea of why it is not working?

Extension doesn't get loaded

Installed the Extension through Extension manager, but it always fails with an error. This is what I've found in the console: Uncaught ReferenceError: module is not defined

Cannot find module 'jscs'

Ubuntu 15.04 x64
Brackets Release 1.3
JSCS 0.6.3

The removal of local jscs seems to have broke on ubuntu. (only tested on works machine)
I have globally(npm -g) installed the package but it refuses to find it...

I had to locally install(npm) jscs in extensions/user/globaldesigns.brackets-jscs to get it to work.

Error Message

Unexpected JSCS processing error: Unable to load one of the modules: /home/james/.config/Brackets/extensions/user/globexdesigns.brackets-jscs/domain, reason: Cannot find module 'jscs' ```

Trailing space in comment breaks brackets-jscs

If there is a trailing space in a comment an "Unexpected token"-error is created in brackets-jscs.
This is not a problem when running JSCS in commandline.

// This line has a trailing space 
function a() {
    return;
}

jscs-brackets-trailing-space-error

Unsupported rules: additionalRules

When my repo is open (https://github.com/zaggino/brackets-git) I get a lot of these errors:

JSCS failed to initialize: Error: Unsupported rules: additionalRules, forbiddenFunctions main.js:58
JSCS failed to initialize: Error: Unsupported rules: additionalRules, forbiddenFunctions main.js:58
JSCS failed to initialize: Error: Unsupported rules: additionalRules, forbiddenFunctions main.js:58
JSCS failed to initialize: Error: Unsupported rules: additionalRules, forbiddenFunctions main.js:58

Plugin breaks when JSCS is used with plugin

I have a Brackets with JSCS plugin working fine for a while, but recently I wanted to add a plugin to my .jscsrc configuration (https://github.com/jscs-dev/jscs-jsdoc) but as soon as I did this I started getting errors in Brackets:

Unexpected JSCS processing error: Cannot find module 'jscs-jsdoc'

The configuration section I've added to .jscsrc is

    "plugins": [
        "jscs-jsdoc"
    ],
    "jsDoc": {
        "checkAnnotations": "jsdoc3",
        "checkParamNames": true,
        "requireParamTypes": true,
        "checkRedundantParams": true,
        "checkReturnTypes": true,
        "checkRedundantReturns": true,
        "requireReturnTypes": true,
        "checkTypes": "strictNativeCase",
        "checkRedundantAccess": true,
        "enforceExistence": "exceptExports",
        "requireNewlineAfterDescription": true,
        "requireDescriptionCompleteSentence": true,
        "requireParamDescription": true
    }

The jscs-jsdoc module is installed correctly as it works perfectly well when I run JSCS from command line.

Unexpectedly stop the node server

When I having this extension installed, I got several errors in developer console. Please check the following screen shot.

635682783052642734

This would cause any extension to be working. Please check the other issue. Probably it is because of I'm running in offline mode (not connected to internet)?

I'm using Brackets 1.3 on Windows 7.

Large Project - Litner Config Not Found

Hi,

In a few of our large projects (30,000+ files), the litner config is not found and brackets reverts to the default linter settings.

How can I fix this?

Thanks!!

JSCS timing out

After upgrading to 0.7.0, JSCS for Brackets is reporting JSCS has timed out after waiting for 10000 ms every time it runs.

I'm using Brackets 1.3 on Windows 7.

update to use JSCS 3

A few of the projects I work on have now started using JSCS 3, causing this extension to show "unsupported rule" messages for some of the new rules.

The dependency is already listed as latest, but it looks like the extension has not been updated in a while.

Configuration file path

I see this problem in many extensions... I think it would be more sensitive to include the possibility of defining the path for your own configuration file, instead of trying to guess it. At least specify where should we place it, please, because this "somewhere" you mention doesn't work for any place (the extension says "Unable to find a JSCS configuration file." โ€“ I just have a folder where all the code style definitions are stored, including a .jscsrc file).

In general, I think it should be a more direct mapping between the original command-line tool and the editor's extension. Otherwise, the advantages the extension gives are lost because of the lack of flexibility, as I see it.

Thanks.

Using multiple brackets windows broke the extension

Hi, first thanks for this extension.

I got a problem when I'm running more than one window of Brackets. The extension display an error message:

Unexpected JSCS processing error: Max connection attempts reached

Is there a solution to be able to use JSCS parser with multiple window ?

Tell me if you need more information to find out what is going on.

How to upgrade to JSCS 2.0.0 ?

Hello,

Our team is updating our .jscsrc config files to use JSCS 2.0.0. They are using vi as code editor.
I am using brackets and your plugin but I can't manage to upgrade the JSCS version.

I tried upgrading the jscs node module in the plugin directory and globally, unsuccessfully.

I still have an Unsupported rule error. Do you know how can I do?

Thanks.

Files in Subsubfolders are ignored

When I put the .jscs.json into the Project Root, files in the js folder will get linted as expected:
jscs_1
But files in the js_inner folder are ignored:
jscs_2
To get linting for that file, I have to copy .jscs.json into js (or js_inner):
jscs_3
However when I delete the .jscs.json from the project root, only files in the direct subfolders are affected:
jscs_4
jscs_5


In summary, I would like to have linting for all files in the project, so I don't have to copy the settings.

.jscsrc does not appear to have any effect

Using this .jscsrc file on Ubuntu works great. It seems to be ignored on Mac OS 10.10.2. .jscs.json also appears to be ignored on that operating system. Using brackets release 1.2 build 1.2.0-15697 (release 8f82e2a97) build timestamp: Sun Feb 22 2015 22:34:50 GMT-0800

.jscs is in the project root, at the same level as .jshintrc

{
    "requireCurlyBraces": [
        "if",
        "else",
        "for",
        "while",
        "do",
        "try",
        "catch"
    ],
    "requireOperatorBeforeLineBreak": true,
    "requireCamelCaseOrUpperCaseIdentifiers": true,
    "maximumLineLength": {
      "value": 80,
      "allowComments": true,
      "allowRegex": true
    },
    "validateIndentation": "\t",
    "validateQuoteMarks": "'",

    "disallowMultipleLineStrings": true,
    "disallowMixedSpacesAndTabs": true,
    "disallowTrailingWhitespace": true,
    "disallowSpaceAfterPrefixUnaryOperators": true,
    "disallowMultipleVarDecl": false,
    "disallowKeywordsOnNewLine": ["else"],

    "requireSpaceAfterKeywords": [
      "if",
      "else",
      "for",
      "while",
      "do",
      "switch",
      "return",
      "try",
      "catch"
    ],
    "requireSpaceBeforeBinaryOperators": [
        "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=",
        "&=", "|=", "^=", "+=",

        "+", "-", "*", "/", "%", "<<", ">>", ">>>", "&",
        "|", "^", "&&", "||", "===", "==", ">=",
        "<=", "<", ">", "!=", "!=="
    ],
    "requireSpaceAfterBinaryOperators": true,
    "requireSpacesInConditionalExpression": true,
    "requireSpaceBeforeBlockStatements": true,
    "requireSpacesInForStatement": true,
    "requireLineFeedAtFileEnd": true,
    "requireSpacesInFunctionExpression": {
        "beforeOpeningCurlyBrace": true
    },
    "disallowSpacesInAnonymousFunctionExpression": {
        "beforeOpeningRoundBrace": true
    },
    "disallowSpacesInsideObjectBrackets": "all",
    "disallowSpacesInsideArrayBrackets": "all",
    "disallowSpacesInsideParentheses": true,

    "disallowMultipleLineBreaks": true,
    "disallowNewlineBeforeBlockStatements": true
}

Here is the brackets.json

{
    "themes.theme": "dark-theme",
    "me.drewh.jsbeautify.on_save": false,
    "linting.collapsed": false,
    "language": {
        "javascript": {
            "linting.prefer": [
                "JSHint",
                "JSCS"
            ],
            "linting.usePreferredOnly": true
        }
    },
    "useTabChar": true
}

Support for .jscsrc file name

It would be nice if the extension supported the file format .jscsrc. It seems a lot of extensions like CSS Lint (.csslintrc) and JSHint (.jshintrc) all tend to go for that kind of file name format.

Obviously this would be easy to change and I could raise a pull request, but perhaps its better to get thoughts on this first? Should it support BOTH .jscsrc and .jscs.json? Most of the other extensions only support the one format .*rc.

Not clear install instruction

After I do Debug > Open Preferences File it open me 2 file:
defaultPreferences.json and brackets.json
no one of them have structure like:
"language": {...}
defaultPreferences.json
have few raws:

// Additional mappings from file extension to language name
"language.fileExtensions": {},
// Additional mappings from file name to language name
"language.fileNames": {},

Could you show (print screen it) where is should be?

Ignored rule: One space required after opening bracket.

JSCS for Bracket ignore rule requireSpacesInsideBrackets which command line tool return correctly as an error. We use "preset": "jquery".
This should be evaluated as an error:

ab[c][d]

and should be auto-fixed to:

ab[ c ][ d ]

My JSCS file

{
    "preset": "jquery",
    "requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
    "requireCapitalizedComments": { "allExcept": [ "global", "jshint", "jscs" ] }
}

This extension save me a lot of time with code style fixing. Thank you.

Support .jscsrc file outwith project tree

I would like to share the same .jscrc configuration between multiple projects. However, searching for a .jscrc stops at the project root.

Could support for a global default config file or scanning beyond the project root be supported? For example, the Brackets JSHint extension supports scanning the complete parent tree to find a configuration file.

Rule disallowTrailingWhitespace broken

The JSCS rule:

{"disallowTrailingWhitespace": true}

does not work.

It is cause by the following code most probably:

// Trim trailing whitespace
JSXCode = JSXCode.replace(/( +)\n/g, '\n');

Syntax error cause Brackets CodeInspector to fail

If the Javascript file has a syntax error, JSCS will fail silently and prevent any further execution of CodeInspector code - resulting in errors to slip by.

Make sure to catch syntax errors and report them back to the console.

Brackets console outputs:

[CodeInspection] Provider JSCS threw an error: Error: Syntax error at input: Line 302: Unexpected token ; 

Doesn't do anything

I've installed the extension, placed the example .jscs.json file in my project root, and then saved a random javascript file. It does absolutely nothing. And I know for a fact the javascript isn't indented and curly-braced the same way across the file. So it should do at least something. In fact, there's a piece of minified code at the top of my javascript - I expected that to be un-minified to a certain extent.

Nothing. Just nothing.
Am I missing something?...

Using Brackets 36 on Windows 7.

BUG : "disallowSpacesInsideParentheses" works like "requireSpacesInsideParentheses"

The error "missing space before closing round bracket" appears when I write in my conf file either "disallowSpacesInsideParentheses": true OR "requireSpacesInsideParentheses": "all"

But in the JSCS Rules, disallowSpacesInsideParentheses is the contrary of requireSpacesInsideParentheses !

Here my jscs.json :
{
"preset": "jquery",
"maximumLineLength": null,
"requireMultipleVarDecl": null,
"requireSpacesInsideArrayBrackets": null,
"disallowSpacesInsideArrayBrackets": "all",
"validateQuoteMarks": { "mark": "'", "escape": true },
"disallowSpacesInsideParentheses": true,
"disallowMixedSpacesAndTabs": true,
"requireMultipleVarDecl": true,
"requireBlocksOnNewline": 1
}

JSCS issue "Unexpected JSCS processing error: timeout"

I had been using this plugin for about 6 months without issue. After upgrading to Brackets v1.5, build 1.5.0-16538, I noticed that the JSCS information in the output stated the following:

JSCS has not been installed in the extension. See Installation steps here: https://github.com/globexdesigns/brackets-jscs

So then I went through the installation and configuration information in the readme.md file, noticing that there were extra steps to perform that weren't there previously. So I reinstalled the plugin via Extension Manager registry to ensure I had the latest version. Ran the npm install command as specified in the readme document and checked that my preferences file matches that in the readme.md 'Configuration' Section. Then finally, restarted Brackets.

Now I get the following error and don't know how to proceed with resolving this.

Unexpected JSCS processing error: timeout

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.