@w5s/mrm-preset 1.0.0-alpha.5 → 1.0.0-alpha.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/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.6](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.5...@w5s/mrm-preset@1.0.0-alpha.6) (2022-02-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * correct gitignore task ([b4f0903](https://github.com/w5s/project-config/commit/b4f0903561c97500aef65488ef06ccd7eae0db80))
12
+ * remove jest on lint-staged ([2fbc851](https://github.com/w5s/project-config/commit/2fbc85132ab380429d6966bff47b176bcfb51f6d))
13
+ * shorten eslint extensions ([aecc870](https://github.com/w5s/project-config/commit/aecc870ce0b288436208757376bc05504bff3331))
14
+
15
+
16
+ ### Features
17
+
18
+ * use es-jest as default jest preset ([61535d9](https://github.com/w5s/project-config/commit/61535d9c47c25150becc564a5dd273d7cc14b579))
19
+
20
+
21
+
22
+
23
+
6
24
  # [1.0.0-alpha.5](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.4...@w5s/mrm-preset@1.0.0-alpha.5) (2022-02-18)
7
25
 
8
26
 
package/core/jest.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable no-template-curly-in-string */
2
2
  const { packageJson } = require('mrm-core');
3
- const { vscodeSnippets } = require('./vscode');
4
3
  const pkg = require('./pkg');
5
4
  const npm = require('./npm');
6
5
  const project = require('./project');
@@ -13,34 +12,31 @@ const project = require('./project');
13
12
  function jest({ state }) {
14
13
  const packageFileDefault = packageJson();
15
14
  const hasJest = state === 'present';
16
- const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
17
15
  const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
16
+ const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
18
17
 
19
18
  pkg.withPackageJson((packageFile) => {
20
19
  if (hasJest) {
21
- const ignorePatterns = ['/node_modules/', '/docs/', '/lib/', '/build/', '/.cache/', '/public/'];
22
- packageFile.merge({
23
- jest: {
24
- coveragePathIgnorePatterns: ignorePatterns,
25
- testPathIgnorePatterns: ignorePatterns,
26
- },
27
- });
28
- if (hasTypescript) {
20
+ if (hasWorkspaces) {
21
+ pkg.value(packageFile, {
22
+ path: 'jest',
23
+ state: 'present',
24
+ update: () => ({
25
+ preset: 'es-jest',
26
+ projects: packageFile
27
+ .get('workspaces.packages', packageFile.get('workspaces', []))
28
+ .map((/** @type {string} */ workspace) => `<rootDir>/${workspace}`),
29
+ }),
30
+ });
31
+ } else {
32
+ const ignorePatterns = ['/node_modules/', '/docs/', '/lib/', '/build/', '/.cache/', '/public/'];
29
33
  packageFile.merge({
30
34
  jest: {
31
- globals: {
32
- 'ts-jest': {
33
- tsconfig: hasWorkspaces ? 'tsconfig.settings.json' : 'tsconfig.json',
34
- },
35
- },
36
- roots: hasWorkspaces ? ['<rootDir>/packages'] : null,
37
- transform: {
38
- '^.+\\.tsx?$': 'ts-jest',
39
- },
35
+ preset: 'es-jest',
36
+ coveragePathIgnorePatterns: ignorePatterns,
37
+ testPathIgnorePatterns: ignorePatterns,
40
38
  },
41
39
  });
42
- } else {
43
- packageFile.unset('jest.globals.ts-jest').unset('jest.transform.^.+\\.tsx?$');
44
40
  }
45
41
  } else {
46
42
  packageFile.unset('jest');
@@ -56,48 +52,43 @@ function jest({ state }) {
56
52
  script: hasWorkspaces ? pkg.emptyScript : 'jest',
57
53
  state: !hasJest || hasWorkspaces ? 'default' : 'present',
58
54
  });
59
- pkg.script(packageFile, {
60
- name: `${project.test}:watch`,
61
- script: pkg.emptyScript,
62
- state: 'absent',
63
- });
64
55
  });
65
56
  // Dependencies
66
57
  npm.dependency({
67
58
  dev: true,
68
- name: ['jest', 'babel-jest', '@babel/core'],
59
+ name: ['jest', 'es-jest'],
69
60
  state: hasJest ? 'present' : 'absent',
70
61
  });
71
62
  npm.dependency({
72
63
  dev: true,
73
- name: ['ts-jest', '@types/jest'],
64
+ name: ['@types/jest'],
74
65
  state: hasJest && hasTypescript ? 'present' : 'absent',
75
66
  });
76
67
 
77
- vscodeSnippets({
78
- name: 'jest',
79
- snippets: {
80
- 'Jest Describe Block': {
81
- body: ["describe('${1:description}', () => {", '\t$0', '});'],
82
- description: 'Jest describe block',
83
- prefix: 'describe',
84
- scope: 'javascript,typescript',
85
- },
86
- 'Jest Expect': {
87
- body: 'expect($0)',
88
- description: 'Jest expect assertion',
89
- prefix: 'expect',
90
- scope: 'javascript,typescript',
91
- },
92
- 'Jest Test Block': {
93
- body: ["test('${1:description}', () => {", '\t$0', '});'],
94
- description: 'Jest test block',
95
- prefix: 'test',
96
- scope: 'javascript,typescript',
97
- },
98
- },
99
- state: hasJest ? 'present' : 'absent',
100
- });
68
+ // vscodeSnippets({
69
+ // name: 'jest',
70
+ // snippets: {
71
+ // 'Jest Describe Block': {
72
+ // body: ["describe('${1:description}', () => {", '\t$0', '});'],
73
+ // description: 'Jest describe block',
74
+ // prefix: 'describe',
75
+ // scope: 'javascript,typescript',
76
+ // },
77
+ // 'Jest Expect': {
78
+ // body: 'expect($0)',
79
+ // description: 'Jest expect assertion',
80
+ // prefix: 'expect',
81
+ // scope: 'javascript,typescript',
82
+ // },
83
+ // 'Jest Test Block': {
84
+ // body: ["test('${1:description}', () => {", '\t$0', '});'],
85
+ // description: 'Jest test block',
86
+ // prefix: 'test',
87
+ // scope: 'javascript,typescript',
88
+ // },
89
+ // },
90
+ // state: hasJest ? 'present' : 'absent',
91
+ // });
101
92
  }
102
93
 
103
94
  module.exports = {
package/eslint/index.js CHANGED
@@ -70,7 +70,7 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
70
70
  json: hasJSON,
71
71
  };
72
72
  const extList = Object.keys(extsMap).filter((ext) => extsMap[ext]);
73
- const extOption = ` --ext ${extList.map((ext) => `.${ext}`).join(',')}`;
73
+ const extOption = ` --ext=${extList.join(',')}`;
74
74
 
75
75
  pkg.withPackageJson((packageFile) => {
76
76
  pkg.script(packageFile, {
package/githooks/index.js CHANGED
@@ -12,7 +12,6 @@ function createGitHooks() {
12
12
  const gitSupported = hasGit();
13
13
  const packageFile = packageJson();
14
14
  const hasESLint = pkg.hasDependency(packageFile, 'eslint', 'dev');
15
- const hasJest = pkg.hasDependency(packageFile, 'jest', 'dev');
16
15
  const hasTsc = pkg.hasDependency(packageFile, 'typescript', 'dev');
17
16
 
18
17
  husky({
@@ -23,16 +22,8 @@ function createGitHooks() {
23
22
  update: (config) => ({
24
23
  ...config,
25
24
  '*.json': [...(hasESLint ? ['eslint'] : [])],
26
- '*.js?(x)': [
27
- ...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []),
28
- ...(hasESLint ? ['eslint'] : []),
29
- ...(hasJest ? ['jest --ci --bail --findRelatedTests'] : []),
30
- ],
31
- '*.ts?(x)': [
32
- ...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []),
33
- ...(hasESLint ? ['eslint'] : []),
34
- ...(hasJest ? ['jest --ci --bail --findRelatedTests'] : []),
35
- ],
25
+ '*.js?(x)': [...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []), ...(hasESLint ? ['eslint'] : [])],
26
+ '*.ts?(x)': [...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []), ...(hasESLint ? ['eslint'] : [])],
36
27
  }),
37
28
  });
38
29
  gitHook({
@@ -4,3 +4,5 @@ function task() {
4
4
  gitIgnoreTemplate(['macOS', 'NodeJS', 'VisualStudioCode']);
5
5
  }
6
6
  task.description = 'Adds Gitignore file';
7
+
8
+ module.exports = task;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/mrm-preset",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "Mrm configuration presets",
5
5
  "keywords": [
6
6
  "mrm",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "17d00b3e9ba103fd053aed2c06535d0b1526886a"
48
+ "gitHead": "0bf05f35388f1ddb53438a017186cf64d2ce99f2"
49
49
  }