Added config with ES2015-only rules
This commit adds an additional config, which should be used in ES2015-based projects. It's available by adding `extends: openstack/es2015` to project's .eslintrc file. Change-Id: I5d54cdceb206db7a52ee396eafc513b290e38f86
This commit is contained in:
parent
b2b34d88df
commit
ec845e5e7f
28
.eslintrc-es2015
Normal file
28
.eslintrc-es2015
Normal file
@ -0,0 +1,28 @@
|
||||
# This file contains rules which should only be enabled in
|
||||
# ES2015-based projects.
|
||||
extends: openstack
|
||||
|
||||
parserOptions:
|
||||
ecmaVersion: 6
|
||||
sourceType: module
|
||||
|
||||
rules:
|
||||
# disallow unnecessary .call() and .apply()
|
||||
# http://eslint.org/docs/rules/no-useless-call
|
||||
no-useless-call: 2
|
||||
|
||||
# require let or const instead of var
|
||||
# http://eslint.org/docs/rules/no-var
|
||||
no-var: 2
|
||||
|
||||
# suggest using arrow functions as callbacks
|
||||
# http://eslint.org/docs/rules/prefer-arrow-callback
|
||||
prefer-arrow-callback: 2
|
||||
|
||||
# suggest using the spread operator instead of .apply().
|
||||
# http://eslint.org/docs/rules/prefer-spread
|
||||
prefer-spread: 2
|
||||
|
||||
# suggest using the rest parameters instead of arguments
|
||||
# http://eslint.org/docs/rules/prefer-rest-params
|
||||
prefer-rest-params: 2
|
@ -12,7 +12,8 @@ project to stay as close to the common guidelines as possible.
|
||||
To add these rules to your project, follow these steps.
|
||||
|
||||
1. `npm install --save-dev eslint eslint-config-openstack`
|
||||
2. Add `extends: "openstack"` to your `.eslintrc` yaml file
|
||||
2. Add `extends: "openstack"` to your `.eslintrc` yaml file. If your project is using ES2015, add
|
||||
`extends: "openstack/es2015"` instead.
|
||||
|
||||
## Approval Policies
|
||||
|
||||
@ -29,11 +30,11 @@ Patches that upgrade eslint only require two core approvers to land. These patch
|
||||
upstream rules in a deactivated state, and delete any deprecated rules.
|
||||
|
||||
#### Policy upgrades require all cores
|
||||
Updates to policies and governance on this project require +2 votes from all direct cores on the
|
||||
Updates to policies and governance on this project require +2 votes from all direct cores on the
|
||||
project. Core votes from the parent OpenStack QA project are optional.
|
||||
|
||||
#### Patches should be abandoned after a month of inactivity
|
||||
Cores should attempt to keep the list of extant patches small and managable. As such, they should
|
||||
talk to any author whose patch has failed to garner the necessary support, and has experienced
|
||||
one month of inactivity. Reasonable notice should be given to the author before a patch is
|
||||
talk to any author whose patch has failed to garner the necessary support, and has experienced
|
||||
one month of inactivity. Reasonable notice should be given to the author before a patch is
|
||||
abandoned.
|
||||
|
22
es2015.js
Normal file
22
es2015.js
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2016 Mirantis, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License. You may obtain
|
||||
* a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
|
||||
/**
|
||||
* The default module for this package simply reads in the .eslintrc-es2015 yaml file, and returns
|
||||
* it as a module.
|
||||
*/
|
||||
|
||||
module.exports = require('./load-config')('.eslintrc-es2015');
|
15
index.js
15
index.js
@ -14,22 +14,9 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/*eslint-disable strict*/
|
||||
'use strict';
|
||||
/*eslint-enable strict*/
|
||||
|
||||
/**
|
||||
* The default module for this package simply reads in the .eslintrc yaml file, and returns it
|
||||
* as a module.
|
||||
*/
|
||||
|
||||
var yaml = require('js-yaml');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
/*eslint-disable no-sync */
|
||||
var rcPath = path.join(__dirname, '.eslintrc');
|
||||
var fileContent = fs.readFileSync(rcPath);
|
||||
/*eslint-enable no-sync */
|
||||
|
||||
module.exports = yaml.safeLoad(fileContent);
|
||||
module.exports = require('./load-config')('.eslintrc');
|
||||
|
31
load-config.js
Normal file
31
load-config.js
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the 'License'); you may
|
||||
* not use this file except in compliance with the License. You may obtain
|
||||
* a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a helper module used to load and export YAML-based ESLint config
|
||||
*/
|
||||
|
||||
var yaml = require('js-yaml');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
module.exports = function(filename) {
|
||||
'use strict';
|
||||
|
||||
var rcPath = path.join(__dirname, filename);
|
||||
var fileContent = fs.readFileSync(rcPath); // eslint-disable-line no-sync
|
||||
return yaml.safeLoad(fileContent);
|
||||
};
|
@ -5,7 +5,10 @@
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"es2015.js",
|
||||
"load-config.js",
|
||||
".eslintrc",
|
||||
".eslintrc-es2015",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user