eslint-config-ess
v1.0.7
Published
eslint config
Downloads
10
Readme
###Source
Github: https://github.com/estrat/eslint-config-ess
NPM: https://www.npmjs.com/package/eslint-config-ess
###Install npm install --save eslint-config-ess
###Grunt Configuration
- Install grunt-eslint:
npm install --save-dev grunt-eslint
- Create a new file in the grunt tasks folder, e.g.
grunts/eslint.js
.
mkdir -p grunts;
touch grunts/eslint.js
- In this file, paste this code to register a grunt task:
``` 'use strict';
module.exports = function(grunt) {
grunt.config('eslint', {
options: {
rulePaths: ['node_modules/eslint-config-ess/rules']
},
backend: {
options: {
config: 'eslint-config-ess/configs/backend.js'
},
src: [
//file patterns here
]
},
frontend: {
options: {
config: 'eslint-config-ess/configs/frontend.js'
},
src: [
//file patterns here
]
}
});
grunt.loadNpmTasks('grunt-eslint');
};
```
- Fill out the
backend.src
andfrontend.src
arrays. - Update
gruntfile.js
to include this configuration: ``` 'use strict';
var Pkg = require('./package.json');
module.exports = function(grunt) {
grunt.initConfig({
pkg: Pkg
});
grunt.loadTasks('grunts');
grunt.registerTask('check', [
'eslint'
]);
grunt.registerTask('lint', [
'eslint'
]);
grunt.registerTask('build', [
'check'
//additional tasks here
]);
grunt.registerTask('default', [
'check'
]);
};
```
- Test with
grunt
andgrunt check
.
###Sublime Text Configuration NOTE: This is a secondary helper; it will not catch as many errors as the grunt task above will.
- Install Package Control if not already.
- Open Package Control (⌘⇧P or
CTRL
+SHIFT
+P
). - Select
Package Control: Install Package
. - Install
ESLint
. - Repeat steps 2-3 and install
SublimeLinter-contrib-eslint
. - Create
.eslintrc.js
in the top-level directory of the repo (next topackage.json
):touch .eslintrc.js
- Insert this code into
.eslintrc.js
(this will check only backend errors): ``` 'use strict';
function clone(obj) {
return JSON.parse(JSON.stringify(obj));
}
var config = clone(require('eslint-config-ess').configs.backend);
if (config.rules['lowercase-require']) delete config.rules['lowercase-require'];
module.exports = config;
```