Newer Version Available
Custom “House Style” Rules
Customize the JavaScript style rules that Salesforce
Lightning CLI applies to
your code.
It’s common that different organizations or projects will adopt different JavaScript rules. The Lightning CLI tool is here to help you get ready for LockerService, not enforce Salesforce coding conventions. To that end, the Lightning CLI rules are divided into two sets, security rules and style rules. The security rules can’t be modified, but you can modify or add to the style rules.
Use the --config argument to provide a custom rules configuration file. A custom rules configuration file allows you to define your own code style rules, which affect the style rules used by the Lightning CLI tool.
The Lightning CLI default style rules
are provided below. Copy the rules to a new file, and modify them to match your preferred
style rules. Alternatively, you can use your existing ESLint rule configuration file directly.
For
example:
1heroku lightning:lint ./path/to/lightning/components/ --config ~/.eslintrcDefault Style Rules
Here are the default style rules used by Lightning CLI.
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 module.exports = {
18 rules: {
19 // code style rules, these are the default value, but the user can
20 // customize them via --config in the linter by providing custom values
21 // for each of these rules.
22 "no-trailing-spaces": 1,
23 "no-spaced-func": 1,
24 "no-mixed-spaces-and-tabs": 0,
25 "no-multi-spaces": 0,
26 "no-multiple-empty-lines": 0,
27 "no-lone-blocks": 1,
28 "no-lonely-if": 1,
29 "no-inline-comments": 0,
30 "no-extra-parens": 0,
31 "no-extra-semi": 1,
32 "no-warning-comments": [0, { "terms": ["todo", "fixme", "xxx"], "location": "start" }],
33 "block-scoped-var": 1,
34 "brace-style": [1, "1tbs"],
35 "camelcase": 1,
36 "comma-dangle": [1, "never"],
37 "comma-spacing": 1,
38 "comma-style": 1,
39 "complexity": [0, 11],
40 "consistent-this": [0, "that"],
41 "curly": [1, "all"],
42 "eol-last": 0,
43 "func-names": 0,
44 "func-style": [0, "declaration"],
45 "generator-star-spacing": 0,
46 "indent": 0,
47 "key-spacing": 0,
48 "keyword-spacing": [0, "always"],
49 "max-depth": [0, 4],
50 "max-len": [0, 80, 4],
51 "max-nested-callbacks": [0, 2],
52 "max-params": [0, 3],
53 "max-statements": [0, 10],
54 "new-cap": 0,
55 "newline-after-var": 0,
56 "one-var": [0, "never"],
57 "operator-assignment": [0, "always"],
58 "padded-blocks": 0,
59 "quote-props": 0,
60 "quotes": 0,
61 "semi": 1,
62 "semi-spacing": [0, {"before": false, "after": true}],
63 "sort-vars": 0,
64 "space-after-function-name": [0, "never"],
65 "space-before-blocks": [0, "always"],
66 "space-before-function-paren": [0, "always"],
67 "space-before-function-parentheses": [0, "always"],
68 "space-in-brackets": [0, "never"],
69 "space-in-parens": [0, "never"],
70 "space-infix-ops": 0,
71 "space-unary-ops": [1, { "words": true, "nonwords": false }],
72 "spaced-comment": [0, "always"],
73 "vars-on-top": 0,
74 "valid-jsdoc": 0,
75 "wrap-regex": 0,
76 "yoda": [1, "never"]
77 }
78};