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

Commit bd23862

Browse files
author
Daniel Brook-Roberge
authored
Merge pull request #116 from mobify/modern-eslint-es5-compatibility
Modern eslint ES5 compatibility
2 parents f39f0f9 + 60b3fa8 commit bd23862

File tree

5 files changed

+680
-7
lines changed

5 files changed

+680
-7
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2.5.2
2+
- Add a new ES5 configuration ported to ESLint 2 and up
13
2.5.1
24
- Update line length to 200
35
- Remove 'strict' rule for modules

README.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,29 @@ A repo to document code standards for different languages and provide tools for
44

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

7-
## JavaScript (ES5)
7+
## JavaScript (ES5) with Grunt
88

9-
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.
9+
Typically, we lint our javascript files using
10+
[Grunt](http://gruntjs.com/) and
11+
[grunt-eslint](https://github.com/sindresorhus/grunt-eslint). grunt-eslint
12+
is a Grunt helper for the [ESLint](http://eslint.org/) linter.
1013

1114
To add javascript linting to your project:
1215

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

17-
Sample eslint config:
22+
The `.eslintrc.yml` file should contain, to begin with:
23+
```yaml
24+
extends:
25+
- './node_modules/mobify-code-style/es5/mobify-es5.yml'
26+
```
27+
28+
29+
Sample eslint Grunt config:
1830
1931
```javascript
2032
eslint:{
@@ -24,20 +36,36 @@ eslint:{
2436
// When true, eslint will test _only_ the rules set in the provided
2537
// configuration file
2638
reset: false,
27-
config: 'node_modules/mobify-code-style/javascript/.eslintrc'
39+
configFile: './.eslintrc.yml'
2840
}
2941
}
3042
}
3143
```
3244

45+
### Migrating from ESLint 0.x or 1.x to ESlint 2.x or 3.x
46+
47+
If you upgrade the version of `grunt-eslint` you use from one that
48+
pulls in ESLint 1.x or lower to one that pulls
49+
in ESLint 2.x or greater, you must modify the configuration files to
50+
include the new style of configuration.
51+
52+
If the Grunt config includes the default config
53+
`./node_modules/mobify-code-style/javascript/.eslintrc`, replace that
54+
with `./.eslintrc.yml`, and add an `.eslintrc.yml` to the project root
55+
as described above.
56+
57+
If there are modifications to the lint configuration in the project,
58+
please check the migration guides at [http://eslint.org/] to port the
59+
modified lint config to ESLint 3.x.
60+
3361
## ES6/JSX
3462

3563
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
3664

3765
```yaml
3866
extends:
3967
- './node_modules/mobify-code-style/es6/mobify-es6.yml'
40-
```
68+
```
4169
4270
and for a React/JSX project:
4371

0 commit comments

Comments
 (0)