npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

finn-js-code-style

v5.0.0

Published

Config files for FINN JavaScript style

Downloads

51

Readme

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