-
Notifications
You must be signed in to change notification settings - Fork 109
/
FBRequireConfig.js
37 lines (34 loc) · 1.17 KB
/
FBRequireConfig.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
const StringUtils = require('nuclide-format-js/lib/common/utils/StringUtils');
const getDeclarationName = require('../utils/getDeclarationName');
const isGlobal = require('nuclide-format-js/lib/common/utils/isGlobal');
const isValidRequireDeclaration = require('../utils/isValidRequireDeclaration');
const jscs = require('jscodeshift');
module.exports = [
// Handle UpperCase requires, e.g: `require('UpperCase');`
{
searchTerms: [jscs.VariableDeclaration],
filters: [
isGlobal,
path => isValidRequireDeclaration(path.node),
path => StringUtils.isCapitalized(getDeclarationName(path.node)),
],
comparator: (node1, node2) => StringUtils.compareStrings(
getDeclarationName(node1),
getDeclarationName(node2)
),
},
// Handle lowerCase requires, e.g: `require('lowerCase');`
{
searchTerms: [jscs.VariableDeclaration],
filters: [
isGlobal,
path => isValidRequireDeclaration(path.node),
path => !StringUtils.isCapitalized(getDeclarationName(path.node)),
],
comparator: (node1, node2) => StringUtils.compareStrings(
getDeclarationName(node1),
getDeclarationName(node2)
),
},
];