UNPKG

2.15 kBJavaScriptView Raw
1/**
2 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 */
8
9// Can't be ESModules as this is not compiled
10const fbjsConfig = require('eslint-config-fbjs');
11
12const variableNamePattern = String.raw`\s*[a-zA-Z_$][a-zA-Z_$\d]*\s*`;
13const importPattern =
14 String.raw`^(?:var|let|const|import type)\s+` +
15 '{?' +
16 variableNamePattern +
17 '(?:,' +
18 variableNamePattern +
19 ')*}?' +
20 String.raw`\s*(?:=\s*require\(|from)[a-zA-Z_+./''\s\d\-]+\)?[^;\n]*[;\n]`;
21const maxLenIgnorePattern = String.raw`(^\s*(it|test)\(|${importPattern})`;
22
23delete fbjsConfig.rules['babel/flow-object-type'];
24
25module.exports = Object.assign({}, fbjsConfig, {
26 env: {
27 es6: true,
28 node: true,
29 },
30 plugins: fbjsConfig.plugins,
31 rules: Object.assign({}, fbjsConfig.rules, {
32 'array-bracket-spacing': [2, 'never'],
33 'arrow-parens': [2, 'as-needed'],
34 'arrow-spacing': [2],
35 'brace-style': [
36 2,
37 '1tbs',
38 {
39 allowSingleLine: true,
40 },
41 ],
42 'comma-dangle': [2, 'always-multiline'],
43 'comma-spacing': [2],
44 'comma-style': [2, 'last'],
45 'computed-property-spacing': [2, 'never'],
46 'eol-last': [2],
47 'ft-flow/object-type-delimiter': [2, 'comma'],
48 indent: [0],
49 'max-len': [
50 2,
51 {
52 code: 80,
53 ignorePattern: maxLenIgnorePattern,
54 ignoreUrls: true,
55 },
56 ],
57 'no-const-assign': [2],
58 'no-extra-parens': [2, 'functions'],
59 'no-irregular-whitespace': [2],
60 'no-this-before-super': [2],
61 'no-var': [2],
62 'object-curly-spacing': [2, 'never'],
63 'object-shorthand': [2],
64 'prefer-arrow-callback': [2],
65 'prefer-const': [2],
66 quotes: [
67 2,
68 'single',
69 {
70 allowTemplateLiterals: true,
71 avoidEscape: true,
72 },
73 ],
74 semi: [2, 'always'],
75 'sort-keys': [2],
76 'space-before-blocks': [2],
77 'space-before-function-paren': [
78 2,
79 {anonymous: 'never', asyncArrow: 'always', named: 'never'},
80 ],
81 'space-in-parens': [2, 'never'],
82 }),
83});