@ttoss/config 1.11.3 → 1.11.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -15
- package/dist/esm/index.js +31 -5
- package/dist/index.d.ts +7 -1
- package/dist/index.js +43 -21
- package/package.json +4 -2
- package/src/commitlint.spec.ts +13 -0
- package/src/commitlint.ts +10 -0
- package/src/index.spec.ts +3 -0
- package/src/index.ts +3 -0
- package/src/lintstaged.spec.ts +13 -0
- package/src/lintstaged.ts +8 -0
- package/src/prettier.spec.ts +13 -0
- package/src/prettier.ts +14 -0
package/README.md
CHANGED
|
@@ -1,23 +1,102 @@
|
|
|
1
1
|
# @ttoss/config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<strong>@ttoss/config</strong> is a very opinionated configuration library for monorepo repositories, packages, and applications. It contains a set of default configuration methods that you can use to configure your projects.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Each configuration is customizable and you can extend them with your own. For example, you can use the default `.prettierrc.js` file in your monorepo:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```js title=".prettierrc.js"
|
|
8
|
+
const { prettierConfig } = require('@ttoss/config');
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
module.exports = prettierConfig();
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
But, if you want to change the `printWidth` [option](https://prettier.io/docs/en/options.html), you can do so:
|
|
14
|
+
|
|
15
|
+
```js title=".prettierrc.js"
|
|
16
|
+
const { prettierConfig } = require('@ttoss/config');
|
|
17
|
+
|
|
18
|
+
module.exports = prettierConfig({
|
|
19
|
+
printWidth: 120,
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Install
|
|
24
|
+
|
|
25
|
+
```shell
|
|
26
|
+
$ yarn add -DW @ttoss/config
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Monorepo
|
|
30
|
+
|
|
31
|
+
### Eslint and Prettier
|
|
32
|
+
|
|
33
|
+
Install the following packages on the root of your monorepo:
|
|
34
|
+
|
|
35
|
+
```shell
|
|
36
|
+
yarn add -DW eslint @rushstack/eslint-patch prettier
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Create `.prettierrc.js`:
|
|
40
|
+
|
|
41
|
+
```js title=".prettierrc.js"
|
|
42
|
+
const { prettierConfig } = require('@ttoss/config');
|
|
43
|
+
|
|
44
|
+
module.exports = prettierConfig();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Create `.eslintrc.js`:
|
|
48
|
+
|
|
49
|
+
```js title=".eslintrc.js"
|
|
50
|
+
require('@rushstack/eslint-patch/modern-module-resolution');
|
|
51
|
+
|
|
52
|
+
module.exports = {
|
|
53
|
+
extends: '@ttoss/eslint-config',
|
|
54
|
+
};
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You need `require('@rushstack/eslint-patch/modern-module-resolution');` because ESLint doesn't support plugins as dependency in shareable ESLint configuration, as you can see on [this issue](https://github.com/eslint/eslint/issues/3458). To overcome this, you can use the [`@rushstack/eslint-patch` package](https://www.npmjs.com/package/@rushstack/eslint-patch), a patch that improves how ESLint loads plugins when working in a monorepo
|
|
58
|
+
|
|
59
|
+
### Husky, commitlint, and lint-staged
|
|
60
|
+
|
|
61
|
+
This group of packages will only work if you have already installed [Eslint and Prettier](#eslint-and-prettier).
|
|
62
|
+
|
|
63
|
+
Install the following packages on the root of your monorepo:
|
|
64
|
+
|
|
65
|
+
```shell
|
|
66
|
+
yarn add -DW husky @commitlint/cli lint-staged
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Create `.commitlintrc.js`:
|
|
70
|
+
|
|
71
|
+
```js title=".commitlintrc.js"
|
|
72
|
+
const { commitlintConfig } = require('@ttoss/config');
|
|
73
|
+
|
|
74
|
+
module.exports = commitlintConfig();
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Create `.lintstagedrc.js`:
|
|
78
|
+
|
|
79
|
+
```js title=".lintstagedrc.js"
|
|
80
|
+
const { lintstagedConfig } = require('@ttoss/config');
|
|
81
|
+
|
|
82
|
+
module.exports = lintstagedConfig();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Finally, configure Husky:
|
|
10
86
|
|
|
11
87
|
```shell
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
88
|
+
yarn set-script prepare "husky install"
|
|
89
|
+
yarn run prepare
|
|
90
|
+
yarn husky add .husky/commit-msg "yarn commitlint --edit"
|
|
91
|
+
yarn husky add .husky/pre-commit "yarn lint-staged"
|
|
15
92
|
```
|
|
16
93
|
|
|
17
|
-
##
|
|
94
|
+
## Packages and Applications
|
|
18
95
|
|
|
19
96
|
### Babel
|
|
20
97
|
|
|
98
|
+
Add `babel.config.js` to each package:
|
|
99
|
+
|
|
21
100
|
```js title="babel.config.js"
|
|
22
101
|
const { babelConfig } = require('@ttoss/config');
|
|
23
102
|
|
|
@@ -26,30 +105,66 @@ module.exports = babelConfig();
|
|
|
26
105
|
|
|
27
106
|
### Jest
|
|
28
107
|
|
|
108
|
+
Install [Jest](https://jestjs.io/) and its types on the root of your monorepo (or package):
|
|
109
|
+
|
|
110
|
+
```shell
|
|
111
|
+
yarn add -DW jest @types/jest
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Create `jest.config.ts` for each package:
|
|
115
|
+
|
|
29
116
|
```ts title="jest.config.ts"
|
|
30
117
|
import { jestConfig } from '@ttoss/config';
|
|
31
118
|
|
|
32
|
-
const config = jestConfig(
|
|
33
|
-
moduleNameMapper: {
|
|
34
|
-
'\\.(css)$': 'identity-obj-proxy',
|
|
35
|
-
},
|
|
36
|
-
setupFilesAfterEnv: ['./jest.setup.tsx'],
|
|
37
|
-
testEnvironment: 'jsdom',
|
|
38
|
-
});
|
|
119
|
+
const config = jestConfig();
|
|
39
120
|
|
|
40
121
|
export default config;
|
|
41
122
|
```
|
|
42
123
|
|
|
124
|
+
Configure the `test` script on `package.json`:
|
|
125
|
+
|
|
126
|
+
```json title="package.json'
|
|
127
|
+
"scripts: {
|
|
128
|
+
test: 'jest',
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
43
132
|
### Tsup
|
|
44
133
|
|
|
134
|
+
Use [tsup](https://tsup.egoist.sh/) to bundle your TypeScript package, if you need to.
|
|
135
|
+
|
|
136
|
+
Install [tsup](https://tsup.egoist.sh/) on the root of your monorepo (or package):
|
|
137
|
+
|
|
138
|
+
```shell
|
|
139
|
+
yarn add -DW tsup
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Create `tsup.config.ts` for each package:
|
|
143
|
+
|
|
45
144
|
```ts title="tsup.config.ts"
|
|
46
145
|
import { tsupConfig } from '@ttoss/config';
|
|
47
146
|
|
|
48
147
|
export const tsup = tsupConfig();
|
|
49
148
|
```
|
|
50
149
|
|
|
150
|
+
Configure the `build` script on `package.json`:
|
|
151
|
+
|
|
152
|
+
```json title="package.json'
|
|
153
|
+
"scripts: {
|
|
154
|
+
build: 'tsup',
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
51
158
|
### TypeScript
|
|
52
159
|
|
|
160
|
+
Install [TypeScript](https://www.npmjs.com/package/typescript) on the root of your monorepo (or package):
|
|
161
|
+
|
|
162
|
+
```shell
|
|
163
|
+
yarn add -DW typescript
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Extend default configuration for each `tsconfig.json` of the packages:
|
|
167
|
+
|
|
53
168
|
```json title="tsconfig.json"
|
|
54
169
|
{
|
|
55
170
|
"extends": "@ttoss/config/tsconfig.json"
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/configCreator.ts
|
|
2
2
|
import deepmerge from "deepmerge";
|
|
3
3
|
var overwriteMerge = (_, sourceArray) => sourceArray;
|
|
4
|
-
var configCreator = (
|
|
4
|
+
var configCreator = (defaultConfig7 = {}) => (config = {}) => deepmerge(defaultConfig7, config, { arrayMerge: overwriteMerge });
|
|
5
5
|
|
|
6
6
|
// src/babel.ts
|
|
7
7
|
var defaultConfig = {
|
|
@@ -22,8 +22,14 @@ var defaultConfig = {
|
|
|
22
22
|
};
|
|
23
23
|
var babelConfig = configCreator(defaultConfig);
|
|
24
24
|
|
|
25
|
-
// src/
|
|
25
|
+
// src/commitlint.ts
|
|
26
26
|
var defaultConfig2 = {
|
|
27
|
+
extends: ["@commitlint/config-conventional"]
|
|
28
|
+
};
|
|
29
|
+
var commitlintConfig = configCreator(defaultConfig2);
|
|
30
|
+
|
|
31
|
+
// src/jest.ts
|
|
32
|
+
var defaultConfig3 = {
|
|
27
33
|
clearMocks: true,
|
|
28
34
|
collectCoverage: true,
|
|
29
35
|
coverageDirectory: "coverage",
|
|
@@ -33,10 +39,27 @@ var defaultConfig2 = {
|
|
|
33
39
|
},
|
|
34
40
|
timers: "fake"
|
|
35
41
|
};
|
|
36
|
-
var jestConfig = configCreator(
|
|
42
|
+
var jestConfig = configCreator(defaultConfig3);
|
|
43
|
+
|
|
44
|
+
// src/lintstaged.ts
|
|
45
|
+
var defaultConfig4 = {
|
|
46
|
+
"*.{js,jsx,ts,tsx}": "eslint --fix",
|
|
47
|
+
"*.{md,mdx,html,json,yml,yaml}": "prettier --write"
|
|
48
|
+
};
|
|
49
|
+
var lintstagedConfig = configCreator(defaultConfig4);
|
|
50
|
+
|
|
51
|
+
// src/prettier.ts
|
|
52
|
+
var defaultConfig5 = {
|
|
53
|
+
arrowParens: "always",
|
|
54
|
+
printWidth: 80,
|
|
55
|
+
semi: true,
|
|
56
|
+
singleQuote: true,
|
|
57
|
+
trailingComma: "es5"
|
|
58
|
+
};
|
|
59
|
+
var prettierConfig = configCreator(defaultConfig5);
|
|
37
60
|
|
|
38
61
|
// src/tsup.ts
|
|
39
|
-
var
|
|
62
|
+
var defaultConfig6 = {
|
|
40
63
|
clean: true,
|
|
41
64
|
dts: true,
|
|
42
65
|
entryPoints: ["src/index.ts"],
|
|
@@ -44,9 +67,12 @@ var defaultConfig3 = {
|
|
|
44
67
|
legacyOutput: true,
|
|
45
68
|
minify: false
|
|
46
69
|
};
|
|
47
|
-
var tsupConfig = configCreator(
|
|
70
|
+
var tsupConfig = configCreator(defaultConfig6);
|
|
48
71
|
export {
|
|
49
72
|
babelConfig,
|
|
73
|
+
commitlintConfig,
|
|
50
74
|
jestConfig,
|
|
75
|
+
lintstagedConfig,
|
|
76
|
+
prettierConfig,
|
|
51
77
|
tsupConfig
|
|
52
78
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,14 @@ import { Options } from 'tsup';
|
|
|
2
2
|
|
|
3
3
|
declare const babelConfig: (config?: any) => any;
|
|
4
4
|
|
|
5
|
+
declare const commitlintConfig: (config?: any) => any;
|
|
6
|
+
|
|
5
7
|
declare const jestConfig: (config?: any) => any;
|
|
6
8
|
|
|
9
|
+
declare const lintstagedConfig: (config?: any) => any;
|
|
10
|
+
|
|
11
|
+
declare const prettierConfig: (config?: any) => any;
|
|
12
|
+
|
|
7
13
|
declare const tsupConfig: (config?: Options) => Options;
|
|
8
14
|
|
|
9
|
-
export { babelConfig, jestConfig, tsupConfig };
|
|
15
|
+
export { babelConfig, commitlintConfig, jestConfig, lintstagedConfig, prettierConfig, tsupConfig };
|
package/dist/index.js
CHANGED
|
@@ -4,40 +4,37 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
7
|
var __export = (target, all) => {
|
|
9
8
|
for (var name in all)
|
|
10
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
10
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
16
|
}
|
|
18
|
-
return
|
|
17
|
+
return to;
|
|
19
18
|
};
|
|
20
|
-
var __toESM = (
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
-
return (module2, temp) => {
|
|
25
|
-
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
-
};
|
|
27
|
-
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
21
|
|
|
29
22
|
// src/index.ts
|
|
30
23
|
var src_exports = {};
|
|
31
24
|
__export(src_exports, {
|
|
32
25
|
babelConfig: () => babelConfig,
|
|
26
|
+
commitlintConfig: () => commitlintConfig,
|
|
33
27
|
jestConfig: () => jestConfig,
|
|
28
|
+
lintstagedConfig: () => lintstagedConfig,
|
|
29
|
+
prettierConfig: () => prettierConfig,
|
|
34
30
|
tsupConfig: () => tsupConfig
|
|
35
31
|
});
|
|
32
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
33
|
|
|
37
34
|
// src/configCreator.ts
|
|
38
35
|
var import_deepmerge = __toESM(require("deepmerge"));
|
|
39
36
|
var overwriteMerge = (_, sourceArray) => sourceArray;
|
|
40
|
-
var configCreator = (
|
|
37
|
+
var configCreator = (defaultConfig7 = {}) => (config = {}) => (0, import_deepmerge.default)(defaultConfig7, config, { arrayMerge: overwriteMerge });
|
|
41
38
|
|
|
42
39
|
// src/babel.ts
|
|
43
40
|
var defaultConfig = {
|
|
@@ -58,8 +55,14 @@ var defaultConfig = {
|
|
|
58
55
|
};
|
|
59
56
|
var babelConfig = configCreator(defaultConfig);
|
|
60
57
|
|
|
61
|
-
// src/
|
|
58
|
+
// src/commitlint.ts
|
|
62
59
|
var defaultConfig2 = {
|
|
60
|
+
extends: ["@commitlint/config-conventional"]
|
|
61
|
+
};
|
|
62
|
+
var commitlintConfig = configCreator(defaultConfig2);
|
|
63
|
+
|
|
64
|
+
// src/jest.ts
|
|
65
|
+
var defaultConfig3 = {
|
|
63
66
|
clearMocks: true,
|
|
64
67
|
collectCoverage: true,
|
|
65
68
|
coverageDirectory: "coverage",
|
|
@@ -69,10 +72,27 @@ var defaultConfig2 = {
|
|
|
69
72
|
},
|
|
70
73
|
timers: "fake"
|
|
71
74
|
};
|
|
72
|
-
var jestConfig = configCreator(
|
|
75
|
+
var jestConfig = configCreator(defaultConfig3);
|
|
76
|
+
|
|
77
|
+
// src/lintstaged.ts
|
|
78
|
+
var defaultConfig4 = {
|
|
79
|
+
"*.{js,jsx,ts,tsx}": "eslint --fix",
|
|
80
|
+
"*.{md,mdx,html,json,yml,yaml}": "prettier --write"
|
|
81
|
+
};
|
|
82
|
+
var lintstagedConfig = configCreator(defaultConfig4);
|
|
83
|
+
|
|
84
|
+
// src/prettier.ts
|
|
85
|
+
var defaultConfig5 = {
|
|
86
|
+
arrowParens: "always",
|
|
87
|
+
printWidth: 80,
|
|
88
|
+
semi: true,
|
|
89
|
+
singleQuote: true,
|
|
90
|
+
trailingComma: "es5"
|
|
91
|
+
};
|
|
92
|
+
var prettierConfig = configCreator(defaultConfig5);
|
|
73
93
|
|
|
74
94
|
// src/tsup.ts
|
|
75
|
-
var
|
|
95
|
+
var defaultConfig6 = {
|
|
76
96
|
clean: true,
|
|
77
97
|
dts: true,
|
|
78
98
|
entryPoints: ["src/index.ts"],
|
|
@@ -80,11 +100,13 @@ var defaultConfig3 = {
|
|
|
80
100
|
legacyOutput: true,
|
|
81
101
|
minify: false
|
|
82
102
|
};
|
|
83
|
-
var tsupConfig = configCreator(
|
|
84
|
-
module.exports = __toCommonJS(src_exports);
|
|
103
|
+
var tsupConfig = configCreator(defaultConfig6);
|
|
85
104
|
// Annotate the CommonJS export names for ESM import in node:
|
|
86
105
|
0 && (module.exports = {
|
|
87
106
|
babelConfig,
|
|
107
|
+
commitlintConfig,
|
|
88
108
|
jestConfig,
|
|
109
|
+
lintstagedConfig,
|
|
110
|
+
prettierConfig,
|
|
89
111
|
tsupConfig
|
|
90
112
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/config",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.6",
|
|
4
4
|
"description": "Default configuration for packages.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,14 +31,16 @@
|
|
|
31
31
|
"@babel/preset-env": "^7.16.11",
|
|
32
32
|
"@babel/preset-react": "^7.16.7",
|
|
33
33
|
"@babel/preset-typescript": "^7.16.7",
|
|
34
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
34
35
|
"@emotion/jest": "^11.7.1",
|
|
35
36
|
"@formatjs/ts-transformer": "^3.9.1",
|
|
37
|
+
"babel-jest": "^27.4.6",
|
|
36
38
|
"babel-plugin-formatjs": "^10.3.18",
|
|
37
39
|
"deepmerge": "^4.2.2",
|
|
38
40
|
"identity-obj-proxy": "^3.0.0",
|
|
39
41
|
"tsup": "^5.11.11"
|
|
40
42
|
},
|
|
41
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "eb5615ee3b87ffa3eea40f072cefb6d74a3f5423",
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@jest/types": "^27.4.2"
|
|
44
46
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { commitlintConfig, defaultConfig } from './commitlint';
|
|
2
|
+
|
|
3
|
+
test('should return default configuration', () => {
|
|
4
|
+
expect(commitlintConfig()).toEqual(defaultConfig);
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test('should return default configuration', () => {
|
|
8
|
+
expect(
|
|
9
|
+
commitlintConfig({
|
|
10
|
+
extends: ['other-config'],
|
|
11
|
+
})
|
|
12
|
+
).toEqual({ ...defaultConfig, extends: ['other-config'] });
|
|
13
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://prettier.io/docs/en/configuration.html#sharing-configurations
|
|
3
|
+
*/
|
|
4
|
+
import { configCreator } from './configCreator';
|
|
5
|
+
|
|
6
|
+
export const defaultConfig: any = {
|
|
7
|
+
extends: ['@commitlint/config-conventional'],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const commitlintConfig = configCreator(defaultConfig);
|
package/src/index.spec.ts
CHANGED
|
@@ -2,6 +2,9 @@ import * as allConfigs from '.';
|
|
|
2
2
|
|
|
3
3
|
it('configs should be exported', () => {
|
|
4
4
|
expect(allConfigs.babelConfig).toBeDefined();
|
|
5
|
+
expect(allConfigs.commitlintConfig).toBeDefined();
|
|
5
6
|
expect(allConfigs.jestConfig).toBeDefined();
|
|
7
|
+
expect(allConfigs.lintstagedConfig).toBeDefined();
|
|
8
|
+
expect(allConfigs.prettierConfig).toBeDefined();
|
|
6
9
|
expect(allConfigs.tsupConfig).toBeDefined();
|
|
7
10
|
});
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { lintstagedConfig, defaultConfig } from './lintstaged';
|
|
2
|
+
|
|
3
|
+
test('should return default configuration', () => {
|
|
4
|
+
expect(lintstagedConfig()).toEqual(defaultConfig);
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test('should return default configuration', () => {
|
|
8
|
+
expect(
|
|
9
|
+
lintstagedConfig({
|
|
10
|
+
'.js': 'eslint --fix',
|
|
11
|
+
})
|
|
12
|
+
).toEqual({ ...defaultConfig, '.js': 'eslint --fix' });
|
|
13
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { prettierConfig, defaultConfig } from './prettier';
|
|
2
|
+
|
|
3
|
+
test('should return default configuration', () => {
|
|
4
|
+
expect(prettierConfig()).toEqual(defaultConfig);
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
test('should return default configuration', () => {
|
|
8
|
+
expect(
|
|
9
|
+
prettierConfig({
|
|
10
|
+
printWidth: 100,
|
|
11
|
+
})
|
|
12
|
+
).toEqual({ ...defaultConfig, printWidth: 100 });
|
|
13
|
+
});
|
package/src/prettier.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://prettier.io/docs/en/configuration.html#sharing-configurations
|
|
3
|
+
*/
|
|
4
|
+
import { configCreator } from './configCreator';
|
|
5
|
+
|
|
6
|
+
export const defaultConfig: any = {
|
|
7
|
+
arrowParens: 'always',
|
|
8
|
+
printWidth: 80,
|
|
9
|
+
semi: true,
|
|
10
|
+
singleQuote: true,
|
|
11
|
+
trailingComma: 'es5',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const prettierConfig = configCreator(defaultConfig);
|