Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

finn-js-code-style

Package Overview
Dependencies
Maintainers
3
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

finn-js-code-style

Config files for FINN JavaScript style

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-62.5%
Maintainers
3
Weekly downloads
 
Created
Source

FINN.no JavaScript code style

This project is meant for internal JS-code at FINN.no, but we have many public JS projects which also want to use the same code style. Feel free to use/fork, but it probably will become very FINN specific, so we don't expect it to be very useful for others.

Just a start...

The JSHint config is just a beginning and up for discussion. The most important is that we land on a config that everyone uses. So it's better with a relaxed config that everyone use than a strict config that nobody wants to use. But the main concept of linting code is to avoid potential typos, so it's a fine balance...

Add a pull-request if you want to change something and we can discuss on the pull-request. One pull-request pr option change. Please include the description of the option in the PR description :)

Install

npm install --save-dev finn-js-code-style

Use

This command will run jshint on the files you specify. In the future, it will probably do more code style checks on the same set of files.

finn-js-code-style [options] <file | dir>...

Options

  • --help Usage info
  • --max-warnings <number> Exit when more warnings than max-warnings
  • --max-errors <number> Exit when more errors than max-errors
  • --fail Exit when warnings/errors are generated

Changelog

See CHANGELOG.md for what has changed since last release

Config

The config should be in the dot-files instead of hard-coded in build scripts. That makes it possible for editor plugins to auto-detect the config.

If you already have a .jshintrc file; add the line below and remove all old rules. If you don't have it, finn-js-code-style will generate it the first time you run the command.

"extends": "./node_modules/finn-js-code-style/.jshintrc"

The extends option became usable in jshint v2.5.1, so make sure the version you use (also editor plugins) at least have this version.

It is possible to extend js-code-style with a project-specific config, but we only allow a more strict set of rules or change the environment (node/browser). The project globals should also be defined here (if you have any), and will extend the parent´s globals (instead of overwriting).

You can also use extends to have different config for tests or similar:

./.jshintrc

{
    "extends": "./node_modules/finn-js-code-style/.jshintrc",
    "browser": true,
    "node": false,
    "maxstatements": 10
}

./test/.jshintrc

{
    "extends": "../.jshintrc",
    "globals": {
        "suite": true,
        "test": true,
        "setup": true,
        "teardown": true,
        "assert": true
    }
}

Use the .jshintignore to exclude files or folders.

Grunt config

npm install --save-dev grunt-exec

In Gruntfile.js

grunt.loadNpmTasks('grunt-exec');

grunt.initConfig({
    //...,
    exec: {
        finn_js_code_style: {
            cmd: 'finn-js-code-style src'
        }
    },
    //...
});

For Sublime

- Install plugin...

For Intellij

- Open prefrences in Intellij.
- Under Project Settings find: JavaScript -> Code Quality Tools -> JSHint.
- Check off for "Enable", "Use config files" and "2.8.0".

Wondering what all these options mean?

See JSHint docs

More jshint docs

Release a new version

# patch version
$ npm run release:patch

# minor version
$ npm run release:minor

# major version
$ npm run release:major

# special versions (alpha/beta/etc) 1.2.3-beta.1
$ npm version <newversion>
$ NPM_CONFIG_TAG=<tag> npm run push-package-publish

FAQs

Package last updated on 04 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc