Skip to content

Commit 6964913

Browse files
committed
style: switched from xo to prettier
for #296
1 parent abd2a7e commit 6964913

15 files changed

+7057
-19624
lines changed

README.md

Lines changed: 58 additions & 35 deletions
Large diffs are not rendered by default.

index.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { isUndefined } from 'lodash-es';
2-
import { sync as parser } from 'conventional-commits-parser';
3-
import filter from 'conventional-commits-filter';
4-
import debugFactory from 'debug';
5-
import loadParserConfig from './lib/load-parser-config.js';
6-
import loadReleaseRules from './lib/load-release-rules.js';
7-
import analyzeCommit from './lib/analyze-commit.js';
8-
import compareReleaseTypes from './lib/compare-release-types.js';
9-
import RELEASE_TYPES from './lib/default-release-types.js';
10-
import DEFAULT_RELEASE_RULES from './lib/default-release-rules.js';
1+
import { isUndefined } from "lodash-es";
2+
import { sync as parser } from "conventional-commits-parser";
3+
import filter from "conventional-commits-filter";
4+
import debugFactory from "debug";
5+
import loadParserConfig from "./lib/load-parser-config.js";
6+
import loadReleaseRules from "./lib/load-release-rules.js";
7+
import analyzeCommit from "./lib/analyze-commit.js";
8+
import compareReleaseTypes from "./lib/compare-release-types.js";
9+
import RELEASE_TYPES from "./lib/default-release-types.js";
10+
import DEFAULT_RELEASE_RULES from "./lib/default-release-rules.js";
1111

12-
const debug = debugFactory('semantic-release:commit-analyzer');
12+
const debug = debugFactory("semantic-release:commit-analyzer");
1313

