xenopomp-essentials 0.3.3 → 0.3.4-hotfix.1

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.
Files changed (143) hide show
  1. package/cli-tools/index.d.mts +60 -0
  2. package/cli-tools/index.d.ts +60 -0
  3. package/cli-tools/index.mjs +1 -0
  4. package/eslint/index.d.mts +39 -0
  5. package/eslint/index.d.ts +39 -0
  6. package/eslint/index.mjs +3 -0
  7. package/index.d.mts +613 -0
  8. package/index.d.ts +613 -0
  9. package/index.mjs +1 -0
  10. package/next/index.d.mts +67 -0
  11. package/next/index.d.ts +67 -0
  12. package/next/index.mjs +11 -0
  13. package/package.json +5 -3
  14. package/.config/.lintstagedrc.json +0 -3
  15. package/.config/build.config.ts +0 -41
  16. package/.config/testing-exclusions/index.ts +0 -2
  17. package/.config/testing-exclusions/istanbul-exclusions.ts +0 -1
  18. package/.config/testing-exclusions/vitest-exclusions.ts +0 -8
  19. package/.config/ts/tsconfig.lint.json +0 -10
  20. package/.config/vitest.config.ts +0 -18
  21. package/.gitattributes +0 -25
  22. package/.github/workflows/ci.yml +0 -54
  23. package/.github/workflows/npm-publish.yml +0 -27
  24. package/.husky/pre-commit +0 -1
  25. package/.idea/codeStyles/Project.xml +0 -59
  26. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  27. package/.idea/inspectionProfiles/Project_Default.xml +0 -6
  28. package/.idea/modules.xml +0 -8
  29. package/.idea/prettier.xml +0 -7
  30. package/.idea/runConfigurations/_template__of_Vitest.xml +0 -9
  31. package/.idea/runConfigurations/build.xml +0 -13
  32. package/.idea/runConfigurations/coverage.xml +0 -12
  33. package/.idea/runConfigurations/lint.xml +0 -13
  34. package/.idea/runConfigurations/lint_code.xml +0 -13
  35. package/.idea/vcs.xml +0 -6
  36. package/.idea/xenopomp-essentials-js.iml +0 -14
  37. package/.prettierrc +0 -20
  38. package/.yarnrc +0 -2
  39. package/README.md +0 -0
  40. package/__tests__/assets/assertions/expect-deep-equal.ts +0 -14
  41. package/__tests__/assets/assertions/expect-to-render.ts +0 -26
  42. package/__tests__/assets/assertions/index.ts +0 -3
  43. package/__tests__/assets/assertions/not-throwing.ts +0 -6
  44. package/__tests__/assets/index.ts +0 -1
  45. package/__tests__/data/index.ts +0 -1
  46. package/__tests__/data/parseVersion.data.ts +0 -52
  47. package/__tests__/unit/cli/path-builder.test.ts +0 -39
  48. package/__tests__/unit/components/hoc/jsx-dot-notation/component.test-source.tsx +0 -24
  49. package/__tests__/unit/components/hoc/jsx-dot-notation/hoc.test.tsx +0 -11
  50. package/__tests__/unit/components/metrika.test.tsx +0 -14
  51. package/__tests__/unit/components/react-scan.test.tsx +0 -10
  52. package/__tests__/unit/eslint/config.test.tsx +0 -41
  53. package/__tests__/unit/utils/capitalize.test.ts +0 -17
  54. package/__tests__/unit/utils/minmax.test.ts +0 -21
  55. package/__tests__/unit/utils/parseVersion.test.ts +0 -22
  56. package/__tests__/unit/utils/pipe.test.ts +0 -23
  57. package/__tests__/unit/utils/transliterate.test.ts +0 -17
  58. package/_templates/generator/help/index.ejs.t +0 -5
  59. package/_templates/generator/new/hello.ejs.t +0 -18
  60. package/_templates/generator/with-prompt/hello.ejs.t +0 -18
  61. package/_templates/generator/with-prompt/prompt.ejs.t +0 -14
  62. package/_templates/init/repo/new-repo.ejs.t +0 -4
  63. package/_templates/type/new/module.ejs.t +0 -7
  64. package/_templates/type/new/type.ejs.t +0 -7
  65. package/_templates/util/new/func.ejs.t +0 -7
  66. package/_templates/util/new/module.ejs.t +0 -7
  67. package/_templates/util/new/test.ejs.t +0 -13
  68. package/eslint.config.ts +0 -17
  69. package/src/cli-tools/changeFile.ts +0 -1
  70. package/src/cli-tools/index.ts +0 -2
  71. package/src/cli-tools/pathBuilder.ts +0 -89
  72. package/src/eslint/config.ts +0 -145
  73. package/src/eslint/configs/all.ts +0 -74
  74. package/src/eslint/configs/deprecation.ts +0 -33
  75. package/src/eslint/configs/index.ts +0 -7
  76. package/src/eslint/configs/markdown.ts +0 -30
  77. package/src/eslint/configs/next.ts +0 -40
  78. package/src/eslint/configs/old.ts +0 -67
  79. package/src/eslint/configs/prettier.ts +0 -6
  80. package/src/eslint/configs/react.ts +0 -18
  81. package/src/eslint/index.ts +0 -7
  82. package/src/eslint/prefixes/author.ts +0 -2
  83. package/src/eslint/prefixes/index.ts +0 -1
  84. package/src/eslint/types/configs.ts +0 -4
  85. package/src/eslint/types/custom-config.ts +0 -4
  86. package/src/eslint/types/index.ts +0 -2
  87. package/src/index.ts +0 -3
  88. package/src/next/Metrika/Metrika.props.ts +0 -11
  89. package/src/next/Metrika/Metrika.tsx +0 -56
  90. package/src/next/ReactScan/ReactScan.tsx +0 -33
  91. package/src/next/index.ts +0 -2
  92. package/src/react/hoc/index.ts +0 -1
  93. package/src/react/hoc/jsxDotNotation.tsx +0 -38
  94. package/src/react/index.ts +0 -1
  95. package/src/repo-eslint-rules/deep-type-naming.rule.ts +0 -49
  96. package/src/repo-eslint-rules/index.ts +0 -9
  97. package/src/schemas/import-meta.schema.ts +0 -12
  98. package/src/schemas/index.ts +0 -1
  99. package/src/types/aliases/AnyObject.ts +0 -5
  100. package/src/types/aliases/EmptyObject.ts +0 -8
  101. package/src/types/aliases/Fn.ts +0 -12
  102. package/src/types/aliases/index.ts +0 -3
  103. package/src/types/index.ts +0 -4
  104. package/src/types/next/NextParams.ts +0 -26
  105. package/src/types/next/index.ts +0 -1
  106. package/src/types/react/AnyFc.ts +0 -6
  107. package/src/types/react/AsyncFC.ts +0 -16
  108. package/src/types/react/DataAttributes.ts +0 -21
  109. package/src/types/react/FCProps.ts +0 -19
  110. package/src/types/react/FunctionalChildren.ts +0 -13
  111. package/src/types/react/SetState.ts +0 -11
  112. package/src/types/react/VariableFC.ts +0 -48
  113. package/src/types/react/VariableProps.ts +0 -9
  114. package/src/types/react/index.ts +0 -8
  115. package/src/types/utilities/ArrayType.ts +0 -12
  116. package/src/types/utilities/AsyncReturnType.ts +0 -14
  117. package/src/types/utilities/DeepInject.ts +0 -22
  118. package/src/types/utilities/Defined.ts +0 -5
  119. package/src/types/utilities/Jsonish.ts +0 -11
  120. package/src/types/utilities/LenientAutocomplete.ts +0 -24
  121. package/src/types/utilities/MatchType.ts +0 -26
  122. package/src/types/utilities/MergeTypes.ts +0 -12
  123. package/src/types/utilities/Modify.ts +0 -10
  124. package/src/types/utilities/Nullable.ts +0 -5
  125. package/src/types/utilities/OneOf.ts +0 -42
  126. package/src/types/utilities/Prettify.ts +0 -15
  127. package/src/types/utilities/RecordKey.ts +0 -9
  128. package/src/types/utilities/RecordValue.ts +0 -9
  129. package/src/types/utilities/ReplaceReturnType.ts +0 -10
  130. package/src/types/utilities/SelectivePartial.ts +0 -17
  131. package/src/types/utilities/StrictOmit.ts +0 -19
  132. package/src/types/utilities/Synchronous.ts +0 -18
  133. package/src/types/utilities/Undefinable.ts +0 -5
  134. package/src/types/utilities/WeakOmit.ts +0 -17
  135. package/src/types/utilities/Writeable.ts +0 -18
  136. package/src/types/utilities/index.ts +0 -24
  137. package/src/utils/capitalize.ts +0 -15
  138. package/src/utils/index.ts +0 -7
  139. package/src/utils/minmax.ts +0 -35
  140. package/src/utils/parseVersion.ts +0 -42
  141. package/src/utils/pipe.ts +0 -29
  142. package/src/utils/transliterate.ts +0 -8
  143. package/tsconfig.json +0 -43
