Permalink
Browse files

ci: Lint with XO

  • Loading branch information...
pvdlg committed Nov 22, 2017
1 parent d548edc commit facdadaddb9d1816c77d5719812734549a74899b
View
@@ -3,6 +3,7 @@
// Bad news: We have to write plain ES5 in this file
// Good news: It's the only file of the entire project
// eslint-disable-next-line no-var
var semver = require('semver');
if (semver.lt(process.version, '8.0.0')) {
@@ -22,7 +23,7 @@ npx is bundled with npm >= 5.4, or available via npm. More info: npm.im/npx`
process.exit(1);
}
// node 8+ from this point on
// Node 8+ from this point on
require('../cli')().catch(() => {
process.exitCode = 1;
});
View
@@ -3,15 +3,15 @@ const SemanticReleaseError = require('@semantic-release/error');
module.exports = (type, lastRelease, logger) => {
let version;
if (!lastRelease.version) {
version = '1.0.0';
logger.log('There is no previous release, the next release version is %s', version);
} else {
if (lastRelease.version) {
version = semver.inc(lastRelease.version, type);
if (!version) {
throw new SemanticReleaseError(`Invalid release type ${type}`, 'EINVALIDTYPE');
}
logger.log('The next release version is %s', version);
} else {
version = '1.0.0';
logger.log('There is no previous release, the next release version is %s', version);
}
return version;
@@ -7,6 +7,7 @@ const npm = require('@semantic-release/npm');
const github = require('@semantic-release/github');
const RELEASE_TYPE = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'];
const validatePluginConfig = conf => isString(conf) || isString(conf.path) || isFunction(conf);
module.exports = {
verifyConditions: {
@@ -74,5 +75,3 @@ module.exports = {
},
},
};
const validatePluginConfig = conf => isString(conf) || isString(conf.path) || isFunction(conf);
View
@@ -42,41 +42,23 @@
"commitizen": "^2.9.6",
"cz-conventional-changelog": "^2.0.0",
"dockerode": "^2.5.2",
"eslint": "^4.7.0",
"eslint-config-prettier": "^2.5.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-prettier": "^2.3.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"mockserver-client": "^2.0.0",
"nock": "^9.0.2",
"npm-registry-couchapp": "^2.6.12",
"nyc": "^11.2.1",
"p-map-series": "^1.0.0",
"prettier": "~1.8.0",
"proxyquire": "^1.8.0",
"rimraf": "^2.5.0",
"sinon": "^4.0.0",
"tempy": "^0.2.1"
"tempy": "^0.2.1",
"xo": "^0.18.2"
},
"engines": {
"node": ">=4",
"npm": ">=2"
},
"eslintConfig": {
"extends": [
"standard",
"prettier"
],
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": 2
}
},
"files": [
"bin",
"lib",
@@ -127,12 +109,22 @@
"url": "git+https://github.com/semantic-release/semantic-release.git"
},
"scripts": {
"clean": "rimraf coverage && rimraf .nyc_output",
"cm": "git-cz",
"codecov": "codecov -f coverage/coverage-final.json",
"lint": "eslint index.js cli.js lib test",
"pretest": "npm run clean && npm run lint",
"lint": "xo",
"pretest": "npm run lint",
"semantic-release": "./bin/semantic-release.js",
"test": "nyc ava -v"
},
"xo": {
"extends": [
"prettier"
],
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": 2
}
}
}
View
@@ -1,6 +1,7 @@
import test from 'ava';
import {stub} from 'sinon';
import SemanticReleaseError from '@semantic-release/error';
import getCommits from '../lib/get-commits';
import {
gitRepo,
gitCommits,
@@ -11,7 +12,6 @@ import {
gitLog,
gitDetachedHead,
} from './helpers/git-utils';
import getCommits from '../lib/get-commits';
test.beforeEach(t => {
// Save the current working diretory
View
@@ -1,6 +1,6 @@
import test from 'ava';
import {gitRepo, gitCommits, gitCheckout, gitTagVersion, gitShallowClone, gitLog} from './helpers/git-utils';
import {gitTagHead, gitCommitTag, isCommitInHistory, unshallow, gitHead} from '../lib/git';
import {gitRepo, gitCommits, gitCheckout, gitTagVersion, gitShallowClone, gitLog} from './helpers/git-utils';
test.beforeEach(t => {
// Save the current working diretory
@@ -74,7 +74,7 @@ test.serial('Get the tag associated with a commit sha or "null" if the commit do
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
let commits = await gitCommits(['First']);
const commits = await gitCommits(['First']);
// Create the tag corresponding to version 1.0.0
await gitTagVersion('v1.0.0');
@@ -86,7 +86,7 @@ test.serial('Get the commit sha for a given tag or "null" if the tag does not ex
// Create a git repository, set the current working directory at the root of the repo
await gitRepo();
// Add commits to the master branch
let commits = await gitCommits(['First']);
const commits = await gitCommits(['First']);
// Create the tag corresponding to version 1.0.0
await gitTagVersion('v1.0.0');
@@ -87,14 +87,14 @@ export async function gitTagVersion(tagName, sha) {
* @return {Array<string>} The list of tags from the current git repository.
*/
export async function gitTags() {
return (await execa('git', ['tag'])).stdout.split('\n').filter(tag => !!tag);
return (await execa('git', ['tag'])).stdout.split('\n').filter(tag => Boolean(tag));
}
/**
* @return {Array<string>} The list of commit sha from the current git repository.
*/
export async function gitLog() {
return (await execa('git', ['log', '--format=format:%H'])).stdout.split('\n').filter(sha => !!sha);
return (await execa('git', ['log', '--format=format:%H'])).stdout.split('\n').filter(sha => Boolean(sha));
}
/**
@@ -7,7 +7,7 @@ import nock from 'nock';
* @param {String} [githubUrl='https://api.github.com'] The url on which to intercept http requests.
* @return {Object} A `nock` object ready to respond to a github authentication request.
*/
export function authenticate(
export default function authenticate(
{githubToken = 'GH_TOKEN', githubUrl = 'https://api.github.com', githubApiPathPrefix = ''} = {}
) {
return nock(`${githubUrl}/${githubApiPathPrefix}`, {reqheaders: {Authorization: `token ${githubToken}`}});
Oops, something went wrong.

0 comments on commit facdada

Please sign in to comment.