UNPKG

4.9 kBJavaScriptView Raw
1/*
2 * Copyright (C) 2016 salesforce.com, inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain 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,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17"use strict";
18
19// to guarantee that all custom rules are loaded before creating the config
20require("./load-rules.js");
21
22var ERROR = 2;
23var WARNING = 1;
24var IGNORE = 0;
25
26// eslint config
27module.exports = {
28 version: false,
29 eslintrc: false,
30 env: {
31 browser: true
32 },
33 parserOptions: {
34 ecmaVersion: 5
35 },
36 globals: {
37 $A: true,
38 AuraContext: true,
39 AuraSerializationService: true,
40 AuraExpressionService: true,
41 AuraEventService: true,
42 AuraLocalizationService: true,
43 AuraStorageService: true,
44 AuraStyleService: true,
45 MetricsService: true,
46 AuraDevToolService: true,
47 Component: true,
48 CKEDITOR: true,
49 FORCE: true,
50 moment: true,
51 exports: true,
52 iScroll: true,
53 unescape: true,
54 Promise: true
55 },
56 rules: {
57 // custom rules
58 "ecma-intrinsics": ERROR,
59 "new-rule-template": IGNORE,
60 "secure-document": ERROR,
61 "aura-api": ERROR,
62 "secure-window": ERROR,
63
64 // platform rules that as immutable
65 "no-alert": ERROR,
66 "no-array-constructor": ERROR, // help with instanceof
67 "no-bitwise": WARNING, // usually a typo | -> ||
68 "no-caller": ERROR, // strict mode compliance
69 "no-catch-shadow": ERROR,
70 "no-cond-assign": ERROR,
71 "no-console": ERROR,
72 "no-constant-condition": ERROR,
73 "no-control-regex": WARNING,
74 "no-debugger": ERROR,
75 "no-delete-var": WARNING, // for perf reasons, we might want to set this to 2
76 "no-div-regex": WARNING,
77 "no-dupe-keys": ERROR,
78 "no-dupe-args": ERROR,
79 "no-duplicate-case": ERROR,
80 "no-else-return": IGNORE,
81 "no-empty-character-class": ERROR,
82 "no-eq-null": WARNING,
83 "no-eval": IGNORE,
84 "no-ex-assign": ERROR,
85 "no-extend-native": ERROR,
86 "no-extra-bind": ERROR,
87 "no-extra-boolean-cast": ERROR,
88 "no-fallthrough": ERROR, // switch fallthrough
89 "no-floating-decimal": WARNING, // var num = .5;
90 "no-func-assign": ERROR,
91 "no-implied-eval": ERROR,
92 "no-inner-declarations": [ERROR, "functions"],
93 "no-invalid-regexp": ERROR,
94 "no-irregular-whitespace": ERROR,
95 "no-iterator": ERROR,
96 "no-label-var": ERROR,
97 "no-labels": ERROR,
98 "no-loop-func": ERROR,
99 "no-multi-str": ERROR,
100 "no-native-reassign": ERROR,
101 "no-negated-in-lhs": ERROR,
102 "no-nested-ternary": WARNING,
103 "no-new": ERROR,
104 "no-new-func": IGNORE,
105 "no-new-object": ERROR,
106 "no-new-wrappers": ERROR,
107 "no-obj-calls": ERROR,
108 "no-octal": ERROR,
109 "no-octal-escape": ERROR,
110 "no-param-reassign": WARNING,
111 "no-plusplus": WARNING,
112 "no-proto": ERROR,
113 "no-redeclare": ERROR,
114 "no-regex-spaces": ERROR,
115 "no-return-assign": ERROR,
116 "no-script-url": ERROR,
117 "no-self-compare": ERROR,
118 "no-sequences": ERROR, // var a = (3, 5);
119 "no-shadow": ERROR,
120 "no-shadow-restricted-names": ERROR,
121 "no-sparse-arrays": ERROR,
122 "no-ternary": IGNORE,
123 "no-throw-literal": WARNING,
124 "no-undef": WARNING,
125 "no-undef-init": WARNING,
126 "no-undefined": IGNORE,
127 "no-underscore-dangle": IGNORE,
128 "no-unreachable": ERROR,
129 "no-unused-expressions": WARNING,
130 "no-unused-vars": [WARNING, { vars: "all", args: "after-used" }],
131 "no-use-before-define": [ERROR, { functions: false }],
132 "no-void": ERROR,
133 "no-var": IGNORE,
134 "no-with": ERROR,
135 "consistent-return": WARNING,
136 "default-case": ERROR,
137 "dot-notation": [WARNING, { allowKeywords: true }],
138 eqeqeq: ["error", "smart"],
139 "guard-for-in": WARNING,
140 "handle-callback-err": WARNING,
141 "new-parens": ERROR,
142 radix: ERROR,
143 strict: [ERROR, "global"],
144 "use-isnan": ERROR,
145 "valid-typeof": ERROR,
146 "wrap-iife": [WARNING, "any"]
147
148 // aside from this list, ./code-style-rules.js will have the rules that are not
149 // important for the code to function, but just stylish.
150 }
151};