Skip to content

Commit

Permalink
Style: remove eslint warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeer264 committed Jun 14, 2018
1 parent 465aab5 commit 448747a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 26 deletions.
24 changes: 8 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
'use strict';

const rcs = require('rcs-core');
const fs = require('fs-extra');
const path = require('path');
const glob = require('glob');
const json = require('json-extra');
const async = require('async');
const _ = require('lodash');

/**
* parses through every single document and renames the names
*
* @module renameCssSelectors
*/
const renameCssSelectors = module.exports = {};
const renameCssSelectors = {};

// PROCESS
renameCssSelectors.processSync = require('./lib/process/processSync');
renameCssSelectors.process = require('./lib/process/process');
renameCssSelectors.processSync = require('./lib/process/processSync');
renameCssSelectors.process = require('./lib/process/process');
renameCssSelectors.processCssSync = require('./lib/processCss/processCssSync');
renameCssSelectors.processCss = require('./lib/processCss/processCss');
renameCssSelectors.processJsSync = require('./lib/processJs/processJsSync');
renameCssSelectors.processJs = require('./lib/processJs/processJs');
renameCssSelectors.processCss = require('./lib/processCss/processCss');
renameCssSelectors.processJsSync = require('./lib/processJs/processJsSync');
renameCssSelectors.processJs = require('./lib/processJs/processJs');

// MAPPING
renameCssSelectors.generateMappingSync = require('./lib/mapping/generateMappingSync');
Expand All @@ -30,3 +20,5 @@ renameCssSelectors.loadMapping = require('./lib/mapping/loadMapping');

// CONFIG
renameCssSelectors.includeConfig = require('./lib/config/includeConfig');

module.exports = renameCssSelectors;
4 changes: 1 addition & 3 deletions lib/config/includeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ const json = require('json-extra');
/**
* includes .rcsrc - if not found it will include "rcs" in package.json
*/
const include = (pathString) => {
const include = (pathString = path.join(process.cwd(), '.rcsrc')) => {
let configObject;

pathString = pathString || path.join(process.cwd(), '.rcsrc');

configObject = json.readToObjSync(pathString);

if (!configObject) {
Expand Down
17 changes: 12 additions & 5 deletions lib/mapping/generateMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const json = require('json-extra');

const save = require('../helper/save');

/* eslint-disable max-len */
/**
* @typedef {Object} generateMappingOptions
* @property {Boolean | String} [cssMapping=true] true will generate the css mapping. A string will generate the css mapping file and the object is called like the string
Expand All @@ -15,14 +16,15 @@ const save = require('../helper/save');
* @property {Boolean} [json=true] defines if metadata should be added to the selector
* @property {Boolean} [isSelectors=true] if it should write the selector type into the key (# | .)
*/
/* eslint-enable max-len */
/**
* generates a file including all old and new selectors/names
* includes also unused class selectors
*
* @param {String} pathString where it should get saved
* @param {generateMappingOptions} [options]
*/
const generateMapping = (pathString, options, cb) => {
const generateMapping = (pathString, opts, cb) => {
let fileName = 'renaming_map';
let fileNameExt = '.json';
let mappingName = 'CSS_NAME_MAPPING';
Expand All @@ -37,9 +39,12 @@ const generateMapping = (pathString, options, cb) => {
overwrite: false,
};

let options = opts;
let callback = cb;

// set cb if options are not set
if (typeof cb !== 'function') {
cb = options;
if (typeof callback !== 'function') {
callback = options;
options = {};
}

Expand Down Expand Up @@ -77,9 +82,11 @@ const generateMapping = (pathString, options, cb) => {
}

save(`${newPath}${fileNameExt}`, writeData, { overwrite: options.overwrite }, (err, data) => {
if (err) cb(err);
if (err) {
callback(err);
}

cb(null, data);
callback(null, data);
});
}; // /generateMapping

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "./index.js",
"scripts": {
"test": "mocha -R spec --recursive test lib",
"lint": "eslint lib --ignore-pattern '**/tests/**'",
"fix": "eslint lib --ignore-pattern '**/tests/**' --fix",
"lint": "eslint lib index.js --ignore-pattern '**/tests/**'",
"fix": "npm run lint -- --fix",
"coverage": "istanbul cover _mocha -- -R spec --recursive test lib",
"coveralls": "npm run coverage && coveralls < coverage/lcov.info"
},
Expand Down

0 comments on commit 448747a

Please sign in to comment.