Skip to content

Latest commit

 

History

History
83 lines (43 loc) · 2.22 KB

Linting.md

File metadata and controls

83 lines (43 loc) · 2.22 KB

Linting Meteor Projects

Linting your files means you check whether you meet the conventions you defined for your code. It's like doing a quality check.

There are several tools you can use to lint JavaScript code:

They have slightly different approaches. They all have in common that they can check whether code adheres to certain quality or styles standards.

If you only wish to pick one, I'd recommend ESLint.

Usage

Prerequisites

Make sure that npm is available on your machine as all of these tools come as node packages.

JSHint is a tool that helps to detect errors and potential problems in JavaScript code.

Installation

Issue the following command inside a terminal:

$ npm install -g jshint

Configuration

In order to use JShint you need a `.jshintrc file in the root directory. It can be used to configure 77 options.

In order to exclude files or directories from linting you can use a .jshintignore file.

Linting

Inside the root directory of your project issue

$ jshint .

JSCS - JavaScript Code Style

JSCS is a code style linter for programmatically enforcing a style guide.

Installation

Issue the following command inside a terminal:

$ npm install -g jscs

Configuration

In order to use JavaScript Code Style (jscs) you need a .jscsrc file in the root directory. It can be used to configure 100 rules.

In order to exclude files or directories from linting you can set the excludeFiles option to an array of files or locations.

Linting

Inside the root directory of your project issue

$ jscs .

Installation

Issue the following command inside a terminal:

$ npm install -g eslint

Configuration

In order to use ESlint you need a `.eslintrc file in the root directory. It can be used to configure 143 rules.

In order to exclude files or directories from linting you can use a .eslintgnore file.

Linting

Inside the root directory of your project issue

$ eslint .