Skip to content

ravdocs/eslint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eslint Configuration

A set of coding standard settings for use with https://eslint.org/. Eslint is source code checking framework used to enforce coding standards.

Usage

To use this npm module:

  1. Install
  2. Configure Grunt
  3. (Optional) Configure Visual Studio Code

Install

npm install --save @ravdocs/eslint;

Configure Grunt

  1. Install grunt-eslint.

    npm install --save-dev grunt-eslint;
  2. Create a new file in the grunt tasks folder (e.g. grunts/eslint.js) with this content:

    'use strict';
    
    
    module.exports = function(grunt) {
    
    	grunt.config('eslint', {
    		options: {
    			rulePaths: ['node_modules/@ravdocs/eslint/rules']
    		},
    
    		backend: {
    			options: {
    				configFile: 'node_modules/@ravdocs/eslint/configs/backend.js'
    			},
    			src: [
    				'*.js',
    				'grunts/**/*.js',
    				// <file-patterns-here>
    			]
    		},
    
    		frontend: {
    			options: {
    				configFile: 'node_modules/@ravdocs/eslint/configs/frontend.js'
    			},
    			src: [
    				// <file-patterns-here>
    			]
    		}
    	});
    
    	grunt.loadNpmTasks('grunt-eslint');
    };
  3. Fill out <file-patterns-here> in the backend.src and frontend.src arrays. (additional info here)

  4. 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'
    	]);
    };
  5. Test with grunt and grunt lint.

Configure Visual Studio Code

NOTE: This is optional.

  1. Open Settings.

    • OS X: ,
    • Linux: CTRL,
  2. Add to USER SETTINGS:

    "eslint.autoFixOnSave": true,
    "eslint.options": {
        "rulePaths": [
            "node_modules/@ravdocs/eslint/rules"
        ]
    },
  3. Create .eslintrc.js in the top-level directory of the repo (next to package.json) with this content:

    	'use strict';
    
    
    	module.exports = require('@ravdocs/eslint').configs.backend;
  4. Create another .eslintrc.js in the directory containing frontend files (e.g., public/.eslintrc.js) with this content:

    	'use strict';
    
    
    	module.exports = require('@ravdocs/eslint').configs.frontend;

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published