Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Modern eslint ES5 compatibility #116

Merged
merged 7 commits into from
Aug 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2.5.2
- Add a new ES5 configuration ported to ESLint 2 and up
2.5.1
- Update line length to 200
- Remove 'strict' rule for modules
Expand Down
42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@ A repo to document code standards for different languages and provide tools for

[![NPM version](https://badge.fury.io/js/mobify-code-style.svg)](http://badge.fury.io/js/mobify-code-style)

## JavaScript (ES5)
## JavaScript (ES5) with Grunt

Typically, we lint our javascript files using [Grunt](http://gruntjs.com/) and [grunt-eslint](https://github.com/sindresorhus/grunt-eslint). grunt-eslint is a Grunt helper for the [ESLint](http://eslint.org/) linter.
Typically, we lint our javascript files using
[Grunt](http://gruntjs.com/) and
[grunt-eslint](https://github.com/sindresorhus/grunt-eslint). grunt-eslint
is a Grunt helper for the [ESLint](http://eslint.org/) linter.

To add javascript linting to your project:

1. Install the NPM `mobify-code-style` and `grunt-eslint` modules.
2. Create a [Gruntfile](http://gruntjs.com/sample-gruntfile) if you don't have one already.
3. In the initConfig of your gruntfile, add a section for eslint pointing to the correct linting file.
2. Create a [Gruntfile](http://gruntjs.com/sample-gruntfile) if you
don't have one already.
3. Create an `.eslintrc.yml` file in the root of your project directory
4. In the initConfig of your gruntfile, add a section for eslint pointing to the correct linting file.

Sample eslint config:
The `.eslintrc.yml` file should contain, to begin with:
```yaml
extends:
- './node_modules/mobify-code-style/es5/mobify-es5.yml'
```


Sample eslint Grunt config:

```javascript
eslint:{
Expand All @@ -24,20 +36,36 @@ eslint:{
// When true, eslint will test _only_ the rules set in the provided
// configuration file
reset: false,
config: 'node_modules/mobify-code-style/javascript/.eslintrc'
configFile: './.eslintrc.yml'
}
}
}
```

### Migrating from ESLint 0.x or 1.x to ESlint 2.x or 3.x

If you upgrade the version of `grunt-eslint` you use from one that
pulls in ESLint 1.x or lower to one that pulls
in ESLint 2.x or greater, you must modify the configuration files to
include the new style of configuration.

If the Grunt config includes the default config
`./node_modules/mobify-code-style/javascript/.eslintrc`, replace that
with `./.eslintrc.yml`, and add an `.eslintrc.yml` to the project root
as described above.

If there are modifications to the lint configuration in the project,
please check the migration guides at [http://eslint.org/] to port the
modified lint config to ESLint 3.x.

## ES6/JSX

We use [ESLint](http://eslint.org/) to lint ES6 and React/JSX code. If ESLint is installed in a project, we can use the configuration from this module by creating a file in the project root named `.eslintrc.yml`. If the project does not use JSX, the file contents should be

```yaml
extends:
- './node_modules/mobify-code-style/es6/mobify-es6.yml'
```
```

and for a React/JSX project:

Expand Down
Loading