@@ -1,39 +0,0 @@
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
- });
@@ -1,24 +0,0 @@
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
- };
@@ -1,11 +0,0 @@
1
- import { describe, test } from 'vitest';
2
-
3
- import { expectToRender } from '@test/assets';
4
-
5
- import { Am } from './component.test-source';
6
-
7
- describe('jsxDotNotation HOC', () => {
8
- test('It renders', () => {
9
- expectToRender(<Am />);
10
- });
11
- });
@@ -1,14 +0,0 @@
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
- });
@@ -1,10 +0,0 @@
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
- });
@@ -1,41 +0,0 @@
1
- import { expectType } from 'tsd';
2
- import { describe, expect, test } from 'vitest';
3
-
4
- import type { Configs, Options, UserConfigItem } from '@/eslint';
5
- import xenopomp from '@/eslint';
6
- import { next } from '@/eslint/configs';
7
- import type { Fn } from '@/types';
8
-
9
- import { assertNotThrowing } from '@test/assets';
10
-
11
- type ExpectedType = Fn<
12
- [options?: Options, ...userConfigs: UserConfigItem[]],
13
- Configs
14
- >;
15
-
16
- describe('xenopomp ESLint config', () => {
17
- test('Expected types are not any', () => {
18
- expectType<ExpectedType>(xenopomp);
19
- });
20
-
21
- test('It does not throw', () => {
22
- assertNotThrowing(() => xenopomp());
23
-
24
- assertNotThrowing(() =>
25
- xenopomp({
26
- react: undefined,
27
- }),
28
- );
29
-
30
- assertNotThrowing(() =>
31
- xenopomp({
32
- next: true,
33
- }),
34
- );
35
- });
36
-
37
- test('Next.js integration', async () => {
38
- const config = await next();
39
- expect(config.length).toBeGreaterThan(0);
40
- });
41
- });
@@ -1,17 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
-
3
- import { capitalize, uncapitalize } from '@/utils';
4
-
5
- describe('Capitalize/uncapitalize utilities', () => {
6
- test('Capitalize works', () => {
7
- const og = 'alex';
8
- const cap = capitalize(og);
9
- expect(cap).toBe('Alex');
10
- });
11
-
12
- test('Uncapitalize works', () => {
13
- const og = 'Alex';
14
- const cap = uncapitalize(og);
15
- expect(cap).toBe('alex');
16
- });
17
- });
@@ -1,21 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
-
3
- import { minmax } from '@/utils';
4
-
5
- describe('minmax util', () => {
6
- test('Min value', () => {
7
- expect(minmax(1, [2, undefined])).toBe(2);
8
- });
9
-
10
- test('Max value', () => {
11
- expect(minmax(1001, [undefined, 900])).toBe(900);
12
- });
13
-
14
- test('Min/Max', () => {
15
- const constraint = (num: number) => minmax(num, [100, 500]);
16
-
17
- expect(constraint(1)).toBe(100);
18
- expect(constraint(352)).toBe(352);
19
- expect(constraint(1000)).toBe(500);
20
- });
21
- });
@@ -1,22 +0,0 @@
1
- import { describe, test } from 'vitest';
2
-
3
- import { parseVersion } from '@/utils';
4
- import type { VersionData } from '@/utils';
5
-
6
- import { assertNotThrowing, expectToDeepEqual } from '@test/assets';
7
- import { testCases } from '@test/data';
8
-
9
- describe('parseVersion util', () => {
10
- const testParseVersion = (raw: string, expected: VersionData) => {
11
- expectToDeepEqual(parseVersion(raw), expected);
12
- };
13
-
14
- test('It does not throw', () => assertNotThrowing(() => parseVersion('')));
15
-
16
- test.each(testCases)(
17
- 'Test case: input=$input, version=$version, preid=$preid, prerelease=$prerelease',
18
- ({ input, ...versionData }) => {
19
- testParseVersion(input, versionData);
20
- },
21
- );
22
- });
@@ -1,23 +0,0 @@
1
- import { expectAssignable } from 'tsd';
2
- import { describe, test } from 'vitest';
3
-
4
- import { pipe } from '@/utils';
5
-
6
- import { assertNotThrowing } from '@test/assets';
7
-
8
- describe('Pipe function', () => {
9
- const testFn = pipe(Date.parse)
10
- .pipe(n => new Date(n))
11
- .pipe(d => d.toDateString())
12
- .pipe(s => s.split('T'))
13
- .pipe(([date, time]) => ({ date, time }));
14
-
15
- test('It won`t throw', () => {
16
- assertNotThrowing(() => testFn('Jan 1, 2024'));
17
- });
18
-
19
- test('Type inference works just fine', () => {
20
- const date = testFn('Jan 1, 2024');
21
- expectAssignable<{ date?: string; time?: string }>(date);
22
- });
23
- });
@@ -1,17 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
-
3
- import { transliterate } from '@/utils';
4
-
5
- import { assertNotThrowing } from '@test/assets';
6
-
7
- describe('transliterate util', () => {
8
- test('It does not throw', () =>
9
- assertNotThrowing(() => transliterate('Я русский')));
10
-
11
- test('It correctly transliterates text', () => {
12
- expect(transliterate('Я русский')).toBe('Ya russkiy');
13
- expect(transliterate('Ya betonovaya милашка')).toBe(
14
- 'Ya betonovaya milashka',
15
- );
16
- });
17
- });
@@ -1,5 +0,0 @@
1
- ---
2
- message: |
3
- hygen {bold generator new} --name [NAME] --action [ACTION]
4
- hygen {bold generator with-prompt} --name [NAME] --action [ACTION]
5
- ---
@@ -1,18 +0,0 @@
1
- ---
2
- to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t
3
- ---
4
- ---
5
- to: app/hello.js
6
- ---
7
- const hello = ```
8
- Hello!
9
- This is your first hygen template.
10
-
11
- Learn what it can do here:
12
-
13
- https://github.com/jondot/hygen
14
- ```
15
-
16
- console.log(hello)
17
-
18
-
@@ -1,18 +0,0 @@
1
- ---
2
- to: _templates/<%= name %>/<%= action || 'new' %>/hello.ejs.t
3
- ---
4
- ---
5
- to: app/hello.js
6
- ---
7
- const hello = ```
8
- Hello!
9
- This is your first prompt based hygen template.
10
-
11
- Learn what it can do here:
12
-
13
- https://github.com/jondot/hygen
14
- ```
15
-
16
- console.log(hello)
17
-
18
-
@@ -1,14 +0,0 @@
1
- ---
2
- to: _templates/<%= name %>/<%= action || 'new' %>/prompt.js
3
- ---
4
-
5
- // see types of prompts:
6
- // https://github.com/enquirer/enquirer/tree/master/examples
7
- //
8
- module.exports = [
9
- {
10
- type: 'input',
11
- name: 'message',
12
- message: "What's your message?"
13
- }
14
- ]
@@ -1,4 +0,0 @@
1
- ---
2
- setup: <%= name %>
3
- force: true # this is because mostly, people init into existing folders is safe
4
- ---
@@ -1,7 +0,0 @@
1
- ---
2
- to: src/types/<%= at %>/index.ts
3
- inject: true
4
- append: true
5
- skip_if: <%= h.changeCase.pascalCase(name) %>
6
- ---
7
- export * from './<%= h.changeCase.pascalCase(name) %>';
@@ -1,7 +0,0 @@
1
- ---
2
- to: src/types/<%= at %>/<%= h.changeCase.pascalCase(name) %>.ts
3
- ---
4
- /**
5
- * @TODO
6
- */
7
- export type <%= h.changeCase.pascalCase(name) %> = unknown;
@@ -1,7 +0,0 @@
1
- ---
2
- to: src/utils/<%= h.changeCase.camelCase(name) %>.ts
3
- ---
4
- /**
5
- * @TODO
6
- */
7
- export function <%= h.changeCase.camelCase(name) %>() {}
@@ -1,7 +0,0 @@
1
- ---
2
- to: src/utils/index.ts
3
- inject: true
4
- append: true
5
- skip_if: <%= h.changeCase.camelCase(name) %>
6
- ---
7
- export * from './<%= h.changeCase.camelCase(name) %>';
@@ -1,13 +0,0 @@
1
- ---
2
- to: __tests__/unit/utils/<%= h.changeCase.camelCase(name) %>.test.ts
3
- ---
4
- import { describe, test } from 'vitest';
5
-
6
- import { <%= h.changeCase.camelCase(name) %> } from '@/utils';
7
-
8
- import { assertNotThrowing } from '@test/assets';
9
-
10
- describe('<%= h.changeCase.camelCase(name) %> util', () => {
11
- test('It does not throw', () => assertNotThrowing(() => <%= h.changeCase.camelCase(name) %>()));
12
- });
13
-
package/eslint.config.ts DELETED
@@ -1,17 +0,0 @@
1
- import xenopomp from './src/eslint';
2
- import repoEslintPlugin from './src/repo-eslint-rules';
3
-
4
- export default xenopomp(
5
- {
6
- deprecation: 'warn',
7
- tsconfigPath: './.config/ts/tsconfig.lint.json',
8
- },
9
- {
10
- plugins: {
11
- repo: repoEslintPlugin,
12
- },
13
- rules: {
14
- 'repo/deep-type-naming': 'warn',
15
- },
16
- },
17
- );
@@ -1 +0,0 @@
1
- // export function changeFile() {}
@@ -1,2 +0,0 @@
1
- // export * from './changeFile';
2
- export * from './pathBuilder';
@@ -1,89 +0,0 @@
1
- import path from 'node:path';
2
-
3
- import { importMeta } from '@/schemas';
4
-
5
- /**
6
- * Fluent interface for creating paths of application.
7
- *
8
- * @since 0.0.1
9
- *
10
- * @example
11
- * import { PathBuilder } from 'xenopomp-essentials/cli-tools';
12
- *
13
- * const builder = new PathBuilder();
14
- *
15
- * const res = builder
16
- * .appSource()
17
- * .cd('./dist/src')
18
- * .file('.prettierrc')
19
- * .build();
20
- *
21
- * console.log(res); //? C:/Projects/example/node_modules/xenopomp-essentials/dist/src/.prettierrc
22
- */
23
- export class PathBuilder {
24
- private paths: string[] = [];
25
-
26
- private pushPaths(...paths: string[]): PathBuilder {
27
- this.paths.push(...paths);
28
- return this;
29
- }
30
-
31
- /**
32
- * Pushes any custom paths to builder.
33
- * @since 0.0.1
34
- * @param paths
35
- */
36
- cd(...paths: string[]) {
37
- return this.pushPaths(...paths);
38
- }
39
-
40
- /**
41
- * Pushes filename to paths.
42
- * @since 0.0.1
43
- * @param fileName
44
- */
45
- file<T extends `${string}.${string}`>(fileName: T) {
46
- return this.pushPaths(`./${fileName}`);
47
- }
48
-
49
- /**
50
- * Pushes path to compiled app directory.
51
- * Is useful for cli tools that have to access files inside their bundles.
52
- *
53
- * It probably may take no effect (if import.meta is not available in a scope).
54
- * If it is, will push cwd.
55
- *
56
- * @since 0.0.1
57
- */
58
- appSource(): PathBuilder {
59
- if (!importMeta.dirname) {
60
- return this.cwd();
61
- }
62
-
63
- return this.pushPaths(path.join(path.dirname(importMeta.dirname), '../'));
64
- }
65
-
66
- /**
67
- * Gets path of directory where script is running. In cli tools it access
68
- * path, where cli tool was started.
69
- * @since 0.0.1
70
- */
71
- cwd(): PathBuilder {
72
- return this.pushPaths(process.cwd());
73
- }
74
-
75
- /**
76
- * @since 0.0.1
77
- */
78
- clear(): PathBuilder {
79
- this.paths = [];
80
- return this;
81
- }
82
-
83
- /**
84
- * @since 0.0.1
85
- */
86
- build(): string {
87
- return path.join(...this.paths);
88
- }
89
- }
@@ -1,145 +0,0 @@
1
- import type {
2
- Awaitable,
3
- OptionsConfig,
4
- TypedFlatConfigItem,
5
- } from '@antfu/eslint-config';
6
- import { antfu } from '@antfu/eslint-config';
7
- import { deepmerge } from 'deepmerge-ts';
8
- import type { Linter } from 'eslint';
9
-
10
- import type { Undefinable } from '@/types';
11
-
12
- import {
13
- all,
14
- deprecation,
15
- markdown,
16
- next,
17
- old,
18
- prettier,
19
- react,
20
- } from './configs';
21
- import type { Configs, CustomConfig, UserConfigItem } from './types';
22
-
23
- interface CustomOptions {
24
- deprecation?: Linter.RuleEntry;
25
- tsconfigPath?: string;
26
- }
27
- export type Options = OptionsConfig &
28
- CustomConfig &
29
- TypedFlatConfigItem &
30
- CustomOptions;
31
-
32
- /**
33
- * XenoPOMP`s default ESLint config. Uses @antfu/eslint-config under the hood.
34
- *
35
- * @param options
36
- * @param userConfigs
37
- *
38
- * @example
39
- * export default xenopomp(
40
- * // Setup antfu config
41
- * {
42
- * react: true,
43
- * next: false,
44
- * },
45
- * // User configs
46
- * {
47
- * name: 'My custom config',
48
- * rules: { ... }
49
- * },
50
- * );
51
- */
52
- export default function xenopomp(
53
- options?: Options,
54
- ...userConfigs: UserConfigItem[]
55
- ): Configs {
56
- const configs: Awaitable<TypedFlatConfigItem[]>[] = [];
57
-
58
- options = {
59
- ...options,
60
- react: deepmerge<
61
- [Undefinable<Options['react']>, Undefinable<Options['react']>]
62
- >(true, options?.react),
63
-
64
- vue: deepmerge<[Undefinable<Options['vue']>, Undefinable<Options['vue']>]>(
65
- false,
66
- options?.vue,
67
- ),
68
-
69
- jsonc: deepmerge<
70
- [Undefinable<Options['jsonc']>, Undefinable<Options['jsonc']>]
71
- >(false, options?.jsonc),
72
-
73
- yaml: deepmerge<
74
- [Undefinable<Options['yaml']>, Undefinable<Options['yaml']>]
75
- >(false, options?.yaml),
76
-
77
- stylistic: deepmerge<
78
- [Undefinable<Options['stylistic']>, Undefinable<Options['stylistic']>]
79
- >(
80
- {
81
- semi: true,
82
- quotes: 'single',
83
- },
84
- options?.stylistic,
85
- ),
86
-
87
- typescript: deepmerge<
88
- [Undefinable<Options['typescript']>, Undefinable<Options['typescript']>]
89
- >(
90
- {
91
- overrides: {
92
- 'ts/consistent-type-definitions': ['error', 'interface'],
93
- 'ts/interface-name-prefix': 'off',
94
- 'ts/explicit-function-return-type': 'off',
95
- 'ts/explicit-module-boundary-types': 'off',
96
- 'ts/no-explicit-any': 'off',
97
- },
98
- },
99
- options?.typescript,
100
- ),
101
-
102
- rules: deepmerge<
103
- [Undefinable<Options['rules']>, Undefinable<Options['rules']>]
104
- >(
105
- {
106
- 'import/order': 'off',
107
- 'react/react-in-jsx-scope': 'off',
108
- 'react/prop-types': 'off',
109
- 'antfu/top-level-function': 'off',
110
- 'perfectionist/sort-imports': 'off',
111
- 'perfectionist/sort-named-imports': 'off',
112
- 'perfectionist/sort-named-exports': 'off',
113
- 'antfu/consistent-chaining': 'off',
114
- 'perfectionist/sort-exports': 'off',
115
- 'style/no-multiple-empty-lines': 'off',
116
- },
117
- options?.rules,
118
- ),
119
-
120
- deprecation: options?.deprecation,
121
- tsconfigPath: options?.tsconfigPath,
122
- } satisfies Options;
123
-
124
- if (options.react ?? true) configs.push(react());
125
-
126
- if (options.all ?? true) configs.push(all());
127
-
128
- if (options.next ?? false) configs.push(next());
129
-
130
- if (options.markdown ?? true) configs.push(markdown());
131
-
132
- if (options?.deprecation) {
133
- configs.push(
134
- deprecation(options?.deprecation ?? 'warn', {
135
- tsconfigPath: options?.tsconfigPath,
136
- }),
137
- );
138
- }
139
-
140
- // Apply other configs
141
- configs.push(old());
142
- configs.push(prettier());
143
-
144
- return antfu(options, ...configs, ...userConfigs);
145
- }