Skip to content

Commit a530981

Browse files
committed
style: lift core/library to own modules
1 parent fa80b1b commit a530981

File tree

115 files changed

+877
-197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+877
-197
lines changed

@commitlint/cli/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
"babel-polyfill": "6.26.0",
7474
"chalk": "2.3.0",
7575
"get-stdin": "5.0.1",
76-
"lodash": "4.17.4",
76+
"lodash.merge": "4.6.0",
77+
"lodash.pick": "4.4.0",
7778
"meow": "3.7.0"
7879
}
7980
}

@commitlint/cli/src/cli.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ require('babel-polyfill'); // eslint-disable-line import/no-unassigned-import
44
const core = require('@commitlint/core');
55
const chalk = require('chalk');
66
const meow = require('meow');
7-
const {merge, pick} = require('lodash');
7+
const merge = require('lodash.merge');
8+
const pick = require('lodash.pick');
89
const stdin = require('get-stdin');
910

1011
const pkg = require('../package');

@commitlint/cli/src/cli.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path';
22
import {fix, git} from '@commitlint/test';
33
import test from 'ava';
44
import execa from 'execa';
5-
import {merge} from 'lodash';
5+
import merge from 'lodash.merge';
66
import * as sander from 'sander';
77
import stream from 'string-to-stream';
88

@commitlint/config-patternplate/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
const path = require('path');
22
const globby = require('globby');
3-
const merge = require('lodash').merge;
3+
const merge = require('lodash.merge');
44

55
function pathToId(root, filePath) {
66
const relativePath = path.relative(root, filePath);
7-
return path.dirname(relativePath).split(path.sep).join('/');
7+
return path
8+
.dirname(relativePath)
9+
.split(path.sep)
10+
.join('/');
811
}
912

1013
function getPatternIDs() {

@commitlint/config-patternplate/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"dependencies": {
3030
"@commitlint/config-angular": "^5.1.1",
3131
"globby": "4.1.0",
32-
"lodash": "4.17.4"
32+
"lodash.merge": "4.6.0"
3333
},
3434
"devDependencies": {
3535
"@commitlint/utils": "^5.1.1",

@commitlint/core/package.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,26 @@
6767
"cross-env": "5.1.1",
6868
"execa": "0.8.0",
6969
"globby": "6.1.0",
70+
"lodash.includes": "4.3.0",
7071
"rimraf": "2.6.1",
7172
"xo": "0.18.2"
7273
},
7374
"dependencies": {
75+
"@commitlint/execute-rule": "5.2.6",
76+
"@commitlint/is-ignored": "5.2.6",
7477
"@commitlint/parse": "5.2.6",
78+
"@commitlint/resolve-extends": "5.2.6",
79+
"@commitlint/rules": "5.2.6",
80+
"@commitlint/top-level": "5.2.6",
7581
"@marionebl/sander": "^0.6.0",
7682
"babel-runtime": "^6.23.0",
7783
"chalk": "^2.0.1",
7884
"cosmiconfig": "^3.0.1",
79-
"find-up": "^2.1.0",
8085
"git-raw-commits": "^1.3.0",
81-
"lodash": "^4.17.4",
82-
"require-uncached": "^1.0.3",
83-
"resolve-from": "^4.0.0",
84-
"resolve-global": "^0.1.0",
85-
"semver": "^5.3.0"
86+
"lodash.merge": "4.6.0",
87+
"lodash.mergewith": "4.6.0",
88+
"lodash.pick": "4.4.0",
89+
"lodash.topairs": "4.3.0",
90+
"resolve-from": "4.0.0"
8691
}
8792
}

@commitlint/core/src/format.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22
import chalk from 'chalk';
3-
import {includes} from 'lodash';
3+
import includes from 'lodash.includes';
44
import format from './format';
55

66
const ok = chalk.bold(`${chalk.green('✔')} found 0 problems, 0 warnings`);

@commitlint/core/src/lint.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import isIgnored from '@commitlint/is-ignored';
12
import parse from '@commitlint/parse';
2-
import {entries} from 'lodash';
3-
import isIgnored from './library/is-ignored';
4-
import implementations from './rules';
3+
import implementations from '@commitlint/rules';
4+
import entries from 'lodash.topairs';
55

