Skip to content

Commit aa0604a

Browse files
committed
refactor(codebase): Auto-fix simple lint issues
1 parent a157a28 commit aa0604a

14 files changed

+40
-40
lines changed

core/lib/addPattern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ module.exports = function(pattern, patternlab) {
1313
'/patterns/' + pattern.patternLink;
1414

1515
//only push to array if the array doesn't contain this pattern
16-
var isNew = true;
17-
for (var i = 0; i < patternlab.patterns.length; i++) {
16+
let isNew = true;
17+
for (let i = 0; i < patternlab.patterns.length; i++) {
1818
//so we need the identifier to be unique, which patterns[i].relPath is
1919
if (pattern.relPath === patternlab.patterns[i].relPath) {
2020
//if relPath already exists, overwrite that element

core/lib/buildListItems.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@ const _ = require('lodash');
44

55
module.exports = function(container) {
66
//combine all list items into one structure
7-
var list = [];
8-
for (var item in container.listitems) {
7+
const list = [];
8+
for (const item in container.listitems) {
99
if (container.listitems.hasOwnProperty(item)) {
1010
list.push(container.listitems[item]);
1111
}
1212
}
1313
container.listItemArray = _.shuffle(list);
1414

15-
for (var i = 1; i <= container.listItemArray.length; i++) {
16-
var tempItems = [];
15+
for (let i = 1; i <= container.listItemArray.length; i++) {
16+
const tempItems = [];
1717
if (i === 1) {
1818
tempItems.push(container.listItemArray[0]);
1919
container.listitems['' + i] = tempItems;
2020
} else {
21-
for (var c = 1; c <= i; c++) {
21+
for (let c = 1; c <= i; c++) {
2222
tempItems.push(container.listItemArray[c - 1]);
2323
container.listitems['' + i] = tempItems;
2424
}

core/lib/expandPartials.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ module.exports = function(currentPattern, patternlab) {
3131
.then(() => {
3232
//do something with the regular old partials
3333
foundPatternPartials.forEach(foundPartial => {
34-
var partial = currentPattern.findPartial(foundPartial);
35-
var partialPattern = getPartial(partial, patternlab);
34+
const partial = currentPattern.findPartial(foundPartial);
35+
const partialPattern = getPartial(partial, patternlab);
3636

3737
//recurse through nested partials to fill out this extended template.
3838
return processRecursive(partialPattern.relPath, patternlab)
@@ -41,7 +41,7 @@ module.exports = function(currentPattern, patternlab) {
4141

4242
//complete assembly of extended template
4343
//create a copy of the partial so as to not pollute it after the getPartial call.
44-
var cleanPartialPattern = jsonCopy(
44+
const cleanPartialPattern = jsonCopy(
4545
partialPattern,
4646
`partial pattern ${partial}`
4747
);

core/lib/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = function(partialName, patternlab) {
2222

2323
//return the fuzzy match if all else fails
2424
for (var i = 0; i < patternlab.patterns.length; i++) {
25-
var partialParts = partialName.split('-'),
25+
let partialParts = partialName.split('-'),
2626
partialType = partialParts[0],
2727
partialNameEnd = partialParts.slice(1).join('-');
2828

core/lib/loadPattern.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let fs = require('fs-extra'); //eslint-disable-line prefer-const
2222
// loads a pattern from disk, creates a Pattern object from it and
2323
// all its associated files, and records it in patternlab.patterns[]
2424
module.exports = function(relPath, patternlab) {
25-
var relativeDepth = (relPath.match(/\w(?=\\)|\w(?=\/)/g) || []).length;
25+
const relativeDepth = (relPath.match(/\w(?=\\)|\w(?=\/)/g) || []).length;
2626
if (relativeDepth > 2) {
2727
logger.warning('');
2828
logger.warning('Warning:');
@@ -50,24 +50,24 @@ module.exports = function(relPath, patternlab) {
5050
}
5151

5252
//check if the found file is a top-level markdown file
53-
var fileObject = path.parse(relPath);
53+
const fileObject = path.parse(relPath);
5454
if (fileObject.ext === '.md') {
5555
try {
56-
var proposedDirectory = path.resolve(
56+
const proposedDirectory = path.resolve(
5757
patternlab.config.paths.source.patterns,
5858
fileObject.dir,
5959
fileObject.name
6060
);
61-
var proposedDirectoryStats = fs.statSync(proposedDirectory);
61+
const proposedDirectoryStats = fs.statSync(proposedDirectory);
6262
if (proposedDirectoryStats.isDirectory()) {
63-
var subTypeMarkdownFileContents = fs.readFileSync(
63+
const subTypeMarkdownFileContents = fs.readFileSync(
6464
proposedDirectory + '.md',
6565
'utf8'
6666
);
67-
var subTypeMarkdown = markdown_parser.parse(
67+
const subTypeMarkdown = markdown_parser.parse(
6868
subTypeMarkdownFileContents
6969
);
70-
var subTypePattern = new Pattern(relPath, null, patternlab);
70+
const subTypePattern = new Pattern(relPath, null, patternlab);
7171
subTypePattern.patternSectionSubtype = true;
7272
subTypePattern.patternDesc = subTypeMarkdown
7373
? subTypeMarkdown.markdown
@@ -91,17 +91,17 @@ module.exports = function(relPath, patternlab) {
9191
}
9292

9393
//extract some information
94-
var filename = fileObject.base;
95-
var ext = fileObject.ext;
96-
var patternsPath = patternlab.config.paths.source.patterns;
94+
const filename = fileObject.base;
95+
const ext = fileObject.ext;
96+
const patternsPath = patternlab.config.paths.source.patterns;
9797

9898
// skip non-pattern files
9999
if (!patternEngines.isPatternFile(filename, patternlab)) {
100100
return null;
101101
}
102102

103103
//make a new Pattern Object
104-
var currentPattern = new Pattern(relPath, null, patternlab);
104+
const currentPattern = new Pattern(relPath, null, patternlab);
105105

106106
//if file is named in the syntax for variants
107107
if (patternEngines.isPseudoPatternJSON(filename)) {
@@ -166,7 +166,7 @@ module.exports = function(relPath, patternlab) {
166166
readDocumentation(currentPattern, patternlab);
167167

168168
//add the raw template to memory
169-
var templatePath = path.resolve(patternsPath, currentPattern.relPath);
169+
const templatePath = path.resolve(patternsPath, currentPattern.relPath);
170170

171171
currentPattern.template = fs.readFileSync(templatePath, 'utf8');
172172

core/lib/parseAllLinks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = function(patternlab) {
99
patternlab.data = parseLink(patternlab, patternlab.data, 'data.json');
1010

1111
//loop through all patterns
12-
for (var i = 0; i < patternlab.patterns.length; i++) {
12+
for (let i = 0; i < patternlab.patterns.length; i++) {
1313
patternlab.patterns[i].jsonFileData = parseLink(
1414
patternlab,
1515
patternlab.patterns[i].jsonFileData,

core/lib/parseLink.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const logger = require('./log');
66
const getPartial = require('./get');
77

88
module.exports = function(patternlab, obj, key) {
9-
var linkRE, dataObjAsString, linkMatches;
9+
let linkRE, dataObjAsString, linkMatches;
1010

1111
//check for 'link.patternPartial'
1212
linkRE = /(?:'|")(link\.[A-z0-9-_]+)(?:'|")/g;
@@ -21,18 +21,18 @@ module.exports = function(patternlab, obj, key) {
2121
linkMatches = dataObjAsString.match(linkRE);
2222

2323
if (linkMatches) {
24-
for (var i = 0; i < linkMatches.length; i++) {
25-
var dataLink = linkMatches[i];
24+
for (let i = 0; i < linkMatches.length; i++) {
25+
const dataLink = linkMatches[i];
2626
if (dataLink && dataLink.split('.').length >= 2) {
2727
//get the partial the link refers to
28-
var linkPatternPartial = dataLink
28+
const linkPatternPartial = dataLink
2929
.split('.')[1]
3030
.replace('"', '')
3131
.replace("'", '');
32-
var pattern = getPartial(linkPatternPartial, patternlab);
32+
const pattern = getPartial(linkPatternPartial, patternlab);
3333
if (pattern !== undefined) {
3434
//get the full built link and replace it
35-
var fullLink = patternlab.data.link[linkPatternPartial];
35+
let fullLink = patternlab.data.link[linkPatternPartial];
3636
if (fullLink) {
3737
fullLink = path.normalize(fullLink).replace(/\\/g, '/');
3838

@@ -54,7 +54,7 @@ module.exports = function(patternlab, obj, key) {
5454
}
5555
}
5656

57-
var dataObj;
57+
let dataObj;
5858
try {
5959
dataObj = JSON.parse(dataObjAsString);
6060
} catch (err) {

core/lib/pattern_engines.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const PatternEngines = Object.create({
132132
* @memberof PatternEngines
133133
*/
134134
loadAllEngines: function(patternLabConfig) {
135-
var self = this;
135+
const self = this;
136136

137137
// Try to load engines! We scan for engines at each path specified above. This
138138
// function is kind of a big deal.

core/lib/pattern_graph.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const PatternGraph = function(graph, timestamp, version) {
5151
};
5252

5353
// shorthand. Use relPath as it is always unique, even with subPatternType
54-
var nodeName = p => (p instanceof Pattern ? p.relPath : p);
54+
const nodeName = p => (p instanceof Pattern ? p.relPath : p);
5555

5656
PatternGraph.prototype = {
5757
/**

core/lib/patternlab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ module.exports = class PatternLab {
402402
// see if patternData really needs these other duped values
403403

404404
// construct our extraOutput dump
405-
var extraOutput = Object.assign(
405+
const extraOutput = Object.assign(
406406
{},
407407
pattern.extraOutput,
408408
pattern.allMarkdown

0 commit comments

Comments
 (0)