Skip to content

Commit f62778b

Browse files
committed
Refactored index.js to match the new code style
1 parent 2a39941 commit f62778b

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

index.js

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,42 @@
1-
'use strict';
2-
3-
/**
4-
* @module
5-
* @author Oleg Dutchenko <[email protected]>
6-
* @version 1.0.3
7-
* @contributors
8-
* - April Arcus {@link https://github.com/AprilArcus}
9-
*/
10-
11-
var path = require('path')
12-
, escapeStringRegexp = require('escape-string-regexp')
13-
, ESCAPED_NODE_MODULES = escapeStringRegexp('node_modules')
14-
, ESCAPED_PATH_SEP = escapeStringRegexp(path.sep);
15-
16-
// ----------------------------------------
17-
// Public
18-
// ----------------------------------------
1+
const path = require('path');
2+
const escapeStringRegexp = require('escape-string-regexp');
3+
const ESCAPED_NODE_MODULES = escapeStringRegexp('node_modules');
4+
const ESCAPED_PATH_SEP = escapeStringRegexp(path.sep);
195

206
/**
217
* Creating a regular expression for excluding node modules
228
* from babel transpiling except for individual modules
239
* @param {string[]} [exceptionList] - exclude all modules except this list
2410
* @return {RegExp}
2511
*/
26-
function babelLoaderExcludeNodeModulesExcept (exceptionList) {
27-
var normalizedExceptionList
28-
, alternationGroup
29-
, negativeLookahead
30-
12+
function babelLoaderExcludeNodeModulesExcept(exceptionList) {
3113
if (Array.isArray(exceptionList) && exceptionList.length) {
3214
// Module names can contain path separators, e.g. "@types/react".
3315
// Assume POSIX input and normalize for the current platform.
34-
normalizedExceptionList = exceptionList.map(function (moduleName) {
16+
const normalizedExceptionList = exceptionList.map(function (moduleName) {
3517
// We'll handle trailing path separators when we build the
3618
// negative lookahead, so remove them if present.
3719
if (moduleName[moduleName.length - 1] === path.posix.sep) {
3820
moduleName = moduleName.slice(0, -1);
3921
}
4022
return moduleName.split(path.posix.sep).join(path.sep);
4123
});
42-
alternationGroup = '(' + normalizedExceptionList.map(escapeStringRegexp).join('|') + ')';
24+
25+
const alternationGroup =
26+
'(' + normalizedExceptionList.map(escapeStringRegexp).join('|') + ')';
27+
4328
// If the exception list includes e.g. "react", we don't want to
4429
// accidentally make an exception for "react-dom", so make sure to
4530
// include a trailing path separator inside the negative lookahead.
46-
negativeLookahead = '(?!' + alternationGroup + ESCAPED_PATH_SEP + ')';
47-
return new RegExp(ESCAPED_NODE_MODULES + ESCAPED_PATH_SEP + negativeLookahead, 'i');
31+
const negativeLookahead = '(?!' + alternationGroup + ESCAPED_PATH_SEP + ')';
32+
33+
return new RegExp(
34+
ESCAPED_NODE_MODULES + ESCAPED_PATH_SEP + negativeLookahead,
35+
'i'
36+
);
4837
} else {
4938
return new RegExp(ESCAPED_NODE_MODULES, 'i');
5039
}
5140
}
5241

53-
// ----------------------------------------
54-
// Exports
55-
// ----------------------------------------
56-
5742
module.exports = babelLoaderExcludeNodeModulesExcept;

0 commit comments

Comments
 (0)