66
export default async (message, rules = {}, opts = {}) => {
77
// Found a wildcard match, skip

@commitlint/core/src/load.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import path from 'path';
2+
import executeRule from '@commitlint/execute-rule';
3+
import resolveExtends from '@commitlint/resolve-extends';
24
import cosmiconfig from 'cosmiconfig';
3-
import {entries, merge, mergeWith, pick} from 'lodash';
5+
import entries from 'lodash.topairs';
6+
import merge from 'lodash.merge';
7+
import mergeWith from 'lodash.mergewith';
8+
import pick from 'lodash.pick';
49
import resolveFrom from 'resolve-from';
510

6-
import executeRule from './library/execute-rule';
7-
import resolveExtends from './library/resolve-extends';
8-
911
const w = (a, b) => (Array.isArray(b) ? b : undefined);
1012
const valid = input => pick(input, 'extends', 'rules', 'parserPreset');
1113

@commitlint/core/src/read.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path';
22
import gitRawCommits from 'git-raw-commits';
33
import * as sander from '@marionebl/sander';
44

5-
import toplevel from './library/toplevel';
5+
import toplevel from '@commitlint/top-level';
66

77
export default getCommitMessages;
88

@commitlint/ensure/package.json

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"name": "@commitlint/ensure",
3+
"version": "5.2.6",
4+
"description": "Lint your commit messages",
5+
"main": "lib/index.js",
6+
"scripts": {
7+
"build": "cross-env NODE_ENV=production babel src --out-dir lib --source-maps",
8+
"clean": "npx rimraf lib",
9+
"deps": "dep-check",
10+
"lint": "xo",
11+
"start": "concurrently \"ava -c 4 --verbose --watch\" \"yarn run watch\"",
12+
"test": "ava -c 4 --verbose",
13+
"watch": "babel src --out-dir lib --watch --source-maps"
14+
},
15+
"ava": {
16+
"files": [
17+
"src/**/*.test.js",
18+
"!lib/**/*"
19+
],
20+
"source": [
21+
"src/**/*.js",
22+
"!lib/**/*"
23+
],
24+
"babel": "inherit",
25+
"require": [
26+
"babel-register"
27+
]
28+
},
29+
"babel": {
30+
"presets": [
31+
"babel-preset-commitlint"
32+
]
33+
},
34+
"xo": false,
35+
"engines": {
36+
"node": ">=4"
37+
},
38+
"repository": {
39+
"type": "git",
40+
"url": "https://github.com/marionebl/commitlint.git"
41+
},
42+
"bugs": {
43+
"url": "https://github.com/marionebl/commitlint/issues"
44+
},
45+
"homepage": "https://github.com/marionebl/commitlint#readme",
46+
"keywords": [
47+
"conventional-changelog",
48+
"commitlint",
49+
"library",
50+
"core"
51+
],
52+
"author": {
53+
"name": "Mario Nebl",
54+
"email": "[email protected]"
55+
},
56+
"license": "MIT",
57+
"devDependencies": {
58+
"@commitlint/test": "^5.2.6",
59+
"@commitlint/utils": "^5.1.1",
60+
"ava": "0.22.0",
61+
"babel-cli": "6.26.0",
62+
"babel-preset-commitlint": "^5.2.0",
63+
"babel-register": "6.26.0",
64+
"concurrently": "3.5.1",
65+
"cross-env": "5.1.1",
66+
"globby": "6.1.0",
67+
"lodash.values": "4.3.0",
68+
"rimraf": "2.6.1",
69+
"xo": "0.18.2"
70+
},
71+
"dependencies": {
72+
"lodash.camelcase": "4.3.0",
73+
"lodash.kebabcase": "4.1.1",
74+
"lodash.snakecase": "4.1.1",
75+
"lodash.upperfirst": "4.3.1",
76+
"lodash.startcase": "4.4.0"
77+
}
78+
}

