xenopomp-essentials 0.3.1 → 0.3.3
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/.config/.lintstagedrc.json +3 -0
- package/.config/build.config.ts +41 -0
- package/.config/testing-exclusions/index.ts +2 -0
- package/.config/testing-exclusions/istanbul-exclusions.ts +1 -0
- package/.config/testing-exclusions/vitest-exclusions.ts +8 -0
- package/.config/ts/tsconfig.lint.json +10 -0
- package/.config/vitest.config.ts +18 -0
- package/.gitattributes +25 -0
- package/.github/workflows/ci.yml +54 -0
- package/.github/workflows/npm-publish.yml +27 -0
- package/.husky/pre-commit +1 -0
- package/.idea/codeStyles/Project.xml +59 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/runConfigurations/_template__of_Vitest.xml +9 -0
- package/.idea/runConfigurations/build.xml +13 -0
- package/.idea/runConfigurations/coverage.xml +12 -0
- package/.idea/runConfigurations/lint.xml +13 -0
- package/.idea/runConfigurations/lint_code.xml +13 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/xenopomp-essentials-js.iml +14 -0
- package/.prettierrc +20 -0
- package/.yarnrc +2 -0
- package/README.md +0 -0
- package/__tests__/assets/assertions/expect-deep-equal.ts +14 -0
- package/__tests__/assets/assertions/expect-to-render.ts +26 -0
- package/__tests__/assets/assertions/index.ts +3 -0
- package/__tests__/assets/assertions/not-throwing.ts +6 -0
- package/__tests__/assets/index.ts +1 -0
- package/__tests__/data/index.ts +1 -0
- package/__tests__/data/parseVersion.data.ts +52 -0
- package/__tests__/unit/cli/path-builder.test.ts +39 -0
- package/__tests__/unit/components/hoc/jsx-dot-notation/component.test-source.tsx +24 -0
- package/__tests__/unit/components/hoc/jsx-dot-notation/hoc.test.tsx +11 -0
- package/__tests__/unit/components/metrika.test.tsx +14 -0
- package/__tests__/unit/components/react-scan.test.tsx +10 -0
- package/__tests__/unit/eslint/config.test.tsx +41 -0
- package/__tests__/unit/utils/capitalize.test.ts +17 -0
- package/__tests__/unit/utils/minmax.test.ts +21 -0
- package/__tests__/unit/utils/parseVersion.test.ts +22 -0
- package/__tests__/unit/utils/pipe.test.ts +23 -0
- package/__tests__/unit/utils/transliterate.test.ts +17 -0
- package/_templates/generator/help/index.ejs.t +5 -0
- package/_templates/generator/new/hello.ejs.t +18 -0
- package/_templates/generator/with-prompt/hello.ejs.t +18 -0
- package/_templates/generator/with-prompt/prompt.ejs.t +14 -0
- package/_templates/init/repo/new-repo.ejs.t +4 -0
- package/_templates/type/new/module.ejs.t +7 -0
- package/_templates/type/new/type.ejs.t +7 -0
- package/_templates/util/new/func.ejs.t +7 -0
- package/_templates/util/new/module.ejs.t +7 -0
- package/_templates/util/new/test.ejs.t +13 -0
- package/eslint.config.ts +17 -0
- package/package.json +4 -3
- package/src/cli-tools/changeFile.ts +1 -0
- package/src/cli-tools/index.ts +2 -0
- package/src/cli-tools/pathBuilder.ts +89 -0
- package/src/eslint/config.ts +145 -0
- package/src/eslint/configs/all.ts +74 -0
- package/src/eslint/configs/deprecation.ts +33 -0
- package/src/eslint/configs/index.ts +7 -0
- package/src/eslint/configs/markdown.ts +30 -0
- package/src/eslint/configs/next.ts +40 -0
- package/src/eslint/configs/old.ts +67 -0
- package/src/eslint/configs/prettier.ts +6 -0
- package/src/eslint/configs/react.ts +18 -0
- package/src/eslint/index.ts +7 -0
- package/src/eslint/prefixes/author.ts +2 -0
- package/src/eslint/prefixes/index.ts +1 -0
- package/src/eslint/types/configs.ts +4 -0
- package/src/eslint/types/custom-config.ts +4 -0
- package/src/eslint/types/index.ts +2 -0
- package/src/index.ts +3 -0
- package/src/next/Metrika/Metrika.props.ts +11 -0
- package/src/next/Metrika/Metrika.tsx +56 -0
- package/src/next/ReactScan/ReactScan.tsx +33 -0
- package/src/next/index.ts +2 -0
- package/src/react/hoc/index.ts +1 -0
- package/src/react/hoc/jsxDotNotation.tsx +38 -0
- package/src/react/index.ts +1 -0
- package/src/repo-eslint-rules/deep-type-naming.rule.ts +49 -0
- package/src/repo-eslint-rules/index.ts +9 -0
- package/src/schemas/import-meta.schema.ts +12 -0
- package/src/schemas/index.ts +1 -0
- package/src/types/aliases/AnyObject.ts +5 -0
- package/src/types/aliases/EmptyObject.ts +8 -0
- package/src/types/aliases/Fn.ts +12 -0
- package/src/types/aliases/index.ts +3 -0
- package/src/types/index.ts +4 -0
- package/src/types/next/NextParams.ts +26 -0
- package/src/types/next/index.ts +1 -0
- package/src/types/react/AnyFc.ts +6 -0
- package/src/types/react/AsyncFC.ts +16 -0
- package/src/types/react/DataAttributes.ts +21 -0
- package/src/types/react/FCProps.ts +19 -0
- package/src/types/react/FunctionalChildren.ts +13 -0
- package/src/types/react/SetState.ts +11 -0
- package/src/types/react/VariableFC.ts +48 -0
- package/src/types/react/VariableProps.ts +9 -0
- package/src/types/react/index.ts +8 -0
- package/src/types/utilities/ArrayType.ts +12 -0
- package/src/types/utilities/AsyncReturnType.ts +14 -0
- package/src/types/utilities/DeepInject.ts +22 -0
- package/src/types/utilities/Defined.ts +5 -0
- package/src/types/utilities/Jsonish.ts +11 -0
- package/src/types/utilities/LenientAutocomplete.ts +24 -0
- package/src/types/utilities/MatchType.ts +26 -0
- package/src/types/utilities/MergeTypes.ts +12 -0
- package/src/types/utilities/Modify.ts +10 -0
- package/src/types/utilities/Nullable.ts +5 -0
- package/src/types/utilities/OneOf.ts +42 -0
- package/src/types/utilities/Prettify.ts +15 -0
- package/src/types/utilities/RecordKey.ts +9 -0
- package/src/types/utilities/RecordValue.ts +9 -0
- package/src/types/utilities/ReplaceReturnType.ts +10 -0
- package/src/types/utilities/SelectivePartial.ts +17 -0
- package/src/types/utilities/StrictOmit.ts +19 -0
- package/src/types/utilities/Synchronous.ts +18 -0
- package/src/types/utilities/Undefinable.ts +5 -0
- package/src/types/utilities/WeakOmit.ts +17 -0
- package/src/types/utilities/Writeable.ts +18 -0
- package/src/types/utilities/index.ts +24 -0
- package/src/utils/capitalize.ts +15 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/minmax.ts +35 -0
- package/src/utils/parseVersion.ts +42 -0
- package/src/utils/pipe.ts +29 -0
- package/src/utils/transliterate.ts +8 -0
- package/tsconfig.json +43 -0
- package/cli-tools/index.d.mts +0 -60
- package/cli-tools/index.d.ts +0 -60
- package/cli-tools/index.mjs +0 -1
- package/eslint/index.d.mts +0 -39
- package/eslint/index.d.ts +0 -39
- package/eslint/index.mjs +0 -3
- package/index.d.mts +0 -611
- package/index.d.ts +0 -611
- package/index.mjs +0 -1
- package/next/index.d.mts +0 -67
- package/next/index.d.ts +0 -67
- package/next/index.mjs +0 -11
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { copyFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { defineBuildConfig } from 'unbuild';
|
|
4
|
+
|
|
5
|
+
export default defineBuildConfig([
|
|
6
|
+
{
|
|
7
|
+
entries: [
|
|
8
|
+
// Main entry
|
|
9
|
+
'./src/index.ts',
|
|
10
|
+
|
|
11
|
+
// Type declarations
|
|
12
|
+
{
|
|
13
|
+
builder: 'mkdist',
|
|
14
|
+
input: './src/declarations',
|
|
15
|
+
outDir: './dist/declarations',
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
// Modules that are not to be exported from main module
|
|
19
|
+
'./src/next/index.ts',
|
|
20
|
+
'./src/cli-tools/index.ts',
|
|
21
|
+
'./src/eslint/index.ts',
|
|
22
|
+
],
|
|
23
|
+
outDir: './dist',
|
|
24
|
+
failOnWarn: false,
|
|
25
|
+
declaration: true,
|
|
26
|
+
alias: {
|
|
27
|
+
'@': path.resolve(__dirname, '../', './src'),
|
|
28
|
+
'@test': path.resolve(__dirname, '../', './__tests__'),
|
|
29
|
+
},
|
|
30
|
+
rollup: {
|
|
31
|
+
esbuild: {
|
|
32
|
+
minify: true,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
hooks: {
|
|
36
|
+
'build:done': async () => {
|
|
37
|
+
await copyFile('./package.json', './dist/package.json');
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const istanbulExclusions: string[] = [];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import react from '@vitejs/plugin-react';
|
|
2
|
+
import tsconfigPathsPlugin from 'vite-tsconfig-paths';
|
|
3
|
+
import { defineConfig } from 'vitest/config';
|
|
4
|
+
|
|
5
|
+
import { istanbulExclusions, vitestExclusions } from './testing-exclusions';
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [react(), tsconfigPathsPlugin()],
|
|
9
|
+
test: {
|
|
10
|
+
environment: 'jsdom',
|
|
11
|
+
exclude: vitestExclusions,
|
|
12
|
+
coverage: {
|
|
13
|
+
provider: 'istanbul',
|
|
14
|
+
reporter: ['text', 'json', 'json-summary', 'html'],
|
|
15
|
+
exclude: [...vitestExclusions, ...istanbulExclusions],
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
});
|
package/.gitattributes
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Auto detect text files and perform LF normalization
|
|
2
|
+
* text eol=lf
|
|
3
|
+
|
|
4
|
+
.nvmrc text
|
|
5
|
+
|
|
6
|
+
# Binary files should be encoded as binary
|
|
7
|
+
*.png binary
|
|
8
|
+
*.jpg binary
|
|
9
|
+
*.jpeg binary
|
|
10
|
+
*.gif binary
|
|
11
|
+
*.ico binary
|
|
12
|
+
*.mov binary
|
|
13
|
+
*.mp4 binary
|
|
14
|
+
*.mp3 binary
|
|
15
|
+
*.flv binary
|
|
16
|
+
*.fla binary
|
|
17
|
+
*.swf binary
|
|
18
|
+
*.gz binary
|
|
19
|
+
*.zip binary
|
|
20
|
+
*.7z binary
|
|
21
|
+
*.ttf binary
|
|
22
|
+
*.eot binary
|
|
23
|
+
*.woff binary
|
|
24
|
+
*.pyc binary
|
|
25
|
+
*.pdf binary
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: 'CI'
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
pull_request:
|
|
9
|
+
branches:
|
|
10
|
+
- main
|
|
11
|
+
- master
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
# Install Node.js and dependencies
|
|
15
|
+
ci:
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
NODE_VERSION:
|
|
19
|
+
- '20'
|
|
20
|
+
- '22'
|
|
21
|
+
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
permissions:
|
|
24
|
+
contents: read
|
|
25
|
+
pull-requests: write
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: mstachniuk/ci-skip@v1
|
|
29
|
+
with:
|
|
30
|
+
commit-filter: '[skip ci]'
|
|
31
|
+
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
|
|
34
|
+
- name: '🧩 Install Node (${{ matrix.NODE_VERSION }})'
|
|
35
|
+
uses: actions/setup-node@v4
|
|
36
|
+
with:
|
|
37
|
+
node-version: '${{ matrix.NODE_VERSION }}'
|
|
38
|
+
|
|
39
|
+
- name: '📦 Install dependencies'
|
|
40
|
+
run: yarn install --frozen-lockfile
|
|
41
|
+
|
|
42
|
+
- name: '📕 Linting'
|
|
43
|
+
run: yarn lint
|
|
44
|
+
|
|
45
|
+
# Start to run our inline jobs
|
|
46
|
+
# Vitest
|
|
47
|
+
- name: '🧪 Run coverage'
|
|
48
|
+
run: yarn coverage
|
|
49
|
+
|
|
50
|
+
- name: '✍️ Report coverage'
|
|
51
|
+
if: always() # Also generate the report if tests are failing
|
|
52
|
+
uses: davelosert/vitest-coverage-report-action@v2
|
|
53
|
+
with:
|
|
54
|
+
vite-config-path: .config/vitest.config.ts
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
release:
|
|
9
|
+
types: [created]
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
publish-npm:
|
|
13
|
+
name: Publish to NPM registry
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- name: Build all sources
|
|
18
|
+
run: |
|
|
19
|
+
yarn install --frozen-lockfile
|
|
20
|
+
yarn build
|
|
21
|
+
|
|
22
|
+
- name: Publish if version has been updated
|
|
23
|
+
uses: JS-DevTools/npm-publish@v2
|
|
24
|
+
with:
|
|
25
|
+
token: ${{ secrets.npm_token }}
|
|
26
|
+
access: public
|
|
27
|
+
package: ./dist/package.json
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
yarn lint-staged -c ./.config/.lintstagedrc.json
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<component name="ProjectCodeStyleConfiguration">
|
|
2
|
+
<code_scheme name="Project" version="173">
|
|
3
|
+
<HTMLCodeStyleSettings>
|
|
4
|
+
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
|
5
|
+
</HTMLCodeStyleSettings>
|
|
6
|
+
<JSCodeStyleSettings version="0">
|
|
7
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
8
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
9
|
+
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
10
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
11
|
+
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
|
12
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
13
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
14
|
+
</JSCodeStyleSettings>
|
|
15
|
+
<TypeScriptCodeStyleSettings version="0">
|
|
16
|
+
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
|
17
|
+
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
|
18
|
+
<option name="USE_DOUBLE_QUOTES" value="false" />
|
|
19
|
+
<option name="FORCE_QUOTE_STYlE" value="true" />
|
|
20
|
+
<option name="ENFORCE_TRAILING_COMMA" value="Remove" />
|
|
21
|
+
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
|
22
|
+
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
|
23
|
+
</TypeScriptCodeStyleSettings>
|
|
24
|
+
<VueCodeStyleSettings>
|
|
25
|
+
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
|
26
|
+
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
|
27
|
+
</VueCodeStyleSettings>
|
|
28
|
+
<codeStyleSettings language="HTML">
|
|
29
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
30
|
+
<indentOptions>
|
|
31
|
+
<option name="INDENT_SIZE" value="2" />
|
|
32
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
33
|
+
<option name="TAB_SIZE" value="2" />
|
|
34
|
+
</indentOptions>
|
|
35
|
+
</codeStyleSettings>
|
|
36
|
+
<codeStyleSettings language="JavaScript">
|
|
37
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
38
|
+
<indentOptions>
|
|
39
|
+
<option name="INDENT_SIZE" value="2" />
|
|
40
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
41
|
+
<option name="TAB_SIZE" value="2" />
|
|
42
|
+
</indentOptions>
|
|
43
|
+
</codeStyleSettings>
|
|
44
|
+
<codeStyleSettings language="TypeScript">
|
|
45
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
46
|
+
<indentOptions>
|
|
47
|
+
<option name="INDENT_SIZE" value="2" />
|
|
48
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
49
|
+
<option name="TAB_SIZE" value="2" />
|
|
50
|
+
</indentOptions>
|
|
51
|
+
</codeStyleSettings>
|
|
52
|
+
<codeStyleSettings language="Vue">
|
|
53
|
+
<option name="SOFT_MARGINS" value="80" />
|
|
54
|
+
<indentOptions>
|
|
55
|
+
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
|
56
|
+
</indentOptions>
|
|
57
|
+
</codeStyleSettings>
|
|
58
|
+
</code_scheme>
|
|
59
|
+
</component>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/xenopomp-essentials-js.iml" filepath="$PROJECT_DIR$/.idea/xenopomp-essentials-js.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
|
2
|
+
<configuration default="true" type="JavaScriptTestRunnerVitest">
|
|
3
|
+
<node-interpreter value="project" />
|
|
4
|
+
<vitest-options value="-c ./.config/vitest.config.ts" />
|
|
5
|
+
<envs />
|
|
6
|
+
<scope-kind value="ALL" />
|
|
7
|
+
<method v="2" />
|
|
8
|
+
</configuration>
|
|
9
|
+
</component>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
|
2
|
+
<configuration default="false" name="build" type="js.build_tools.npm" nameIsGenerated="true">
|
|
3
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
4
|
+
<command value="run" />
|
|
5
|
+
<scripts>
|
|
6
|
+
<script value="build" />
|
|
7
|
+
</scripts>
|
|
8
|
+
<node-interpreter value="project" />
|
|
9
|
+
<package-manager value="yarn" />
|
|
10
|
+
<envs />
|
|
11
|
+
<method v="2" />
|
|
12
|
+
</configuration>
|
|
13
|
+
</component>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
|
2
|
+
<configuration default="false" name="coverage" type="js.build_tools.npm" nameIsGenerated="true">
|
|
3
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
4
|
+
<command value="run" />
|
|
5
|
+
<scripts>
|
|
6
|
+
<script value="coverage" />
|
|
7
|
+
</scripts>
|
|
8
|
+
<node-interpreter value="project" />
|
|
9
|
+
<envs />
|
|
10
|
+
<method v="2" />
|
|
11
|
+
</configuration>
|
|
12
|
+
</component>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
|
2
|
+
<configuration default="false" name="lint" type="js.build_tools.npm" nameIsGenerated="true">
|
|
3
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
4
|
+
<command value="run" />
|
|
5
|
+
<scripts>
|
|
6
|
+
<script value="lint" />
|
|
7
|
+
</scripts>
|
|
8
|
+
<node-interpreter value="project" />
|
|
9
|
+
<package-manager value="yarn" />
|
|
10
|
+
<envs />
|
|
11
|
+
<method v="2" />
|
|
12
|
+
</configuration>
|
|
13
|
+
</component>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<component name="ProjectRunConfigurationManager">
|
|
2
|
+
<configuration default="false" name="lint:code" type="js.build_tools.npm" nameIsGenerated="true">
|
|
3
|
+
<package-json value="$PROJECT_DIR$/package.json" />
|
|
4
|
+
<command value="run" />
|
|
5
|
+
<scripts>
|
|
6
|
+
<script value="lint:code" />
|
|
7
|
+
</scripts>
|
|
8
|
+
<node-interpreter value="project" />
|
|
9
|
+
<package-manager value="yarn" />
|
|
10
|
+
<envs />
|
|
11
|
+
<method v="2" />
|
|
12
|
+
</configuration>
|
|
13
|
+
</component>
|
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<sourceFolder url="file://$MODULE_DIR$/__tests__" isTestSource="true" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
8
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
9
|
+
<excludeFolder url="file://$MODULE_DIR$/.yarn" />
|
|
10
|
+
</content>
|
|
11
|
+
<orderEntry type="inheritedJdk" />
|
|
12
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
13
|
+
</component>
|
|
14
|
+
</module>
|
package/.prettierrc
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "typescript",
|
|
3
|
+
"tabWidth": 2,
|
|
4
|
+
"singleQuote": true,
|
|
5
|
+
"jsxSingleQuote": true,
|
|
6
|
+
"semi": true,
|
|
7
|
+
"useTabs": false,
|
|
8
|
+
"arrowParens": "avoid",
|
|
9
|
+
"singleAttributePerLine": true,
|
|
10
|
+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
|
|
11
|
+
"importOrder": [
|
|
12
|
+
"<THIRD_PARTY_MODULES>",
|
|
13
|
+
"^@/(.*)$",
|
|
14
|
+
"^@test/(.*)$",
|
|
15
|
+
"^../(.*)$",
|
|
16
|
+
"^./(.*)$"
|
|
17
|
+
],
|
|
18
|
+
"importOrderSeparation": true,
|
|
19
|
+
"importOrderSortSpecifiers": true
|
|
20
|
+
}
|
package/.yarnrc
ADDED
package/README.md
ADDED
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect } from 'vitest';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Deeply checks if two objects are equal.
|
|
5
|
+
*
|
|
6
|
+
* @param expected
|
|
7
|
+
* @param real
|
|
8
|
+
*/
|
|
9
|
+
export const expectToDeepEqual = <Type>(
|
|
10
|
+
expected: Type,
|
|
11
|
+
real: NoInfer<Type>,
|
|
12
|
+
) => {
|
|
13
|
+
expect(expected).to.deep.equal(real);
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { render, renderHook } from '@testing-library/react';
|
|
2
|
+
|
|
3
|
+
import { assertNotThrowing } from '@test/assets';
|
|
4
|
+
|
|
5
|
+
type RenderArguments = Parameters<typeof render>;
|
|
6
|
+
type RenderHookArguments = Parameters<typeof renderHook>;
|
|
7
|
+
|
|
8
|
+
type RenderFunc<Args extends unknown[] = RenderArguments> = (
|
|
9
|
+
...args: Args
|
|
10
|
+
) => void;
|
|
11
|
+
|
|
12
|
+
/** Renders component and expects that it won't throw error. */
|
|
13
|
+
export const expectToRender: RenderFunc = (...props) => {
|
|
14
|
+
assertNotThrowing(() => render(...props));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renders hook within test React component without having to create that component yourself.
|
|
19
|
+
* Expects that it won't throw error.
|
|
20
|
+
* @param props
|
|
21
|
+
*/
|
|
22
|
+
export const expectHookToRender: RenderFunc<RenderHookArguments> = (
|
|
23
|
+
...props
|
|
24
|
+
) => {
|
|
25
|
+
assertNotThrowing(() => renderHook(...props));
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './assertions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './parseVersion.data';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { VersionData } from '@/utils';
|
|
2
|
+
|
|
3
|
+
export const testCases: Array<VersionData & { input: string }> = [
|
|
4
|
+
{
|
|
5
|
+
input: 'Random string',
|
|
6
|
+
version: null,
|
|
7
|
+
preid: undefined,
|
|
8
|
+
prerelease: undefined,
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
input: '0.0.0',
|
|
12
|
+
version: '0.0.0',
|
|
13
|
+
prerelease: undefined,
|
|
14
|
+
preid: undefined,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
input: '0.0.0-alpha.0',
|
|
18
|
+
version: '0.0.0',
|
|
19
|
+
preid: 'alpha',
|
|
20
|
+
prerelease: '0',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
input: '0.0.0-beta.0',
|
|
24
|
+
version: '0.0.0',
|
|
25
|
+
preid: 'beta',
|
|
26
|
+
prerelease: '0',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
input: '0.0.0-rc.0',
|
|
30
|
+
version: '0.0.0',
|
|
31
|
+
preid: 'rc',
|
|
32
|
+
prerelease: '0',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
input: '0.0.0-rc.1',
|
|
36
|
+
version: '0.0.0',
|
|
37
|
+
preid: 'rc',
|
|
38
|
+
prerelease: '1',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
input: '0.0.0-rc.25',
|
|
42
|
+
version: '0.0.0',
|
|
43
|
+
preid: 'rc',
|
|
44
|
+
prerelease: '25',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
input: '0.0.0-canary.0',
|
|
48
|
+
version: '0.0.0',
|
|
49
|
+
preid: 'canary',
|
|
50
|
+
prerelease: '0',
|
|
51
|
+
},
|
|
52
|
+
];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import type { PackageJson } from 'type-fest';
|
|
4
|
+
import { afterEach, describe, expect, test } from 'vitest';
|
|
5
|
+
|
|
6
|
+
import { PathBuilder } from '@/cli-tools';
|
|
7
|
+
|
|
8
|
+
const findPackageJson = async (res: string) => {
|
|
9
|
+
const packageJsonText = await readFile(path.join(res, 'package.json'), {
|
|
10
|
+
encoding: 'utf-8',
|
|
11
|
+
});
|
|
12
|
+
const packageJson = JSON.parse(packageJsonText) as PackageJson;
|
|
13
|
+
|
|
14
|
+
expect(packageJson.name).toBe('xenopomp-essentials');
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe('PathBuilder class', () => {
|
|
18
|
+
const builder = new PathBuilder();
|
|
19
|
+
|
|
20
|
+
afterEach(() => builder.clear());
|
|
21
|
+
|
|
22
|
+
test('cwd method works', async () => {
|
|
23
|
+
await findPackageJson(builder.cwd().build());
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
test('appSource method works', async () => {
|
|
27
|
+
await findPackageJson(builder.appSource().build());
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('cd method works', async () => {
|
|
31
|
+
const res = builder.cd('./src').cd('../').build();
|
|
32
|
+
await findPackageJson(res);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('file method works', () => {
|
|
36
|
+
const res = builder.cd('./src').cd('../').file('.prettierrc').build();
|
|
37
|
+
expect(res.endsWith('.prettierrc')).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FC, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
import { jsxDotNotation } from '@/react';
|
|
4
|
+
|
|
5
|
+
const FlexComp: FC<PropsWithChildren> = ({ children }) => <div>{children}</div>;
|
|
6
|
+
const FlexRow: FC<PropsWithChildren & { short?: boolean }> = ({ children }) => (
|
|
7
|
+
<div>{children}</div>
|
|
8
|
+
);
|
|
9
|
+
const FlexCol: FC<PropsWithChildren> = ({ children }) => <div>{children}</div>;
|
|
10
|
+
|
|
11
|
+
export const Flex = jsxDotNotation(FlexComp, {
|
|
12
|
+
Row: FlexRow,
|
|
13
|
+
Col: FlexCol,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const Am = () => {
|
|
17
|
+
return (
|
|
18
|
+
<Flex>
|
|
19
|
+
<Flex.Row short>
|
|
20
|
+
<Flex.Col></Flex.Col>
|
|
21
|
+
</Flex.Row>
|
|
22
|
+
</Flex>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cleanup } from '@testing-library/react';
|
|
2
|
+
import { afterAll, describe, test } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { Metrika } from '@/next';
|
|
5
|
+
|
|
6
|
+
import { expectToRender } from '@test/assets';
|
|
7
|
+
|
|
8
|
+
describe('Yandex.Metrika script component', () => {
|
|
9
|
+
test('It renders', () => {
|
|
10
|
+
afterAll(() => cleanup());
|
|
11
|
+
|
|
12
|
+
expectToRender(<Metrika id={-1} />);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { describe, test } from 'vitest';
|
|
3
|
+
|
|
4
|
+
import { ReactScan } from '@/next';
|
|
5
|
+
|
|
6
|
+
import { expectToRender } from '@test/assets';
|
|
7
|
+
|
|
8
|
+
describe('react-scan script', () => {
|
|
9
|
+
test('It renders', () => expectToRender(<ReactScan />));
|
|
10
|
+
});
|