@livon/config 0.27.0-rc.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.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # @livon/config Redirect
2
+
3
+ Canonical source moved to Docusaurus:
4
+
5
+ - `/docs/packages/config`
6
+ - File source: `website/docs/packages/config.md`
7
+
8
+ This file is a compatibility redirect only.
@@ -0,0 +1,7 @@
1
+ # @livon/config/eslint Redirect
2
+
3
+ Canonical source moved to Docusaurus:
4
+
5
+ - `/docs/packages/config`
6
+
7
+ This file is a compatibility redirect only.
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Shared ESLint base config exported by `@livon/config/eslint/base.cjs`.
3
+ *
4
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
5
+ */
6
+ module.exports = [
7
+ {
8
+ ignores: ["dist", "build", "coverage", "node_modules"],
9
+ },
10
+ {
11
+ files: ["**/*.ts", "**/*.tsx"],
12
+ languageOptions: {
13
+ parser: require("@typescript-eslint/parser"),
14
+ parserOptions: {
15
+ ecmaVersion: "latest",
16
+ sourceType: "module",
17
+ },
18
+ },
19
+ plugins: {
20
+ "@typescript-eslint": require("@typescript-eslint/eslint-plugin"),
21
+ },
22
+ rules: {
23
+ "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
24
+ "@typescript-eslint/no-explicit-any": "error",
25
+ "@typescript-eslint/consistent-type-definitions": ["warn", "interface"],
26
+ "no-var": "error",
27
+ "prefer-const": "error",
28
+ "prefer-object-spread": "error",
29
+ "max-params": ["warn", 2],
30
+ "func-style": ["warn", "expression", { "allowArrowFunctions": true }],
31
+ "no-restricted-syntax": [
32
+ "error",
33
+ {
34
+ selector: "ForStatement",
35
+ message: "Use declarative array methods instead of for-loops.",
36
+ },
37
+ {
38
+ selector: "ForInStatement",
39
+ message: "Use Object.entries/keys with declarative methods instead of for..in.",
40
+ },
41
+ {
42
+ selector: "ForOfStatement",
43
+ message: "Use declarative array methods instead of for..of.",
44
+ },
45
+ {
46
+ selector: "WhileStatement",
47
+ message: "Use recursion or declarative iteration instead of while.",
48
+ },
49
+ {
50
+ selector: "DoWhileStatement",
51
+ message: "Use recursion or declarative iteration instead of do..while.",
52
+ },
53
+ {
54
+ selector: "ClassDeclaration",
55
+ message: "Use functional modules and data, not classes.",
56
+ },
57
+ {
58
+ selector: "ClassExpression",
59
+ message: "Use functional modules and data, not classes.",
60
+ },
61
+ {
62
+ selector: "ThisExpression",
63
+ message: "Do not use this; pass explicit inputs through parameters/closures.",
64
+ },
65
+ ]
66
+ }
67
+ }
68
+ ];
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@livon/config",
3
+ "version": "0.27.0-rc.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "publishConfig": {
7
+ "access": "public"
8
+ },
9
+ "files": [
10
+ "README.md",
11
+ "eslint",
12
+ "rsbuild",
13
+ "rslib",
14
+ "rspack",
15
+ "swc",
16
+ "tsconfig",
17
+ "vitest"
18
+ ],
19
+ "exports": {
20
+ "./tsconfig/base.json": "./tsconfig/base.json",
21
+ "./tsconfig/library.json": "./tsconfig/library.json",
22
+ "./tsconfig/app.json": "./tsconfig/app.json",
23
+ "./eslint/base.cjs": "./eslint/base.cjs",
24
+ "./swc/base.json": "./swc/base.json",
25
+ "./rspack/base": "./rspack/base.ts",
26
+ "./rsbuild/base": "./rsbuild/base.ts",
27
+ "./rslib/base": "./rslib/base.ts",
28
+ "./vitest/base": "./vitest/base.ts",
29
+ "./vitest/base.cjs": "./vitest/base.cjs"
30
+ },
31
+ "scripts": {
32
+ "build": "true",
33
+ "build:watch": "true",
34
+ "dev": "true",
35
+ "lint": "true",
36
+ "typecheck": "true",
37
+ "test": "true",
38
+ "test:unit": "true",
39
+ "test:integration": "true"
40
+ }
41
+ }
@@ -0,0 +1,7 @@
1
+ # @livon/config/rsbuild Redirect
2
+
3
+ Canonical source moved to Docusaurus:
4
+
5
+ - `/docs/packages/config`
6
+
7
+ This file is a compatibility redirect only.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Shared Rsbuild base config helpers exported by `@livon/config`.
3
+ *
4
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
5
+ */
6
+ import { defineConfig } from '@rsbuild/core';
7
+ import { pluginReact } from '@rsbuild/plugin-react';
8
+
9
+ /**
10
+ * Creates a reusable React-focused Rsbuild configuration.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { createRsbuildReactConfig } from '@livon/config/rsbuild';
15
+ *
16
+ * export default createRsbuildReactConfig({
17
+ * entry: './src/index.tsx',
18
+ * template: './public/index.html',
19
+ * });
20
+ * ```
21
+ *
22
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
23
+ */
24
+ export const createRsbuildReactConfig = ({
25
+ entry,
26
+ template,
27
+ }: {
28
+ entry: string;
29
+ template: string;
30
+ }) => {
31
+ return defineConfig({
32
+ dev: {
33
+ clearScreen: false,
34
+ },
35
+ plugins: [pluginReact()],
36
+ html: {
37
+ template,
38
+ },
39
+ source: {
40
+ entry: {
41
+ index: entry,
42
+ },
43
+ },
44
+ output: {
45
+ distPath: {
46
+ root: 'dist',
47
+ },
48
+ },
49
+ });
50
+ };
@@ -0,0 +1,7 @@
1
+ # @livon/config/rslib Redirect
2
+
3
+ Canonical source moved to Docusaurus:
4
+
5
+ - `/docs/packages/config`
6
+
7
+ This file is a compatibility redirect only.
package/rslib/base.ts ADDED
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Shared Rslib base config helpers exported by `@livon/config`.
3
+ *
4
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
5
+ */
6
+ import { defineConfig, type ConfigParams } from '@rslib/core';
7
+
8
+ type RslibTarget = 'node' | 'web';
9
+ type RslibFormat = 'esm' | 'cjs';
10
+
11
+ interface CreateRslibConfigInput {
12
+ target: RslibTarget;
13
+ formats: ReadonlyArray<RslibFormat>;
14
+ }
15
+
16
+ interface ResolveFormatsInput {
17
+ command: ConfigParams['command'];
18
+ formats: ReadonlyArray<RslibFormat>;
19
+ }
20
+
21
+ const resolveFormats = ({ command, formats }: ResolveFormatsInput): ReadonlyArray<RslibFormat> => {
22
+ if (command !== 'dev') {
23
+ return formats;
24
+ }
25
+
26
+ const devFormats = formats.filter((format) => format === 'esm');
27
+ return devFormats.length > 0 ? devFormats : formats;
28
+ };
29
+
30
+ /**
31
+ * Creates a reusable Rslib configuration with deterministic dev format selection.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { createRslibConfig } from '@livon/config/rslib';
36
+ *
37
+ * export default createRslibConfig({
38
+ * target: 'node',
39
+ * formats: ['esm', 'cjs'],
40
+ * });
41
+ * ```
42
+ *
43
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
44
+ */
45
+ export const createRslibConfig = ({ target, formats }: CreateRslibConfigInput) => {
46
+ return defineConfig(({ command }) => {
47
+ const selectedFormats = resolveFormats({ command, formats });
48
+
49
+ return {
50
+ dev: {
51
+ clearScreen: false,
52
+ },
53
+ lib: selectedFormats.map((format) => {
54
+ return {
55
+ format,
56
+ syntax: 'es2021',
57
+ dts: true,
58
+ bundle: false,
59
+ };
60
+ }),
61
+ output: {
62
+ target,
63
+ distPath: 'dist',
64
+ cleanDistPath: false,
65
+ },
66
+ };
67
+ });
68
+ };
@@ -0,0 +1,7 @@
1
+ # @livon/config/rspack Redirect
2
+
3
+ Canonical source moved to Docusaurus:
4
+
5
+ - `/docs/packages/config`
6
+
7
+ This file is a compatibility redirect only.
package/rspack/base.ts ADDED
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Shared Rspack base config helpers exported by `@livon/config`.
3
+ *
4
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
5
+ */
6
+ import { type Configuration, HtmlRspackPlugin } from '@rspack/core';
7
+ import ReactRefreshRspackPlugin from '@rspack/plugin-react-refresh';
8
+ import path from 'node:path';
9
+
10
+ /**
11
+ * Creates a reusable React-focused Rspack configuration.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { createRspackReactConfig } from '@livon/config/rspack';
16
+ *
17
+ * export default createRspackReactConfig({
18
+ * entry: './src/index.tsx',
19
+ * template: './public/index.html',
20
+ * port: 3000,
21
+ * });
22
+ * ```
23
+ *
24
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
25
+ */
26
+ export const createRspackReactConfig = ({
27
+ entry,
28
+ template,
29
+ port = 3000,
30
+ }: {
31
+ entry: string;
32
+ template: string;
33
+ port?: number;
34
+ }): Configuration => {
35
+ return {
36
+ mode: 'development',
37
+ entry: {
38
+ index: entry,
39
+ },
40
+ output: {
41
+ path: path.resolve(process.cwd(), 'dist'),
42
+ },
43
+ module: {
44
+ rules: [
45
+ {
46
+ test: /\.(t|j)sx?$/,
47
+ use: [
48
+ {
49
+ loader: 'builtin:swc-loader',
50
+ options: {
51
+ jsc: {
52
+ parser: {
53
+ syntax: 'typescript',
54
+ tsx: true,
55
+ },
56
+ transform: {
57
+ react: {
58
+ runtime: 'automatic',
59
+ refresh: true,
60
+ },
61
+ },
62
+ },
63
+ },
64
+ },
65
+ ],
66
+ },
67
+ {
68
+ test: /\.css$/,
69
+ type: 'css',
70
+ },
71
+ ],
72
+ },
73
+ resolve: {
74
+ extensions: ['.ts', '.tsx', '.js'],
75
+ },
76
+ plugins: [
77
+ new HtmlRspackPlugin({ template }),
78
+ new ReactRefreshRspackPlugin(),
79
+ ],
80
+ stats: {
81
+ logging: 'info',
82
+ },
83
+ devServer: {
84
+ port,
85
+ open: false,
86
+ hot: true,
87
+ client: {
88
+ logging: 'info',
89
+ },
90
+ },
91
+ };
92
+ };
package/swc/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @livon/config/swc Redirect
2
+
3
+ Canonical source moved to Docusaurus:
4
+
5
+ - `/docs/packages/config`
6
+
7
+ This file is a compatibility redirect only.
package/swc/base.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://swc.rs/schema.json",
3
+ "jsc": {
4
+ "parser": {
5
+ "syntax": "typescript",
6
+ "tsx": true,
7
+ "decorators": false
8
+ },
9
+ "target": "es2021",
10
+ "minify": {
11
+ "compress": false,
12
+ "mangle": false
13
+ }
14
+ },
15
+ "module": {
16
+ "type": "nodenext"
17
+ },
18
+ "sourceMaps": true
19
+ }
@@ -0,0 +1,7 @@
1
+ # @livon/config/tsconfig Redirect
2
+
3
+ Canonical source moved to Docusaurus:
4
+
5
+ - `/docs/packages/config`
6
+
7
+ This file is a compatibility redirect only.
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
6
+ "jsx": "react-jsx",
7
+ "types": [],
8
+ "noEmit": true
9
+ }
10
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ES2022",
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "strict": true,
8
+ "noImplicitAny": true,
9
+ "noUncheckedIndexedAccess": true,
10
+ "noFallthroughCasesInSwitch": true,
11
+ "useDefineForClassFields": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "skipLibCheck": true
15
+ }
16
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "./base.json",
4
+ "compilerOptions": {
5
+ "lib": ["ES2022"],
6
+ "types": [],
7
+ "noEmit": true
8
+ }
9
+ }
@@ -0,0 +1,7 @@
1
+ # @livon/config/vitest Redirect
2
+
3
+ Canonical source moved to Docusaurus:
4
+
5
+ - `/docs/packages/config`
6
+
7
+ This file is a compatibility redirect only.
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Shared Vitest base config helpers exported by `@livon/config/vitest/base.cjs`.
3
+ *
4
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
5
+ */
6
+
7
+ /**
8
+ * Creates a reusable Vitest config for unit or integration projects.
9
+ *
10
+ * @example
11
+ * ```js
12
+ * const { createVitestConfig } = require('@livon/config/vitest/base.cjs');
13
+ *
14
+ * module.exports = createVitestConfig({ type: 'unit' });
15
+ * ```
16
+ *
17
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
18
+ *
19
+ * @param {{ type: 'unit' | 'integration' }} input
20
+ * @returns {{
21
+ * test: {
22
+ * include: string[];
23
+ * exclude: string[];
24
+ * environment: string;
25
+ * globals: boolean;
26
+ * coverage: {
27
+ * provider: string;
28
+ * reporter: string[];
29
+ * exclude: string[];
30
+ * };
31
+ * };
32
+ * }}
33
+ */
34
+ const createVitestConfig = (input) => {
35
+ const mockExcludes = ['**/testing/mocks/**', '**/__mocks__/**'];
36
+
37
+ return {
38
+ test: {
39
+ include: input.type === 'unit' ? ['src/**/*.spec.ts'] : ['tests/**/*.spec.ts'],
40
+ exclude: mockExcludes,
41
+ environment: 'node',
42
+ globals: false,
43
+ coverage: {
44
+ provider: 'v8',
45
+ reporter: ['text', 'html'],
46
+ exclude: mockExcludes,
47
+ },
48
+ },
49
+ };
50
+ };
51
+
52
+ module.exports = {
53
+ createVitestConfig,
54
+ };
package/vitest/base.ts ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Shared Vitest base config helpers exported by `@livon/config`.
3
+ *
4
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
5
+ */
6
+ type VitestProjectType = 'unit' | 'integration';
7
+
8
+ export interface VitestConfigInput {
9
+ type: VitestProjectType;
10
+ }
11
+
12
+ export interface VitestCoverageConfig {
13
+ provider: string;
14
+ reporter: string[];
15
+ exclude: string[];
16
+ }
17
+
18
+ export interface VitestTestConfig {
19
+ include: string[];
20
+ exclude: string[];
21
+ environment: string;
22
+ globals: boolean;
23
+ coverage: VitestCoverageConfig;
24
+ }
25
+
26
+ export interface VitestConfig {
27
+ test: VitestTestConfig;
28
+ }
29
+
30
+ /**
31
+ * Creates a reusable Vitest config for unit or integration projects.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * import { createVitestConfig } from '@livon/config/vitest';
36
+ *
37
+ * export default createVitestConfig({ type: 'unit' });
38
+ * ```
39
+ *
40
+ * @see https://live-input-vector-output-node.github.io/livon-ts/docs/packages/config
41
+ */
42
+ export const createVitestConfig = (input: VitestConfigInput): VitestConfig => {
43
+ const mockExcludes = ['**/testing/mocks/**', '**/__mocks__/**'];
44
+
45
+ return {
46
+ test: {
47
+ include: input.type === 'unit' ? ['src/**/*.spec.ts'] : ['tests/**/*.spec.ts'],
48
+ exclude: mockExcludes,
49
+ environment: 'node',
50
+ globals: false,
51
+ coverage: {
52
+ provider: 'v8',
53
+ reporter: ['text', 'html'],
54
+ exclude: mockExcludes,
55
+ },
56
+ },
57
+ };
58
+ };