@commitlint/core/src/library/ensure-case.js @commitlint/ensure/src/case.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import {camelCase, kebabCase, snakeCase, upperFirst, startCase} from 'lodash';
1+
import camelCase from 'lodash.camelcase';
2+
import kebabCase from 'lodash.kebabcase';
3+
import snakeCase from 'lodash.snakecase';
4+
import upperFirst from 'lodash.upperfirst';
5+
import startCase from 'lodash.startcase';
26

37
export default ensureCase;
48

@commitlint/core/src/library/ensure-case.test.js @commitlint/ensure/src/case.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import ensure from './ensure-case';
2+
import ensure from './case';
33

44
test('true for no params', t => {
55
const actual = ensure();
File renamed without changes.

@commitlint/core/src/library/ensure-enum.test.js @commitlint/ensure/src/enum.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import ensure from './ensure-enum';
2+
import ensure from './enum';
33

44
test('false for no params', t => {
55
const actual = ensure();

@commitlint/ensure/src/index.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import ensureCase from './case';
2+
import ensureEnum from './enum';
3+
import maxLength from './max-length';
4+
import minLength from './min-length';
5+
import notEmpty from './not-empty';
6+
7+
export {ensureCase as case};
8+
export {ensureEnum as enum};
9+
export {maxLength, minLength, notEmpty};

@commitlint/ensure/src/index.test.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import path from 'path';
2+
import test from 'ava';
3+
import globby from 'globby';
4+
import camelCase from 'lodash.camelcase';
5+
import values from 'lodash.values';
6+
import * as ensure from '.';
7+
8+
test('exports all rules', async t => {
9+
const expected = (await glob('*.js')).map(f => camelCase(f));
10+
const actual = Object.keys(ensure);
11+
t.deepEqual(actual, expected);
12+
});
13+
14+
test('rules export functions', t => {
15+
const actual = values(ensure);
16+
t.true(actual.every(rule => typeof rule === 'function'));
17+
});
18+
19+
async function glob(pattern) {
20+
const files = await globby([path.join(__dirname, pattern)], {
21+
ignore: ['**/index.js', '**/*.test.js'],
22+
cwd: __dirname
23+
});
24+
return files.map(relative).map(toExport);
25+
}
26+
27+
function relative(filePath) {
28+
return path.relative(__dirname, filePath);
29+
}
30+
31+
function toExport(fileName) {
32+
return path.basename(fileName, path.extname(fileName));
33+
}

@commitlint/core/src/library/ensure-min-length.test.js @commitlint/ensure/src/max-length.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import ensure from './ensure-min-length';
2+
import ensure from './max-length';
33

44
test('false for no params', t => {
55
const actual = ensure();
@@ -13,12 +13,12 @@ test('true for a against 1', t => {
1313

1414
test('false for ab against 0', t => {
1515
const actual = ensure('a', 0);
16-
t.is(actual, true);
16+
t.is(actual, false);
1717
});
1818

1919
test('true for a against 2', t => {
2020
const actual = ensure('a', 2);
21-
t.is(actual, false);
21+
t.is(actual, true);
2222
});
2323

2424
test('true for ab against 2', t => {

@commitlint/core/src/library/ensure-max-length.test.js @commitlint/ensure/src/min-length.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import ensure from './ensure-max-length';
2+
import ensure from './min-length';
33

44
test('false for no params', t => {
55
const actual = ensure();
@@ -13,12 +13,12 @@ test('true for a against 1', t => {
1313

1414
test('false for ab against 0', t => {
1515
const actual = ensure('a', 0);
16-
t.is(actual, false);
16+
t.is(actual, true);
1717
});
1818

1919
test('true for a against 2', t => {
2020
const actual = ensure('a', 2);
21-
t.is(actual, true);
21+
t.is(actual, false);
2222
});
2323

2424
test('true for ab against 2', t => {

@commitlint/core/src/library/ensure-not-empty.test.js @commitlint/ensure/src/not-empty.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'ava';
2-
import ensure from './ensure-not-empty';
2+
import ensure from './not-empty';
33

44
test('false for no params', t => {
55
const actual = ensure();

0 commit comments

Comments
 (0)