Skip to content

Commit

Permalink
[Refactor] improve eslint settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Feb 22, 2019
1 parent 9faf119 commit 37554a5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
20 changes: 18 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,34 @@
},
"rules": {
"consistent-return": 1,
"dot-notation": [2, { "allowKeywords": true }],
"func-name-matching": 0,
"max-nested-callbacks": 0,
"max-params": [2, 4],
"no-console": 0,
"sort-keys": 0,

"comma-dangle": [2, {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "never",
}],
"dot-notation": [2, { "allowKeywords": true }],
"no-console": 0,
"object-shorthand": [2, "always"],
"prefer-const": 2,
"quote-props": [2, "as-needed", {
"keywords": false,
"numbers": true,
"unnecessary": true,
}],
},
"overrides": [
{
"files": "test*",
"rules": {
"max-nested-callbacks": 0,
"max-params": 0,
},
},
],
Expand Down
12 changes: 6 additions & 6 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,33 @@ const {
argv: {
output,
date,
'package': pkg
}
package: pkg,
},
} = require('yargs')
.help()
.option('date', {
type: 'string',
describe: '“now”, or a date (same format as `new Date()`)',
demandOption: true,
coerce: function (arg) {
coerce(arg) {
if (arg !== 'now' && !new Date(arg).getTime()) {
throw new TypeError('`date` must be “now” or a valid format for `new Date`');
}
return arg;
}
},
})
.option('package', {
type: 'string',
describe: 'path to a `package.json` file',
normalize: true,
coerce: function (arg) { return path.resolve(arg); }
coerce(arg) { return path.resolve(arg); },
})
.default('package', filename, path.relative(process.cwd(), filename))
.option('output', {
alias: 'o',
describe: 'output file path',
normalize: true,
demandOption: true
demandOption: true,
});

getLockfile(pkg, date === 'now' ? undefined : date, { logger: console.log.bind(console), npmNeeded: '^6.9.0-0' })
Expand Down
2 changes: 1 addition & 1 deletion getLockfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = function getLockfile(packageFile, date, { npmNeeded, logger = (
logger(chalk.blue(`Creating \`package.json\` in temp dir for ${date || '“now”'} lockfile`));
return Promise.all([
copyFile(packageFile, path.join(tmpDir, 'package.json')),
copyFile(npmRC, path.join(tmpDir, '.npmrc'))
copyFile(npmRC, path.join(tmpDir, '.npmrc')),
]);
});
return Promise.all([tmpDirP, copyPkg]).then(([tmpDir]) => new Promise((resolve, reject) => {
Expand Down
8 changes: 4 additions & 4 deletions getProjectTempDir.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const getRootTempDir = function getRootTempDir(npmNeeded, logger = () => {}) {
cleanupHandlers.push(cleanup);
nodeCleanup(finalCleanup);
})).then(tmpDir => {
var npmV = execSync('npm --version', { encoding: 'utf-8', cwd: tmpDir });
const npmV = execSync('npm --version', { encoding: 'utf-8', cwd: tmpDir });
logger(`${chalk.blue('Checking npm version:')} \`npm --version\` -> v${npmV}`);
if (!semver.satisfies(npmV, npmNeeded)) {
const pkgContents = {
'private': true,
private: true,
name: 'npm-jail',
dependencies: {
npm: npmNeeded
}
npm: npmNeeded,
},
};
return writeFile(
path.join(tmpDir, 'package.json'),
Expand Down

0 comments on commit 37554a5

Please sign in to comment.