summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitaly Kramskikh <vkramskikh@mirantis.com>2016-07-25 17:52:13 +0300
committerVitaly Kramskikh <vkramskikh@mirantis.com>2016-07-29 12:04:22 +0300
commitec845e5e7fe3a9fb7b106c791cded2a283ebe42d (patch)
treec830e5598ccdcaa945c30b4c205e802d9b3aecc5
parentb2b34d88dfa5cf431338a6e471f79dd2a711c026 (diff)
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
Notes
Notes (review): Code-Review+2: Michael Krotscheck <krotscheck@gmail.com> Code-Review+1: Julia Aranovich <jkirnosova@mirantis.com> Code-Review+2: Beth Elwell <e.r.elwell@gmail.com> Workflow+1: Beth Elwell <e.r.elwell@gmail.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Tue, 02 Aug 2016 09:57:14 +0000 Reviewed-on: https://review.openstack.org/346875 Project: openstack/eslint-config-openstack Branch: refs/heads/master
-rw-r--r--.eslintrc-es201528
-rw-r--r--README.md9
-rw-r--r--es2015.js22
-rw-r--r--index.js15
-rw-r--r--load-config.js31
-rw-r--r--package.json3
6 files changed, 90 insertions, 18 deletions
diff --git a/.eslintrc-es2015 b/.eslintrc-es2015
new file mode 100644
index 0000000..2908e3b
--- /dev/null
+++ b/.eslintrc-es2015
@@ -0,0 +1,28 @@
1# This file contains rules which should only be enabled in
2# ES2015-based projects.
3extends: openstack
4
5parserOptions:
6 ecmaVersion: 6
7 sourceType: module
8
9rules:
10 # disallow unnecessary .call() and .apply()
11 # http://eslint.org/docs/rules/no-useless-call
12 no-useless-call: 2
13
14 # require let or const instead of var
15 # http://eslint.org/docs/rules/no-var
16 no-var: 2
17
18 # suggest using arrow functions as callbacks
19 # http://eslint.org/docs/rules/prefer-arrow-callback
20 prefer-arrow-callback: 2
21
22 # suggest using the spread operator instead of .apply().
23 # http://eslint.org/docs/rules/prefer-spread
24 prefer-spread: 2
25
26 # suggest using the rest parameters instead of arguments
27 # http://eslint.org/docs/rules/prefer-rest-params
28 prefer-rest-params: 2
diff --git a/README.md b/README.md
index 30dce4e..5a77f65 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,8 @@ project to stay as close to the common guidelines as possible.
12To add these rules to your project, follow these steps. 12To add these rules to your project, follow these steps.
13 13
141. `npm install --save-dev eslint eslint-config-openstack` 141. `npm install --save-dev eslint eslint-config-openstack`
152. Add `extends: "openstack"` to your `.eslintrc` yaml file 152. Add `extends: "openstack"` to your `.eslintrc` yaml file. If your project is using ES2015, add
16 `extends: "openstack/es2015"` instead.
16 17
17## Approval Policies 18## Approval Policies
18 19
@@ -29,11 +30,11 @@ Patches that upgrade eslint only require two core approvers to land. These patch
29upstream rules in a deactivated state, and delete any deprecated rules. 30upstream rules in a deactivated state, and delete any deprecated rules.
30 31
31#### Policy upgrades require all cores 32#### Policy upgrades require all cores
32Updates to policies and governance on this project require +2 votes from all direct cores on the 33Updates to policies and governance on this project require +2 votes from all direct cores on the
33project. Core votes from the parent OpenStack QA project are optional. 34project. Core votes from the parent OpenStack QA project are optional.
34 35
35#### Patches should be abandoned after a month of inactivity 36#### Patches should be abandoned after a month of inactivity
36Cores should attempt to keep the list of extant patches small and managable. As such, they should 37Cores should attempt to keep the list of extant patches small and managable. As such, they should
37talk to any author whose patch has failed to garner the necessary support, and has experienced 38talk to any author whose patch has failed to garner the necessary support, and has experienced
38one month of inactivity. Reasonable notice should be given to the author before a patch is 39one month of inactivity. Reasonable notice should be given to the author before a patch is
39abandoned. 40abandoned.
diff --git a/es2015.js b/es2015.js
new file mode 100644
index 0000000..d8be3f1
--- /dev/null
+++ b/es2015.js
@@ -0,0 +1,22 @@
1/*
2 * Copyright 2016 Mirantis, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may
5 * not use this file except in compliance with the License. You may obtain
6 * a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15**/
16
17/**
18 * The default module for this package simply reads in the .eslintrc-es2015 yaml file, and returns
19 * it as a module.
20 */
21
22module.exports = require('./load-config')('.eslintrc-es2015');
diff --git a/index.js b/index.js
index bba9cd6..6c52d16 100644
--- a/index.js
+++ b/index.js
@@ -14,22 +14,9 @@
14 * under the License. 14 * under the License.
15 */ 15 */
16 16
17/*eslint-disable strict*/
18'use strict';
19/*eslint-enable strict*/
20
21/** 17/**
22 * The default module for this package simply reads in the .eslintrc yaml file, and returns it 18 * The default module for this package simply reads in the .eslintrc yaml file, and returns it
23 * as a module. 19 * as a module.
24 */ 20 */
25 21
26var yaml = require('js-yaml'); 22module.exports = require('./load-config')('.eslintrc');
27var fs = require('fs');
28var path = require('path');
29
30/*eslint-disable no-sync */
31var rcPath = path.join(__dirname, '.eslintrc');
32var fileContent = fs.readFileSync(rcPath);
33/*eslint-enable no-sync */
34
35module.exports = yaml.safeLoad(fileContent);
diff --git a/load-config.js b/load-config.js
new file mode 100644
index 0000000..ec05157
--- /dev/null
+++ b/load-config.js
@@ -0,0 +1,31 @@
1/*
2 * Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
3 *
4 * Licensed under the Apache License, Version 2.0 (the 'License'); you may
5 * not use this file except in compliance with the License. You may obtain
6 * a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16
17/**
18 * This is a helper module used to load and export YAML-based ESLint config
19 */
20
21var yaml = require('js-yaml');
22var fs = require('fs');
23var path = require('path');
24
25module.exports = function(filename) {
26 'use strict';
27
28 var rcPath = path.join(__dirname, filename);
29 var fileContent = fs.readFileSync(rcPath); // eslint-disable-line no-sync
30 return yaml.safeLoad(fileContent);
31};
diff --git a/package.json b/package.json
index 6232d1a..8fe39c1 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,10 @@
5 "main": "index.js", 5 "main": "index.js",
6 "files": [ 6 "files": [
7 "index.js", 7 "index.js",
8 "es2015.js",
9 "load-config.js",
8 ".eslintrc", 10 ".eslintrc",
11 ".eslintrc-es2015",
9 "LICENSE", 12 "LICENSE",
10 "README.md" 13 "README.md"
11 ], 14 ],