Wondering what’s next for npm?Check out our public roadmap! »

norme

1.0.1 • Public • Published

norme

Opinionated JavaScript linter

NPM version Linux and OS X build status Windows build status Code coverage Code style

Norme is an ESLint based JavaScript linter with lowly-configurable opinionated rules. It does not pretend to be the one style to rule them all. We all have different ideals when it comes to writing code, that linter enforces one of them:

  • 2 spaces indentations
  • no semicolon
  • dangling comma
  • support for ES.next, Node.js, React, Electron
  • ensure the requires and imports can be resolved
  • and more...

Install

$ npm install --save-dev norme

Usage

Project-wide

Using the above command will install Norme locally to your project, this is the recommended way to use it. The version should be fixed in the devDependencies so that your build don't break if the rules evolve. It can be accessed from the scripts in package.json.

{
  "scripts": {
    "test": "norme"
  },
  "devDependencies": {
    "norme": "1.0.0"
  }
}

System-wide

Installing this package with npm install --global norme will expose a binary allowing you to lint code from the command line. See the CLI documentation for more information.

It exits with code 0 when there are no errors:

$ norme lib

$ echo $?
0

It exits with the number of errors (warnings are not counted) otherwise:

$ norme test/fixtures/ko_parsingerror

/Users/ab/Workspace/OpenSource/node/norme/test/fixtures/ko_parsingerror
  1:12  error  Parsing error: Unexpected token }

✖ 1 problem (1 error, 0 warnings)

$ echo $?
1

Documentation

CLI

Usage: norme [options] [file ...]

Options:
  --eslintrc     Whether the ESLint configuration files should be read
                                                      [boolean] [default: false]
  --ext          A comma separated list of extension to search for in folders
                                                  [string] [default: ".js,.jsx"]
  -f, --format   The ESLint formatter to use
       [string] [choices: "checkstyle", "compact", "html", "jslint-xml", "json",
           "junit", "stylish", "table", "tap", "unix", "visualstudio"] [default:
                                                                      "stylish"]
  -h, --help     Print this help message and exit                      [boolean]
  -v, --version  Print version information and exit                    [boolean]

Examples:
  norme --ext=.js,.jsx,.es6 src    Support custom file extensions while linting
                                   the src folder
  norme --formatter=json src test  Specify the ESLint formatter while linting
                                   the src and test folders
  norme && ava                     Leverage the exit code to only launch ava if
                                   there are no lint errors
  norme --eslintrc                 Load the ESLint configuration files (if any)
                                   to overload the Norme rules

Notes:
  - by default, the following files will be linted: bin, lib, src, test
  - if a directory is passed, it will be recursively crawled
  - the exit code represents the number of linting errors

For more information: see https://github.com/aymericbeaumet/norme

API

Norme(files[, options])

files

Type: String[]

The files or directories to lint. If a directory is passed, it will be crawled and all the files matching the options.extensions will be linted.

options

Type: Object
Default: {}

options.cwd

Type: String
Default: process.cwd()

The root directory from which the files should be resolved from.

options.extensions

Type: String[]
Default: [ '.js', 'jsx' ]

The extensions to search for when directories are provided.

options.useEslintrc

Type: Boolean
Default: false

Whether the ESLint configuration files can override the Norme rules.

Package.json

It is possible to define a configuration in the norme key of package.json. All the options you could pass to the Norme constructor (see API documentation) can be placed here. Note that it has a lower precedence than the CLI, allowing to override options via the command line.

{
  "norme": {
    "extensions": [ ".js", ".jsx", ".es6" ]
  }
}

FAQ

Can I integrate Norme with my IDE?

Sure, just grab an ESLint plugin for your IDE and create the following .eslintrc.js in your project root:

module.exports = require('norme').rc()

How can I show my support?

Add the following badge to your project:

Code style

[![Code style](https://img.shields.io/badge/code--style-norme-brightgreen.svg?style=flat-square)](https://github.com/aymericbeaumet/norme)

Where does that name come from?

Norme is the french word for norm. It has the same pronunciation.

Support

Install

npm i norme

DownloadsWeekly Downloads

5

Version

1.0.1

License

CC0-1.0

Last publish

Collaborators

  • avatar