1414
/**
1515
* Determine the type of release to create based on a list of commits.
@@ -26,42 +26,42 @@ const debug = debugFactory('semantic-release:commit-analyzer');
2626
* @returns {String|null} the type of release to create based on the list of commits or `null` if no release has to be done.
2727
*/
2828
export async function analyzeCommits(pluginConfig, context) {
29-
const {commits, logger} = context;
29+
const { commits, logger } = context;
3030
const releaseRules = loadReleaseRules(pluginConfig, context);
3131
const config = await loadParserConfig(pluginConfig, context);
3232
let releaseType = null;
3333

3434
filter(
3535
commits
36-
.filter(({message, hash}) => {
36+
.filter(({ message, hash }) => {
3737
if (!message.trim()) {
38-
debug('Skip commit %s with empty message', hash);
38+
debug("Skip commit %s with empty message", hash);
3939
return false;
4040
}
4141

4242
return true;
4343
})
44-
.map(({message, ...commitProps}) => ({rawMsg: message, message, ...commitProps, ...parser(message, config)}))
45-
).every(({rawMsg, ...commit}) => {
44+
.map(({ message, ...commitProps }) => ({ rawMsg: message, message, ...commitProps, ...parser(message, config) }))
45+
).every(({ rawMsg, ...commit }) => {
4646
logger.log(`Analyzing commit: %s`, rawMsg);
4747
let commitReleaseType;
4848

4949
// Determine release type based on custom releaseRules
5050
if (releaseRules) {
51-
debug('Analyzing with custom rules');
51+
debug("Analyzing with custom rules");
5252
commitReleaseType = analyzeCommit(releaseRules, commit);
5353
}
5454

5555
// If no custom releaseRules or none matched the commit, try with default releaseRules
5656
if (isUndefined(commitReleaseType)) {
57-
debug('Analyzing with default rules');
57+
debug("Analyzing with default rules");
5858
commitReleaseType = analyzeCommit(DEFAULT_RELEASE_RULES, commit);
5959
}
6060

6161
if (commitReleaseType) {
62-
logger.log('The release type for the commit is %s', commitReleaseType);
62+
logger.log("The release type for the commit is %s", commitReleaseType);
6363
} else {
64-
logger.log('The commit should not trigger a release');
64+
logger.log("The commit should not trigger a release");
6565
}
6666

6767
// Set releaseType if commit's release type is higher
@@ -76,7 +76,7 @@ export async function analyzeCommits(pluginConfig, context) {
7676

7777
return true;
7878
});
79-
logger.log('Analysis of %s commits complete: %s release', commits.length, releaseType || 'no');
79+
logger.log("Analysis of %s commits complete: %s release", commits.length, releaseType || "no");
8080

8181
return releaseType;
8282
}

lib/analyze-commit.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { isMatchWith, isString } from 'lodash-es';
2-
import micromatch from 'micromatch';
3-
import debugFactory from 'debug';
4-
import RELEASE_TYPES from './default-release-types.js';
5-
import compareReleaseTypes from './compare-release-types.js';
1+
import { isMatchWith, isString } from "lodash-es";
2+
import micromatch from "micromatch";
3+
import debugFactory from "debug";
4+
import RELEASE_TYPES from "./default-release-types.js";
5+
import compareReleaseTypes from "./compare-release-types.js";
66

7-
const debug = debugFactory('semantic-release:commit-analyzer');
7+
const debug = debugFactory("semantic-release:commit-analyzer");
88
/**
99
* Find all the rules matching and return the highest release type of the matching rules.
1010
*
@@ -17,7 +17,7 @@ export default (releaseRules, commit) => {
1717

1818
releaseRules
1919
.filter(
20-
({breaking, revert, release, ...rule}) =>
20+
({ breaking, revert, release, ...rule }) =>
2121
// If the rule is not `breaking` or the commit doesn't have a breaking change note
2222
(!breaking || (commit.notes && commit.notes.length > 0)) &&
2323
// If the rule is not `revert` or the commit is not a revert
@@ -30,14 +30,14 @@ export default (releaseRules, commit) => {
3030
.every((match) => {
3131
if (compareReleaseTypes(releaseType, match.release)) {
3232
releaseType = match.release;
33-
debug('The rule %o match commit with release type %o', match, releaseType);
33+
debug("The rule %o match commit with release type %o", match, releaseType);
3434
if (releaseType === RELEASE_TYPES[0]) {
35-
debug('Release type %o is the highest possible. Stop analysis.', releaseType);
35+
debug("Release type %o is the highest possible. Stop analysis.", releaseType);
3636
return false;
3737
}
3838
} else {
3939
debug(
40-
'The rule %o match commit with release type %o but the higher release type %o has already been found for this commit',
40+
"The rule %o match commit with release type %o but the higher release type %o has already been found for this commit",
4141
match,
4242
match.release,
4343
releaseType
@@ -48,4 +48,4 @@ export default (releaseRules, commit) => {
4848
});
4949

5050
return releaseType;
51-
}
51+
};

lib/compare-release-types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import RELEASE_TYPES from './default-release-types.js';
1+
import RELEASE_TYPES from "./default-release-types.js";
22

33
/**
44
* Test if a realease type is of higher level than a given one.
@@ -8,4 +8,4 @@ import RELEASE_TYPES from './default-release-types.js';
88
* @return {Boolean} true if `releaseType` is higher than `currentReleaseType`.
99
*/
1010
export default (currentReleaseType, releaseType) =>
11-
!currentReleaseType || RELEASE_TYPES.indexOf(releaseType) < RELEASE_TYPES.indexOf(currentReleaseType)
11+
!currentReleaseType || RELEASE_TYPES.indexOf(releaseType) < RELEASE_TYPES.indexOf(currentReleaseType);

lib/default-release-rules.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
* @type {Array}
55
*/
66
export default [
7-
{ breaking: true, release: 'major' },
8-
{ revert: true, release: 'patch' },
7+
{ breaking: true, release: "major" },
8+
{ revert: true, release: "patch" },
99
// Angular
10-
{ type: 'feat', release: 'minor' },
11-
{ type: 'fix', release: 'patch' },
12-
{ type: 'perf', release: 'patch' },
10+
{ type: "feat", release: "minor" },
11+
{ type: "fix", release: "patch" },
12+
{ type: "perf", release: "patch" },
1313
// Atom
14-
{ emoji: ':racehorse:', release: 'patch' },
15-
{ emoji: ':bug:', release: 'patch' },
16-
{ emoji: ':penguin:', release: 'patch' },
17-
{ emoji: ':apple:', release: 'patch' },
18-
{ emoji: ':checkered_flag:', release: 'patch' },
14+
{ emoji: ":racehorse:", release: "patch" },
15+
{ emoji: ":bug:", release: "patch" },
16+
{ emoji: ":penguin:", release: "patch" },
17+
{ emoji: ":apple:", release: "patch" },
18+
{ emoji: ":checkered_flag:", release: "patch" },
1919
// Ember
20-
{ tag: 'BUGFIX', release: 'patch' },
21-
{ tag: 'FEATURE', release: 'minor' },
22-
{ tag: 'SECURITY', release: 'patch' },
20+
{ tag: "BUGFIX", release: "patch" },
21+
{ tag: "FEATURE", release: "minor" },
22+
{ tag: "SECURITY", release: "patch" },
2323
// ESLint
24-
{ tag: 'Breaking', release: 'major' },
25-
{ tag: 'Fix', release: 'patch' },
26-
{ tag: 'Update', release: 'minor' },
27-
{ tag: 'New', release: 'minor' },
24+
{ tag: "Breaking", release: "major" },
25+
{ tag: "Fix", release: "patch" },
26+
{ tag: "Update", release: "minor" },
27+
{ tag: "New", release: "minor" },
2828
// Express
29-
{ component: 'perf', release: 'patch' },
30-
{ component: 'deps', release: 'patch' },
29+
{ component: "perf", release: "patch" },
30+
{ component: "deps", release: "patch" },
3131
// JSHint
32-
{ type: 'FEAT', release: 'minor' },
33-
{ type: 'FIX', release: 'patch' },
32+
{ type: "FEAT", release: "minor" },
33+
{ type: "FIX", release: "patch" },
3434
];

lib/default-release-types.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
*
44
* @type {Array}
55
*/
6-
export default ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'];
6+
export default ["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"];

lib/load-parser-config.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { dirname } from 'node:path';
2-
import { fileURLToPath } from 'node:url';
3-
import { promisify } from 'node:util';
4-
import { isPlainObject } from 'lodash-es';
5-
import importFrom from 'import-from';
6-
import conventionalChangelogAngular from 'conventional-changelog-angular';
1+
import { dirname } from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
import { promisify } from "node:util";
4+
import { isPlainObject } from "lodash-es";
5+
import importFrom from "import-from";
6+
import conventionalChangelogAngular from "conventional-changelog-angular";
77

88
/**
99
* Load `conventional-changelog-parser` options. Handle presets that return either a `Promise<Array>` or a `Promise<Function>`.
@@ -29,11 +29,11 @@ export default async ({ preset, config, parserOpts, presetConfig }, { cwd }) =>
2929
loadedConfig = conventionalChangelogAngular;
3030
}
3131

32-
loadedConfig = await (typeof loadedConfig === 'function'
32+
loadedConfig = await (typeof loadedConfig === "function"
3333
? isPlainObject(presetConfig)
3434
? loadedConfig(presetConfig)
3535
: promisify(loadedConfig)()
3636
: loadedConfig);
3737

38-
return {...loadedConfig.parserOpts, ...parserOpts};
39-
}
38+
return { ...loadedConfig.parserOpts, ...parserOpts };
39+
};

lib/load-release-rules.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { dirname } from 'node:path';
2-
import { fileURLToPath } from 'node:url';
3-
import { isUndefined } from 'lodash-es';
4-
import importFrom from 'import-from';
5-
import RELEASE_TYPES from './default-release-types.js';
1+
import { dirname } from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
import { isUndefined } from "lodash-es";
4+
import importFrom from "import-from";
5+
import RELEASE_TYPES from "./default-release-types.js";
66

77
/**
88
* Load and validate the `releaseRules` rules.
@@ -23,7 +23,7 @@ export default ({ releaseRules }, { cwd }) => {
2323

2424
if (releaseRules) {
2525
loadedReleaseRules =
26-
typeof releaseRules === 'string'
26+
typeof releaseRules === "string"
2727
? importFrom.silent(__dirname, releaseRules) || importFrom(cwd, releaseRules)
2828
: releaseRules;
2929

@@ -45,4 +45,4 @@ export default ({ releaseRules }, { cwd }) => {
4545
}
4646

4747
return loadedReleaseRules;
48-
}
48+
};

0 commit comments

Comments
 (0)