Skip to content

Commit

Permalink
chore: change semicolon format config (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 authored May 31, 2024
1 parent 9a9c238 commit c24f23c
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 71 deletions.
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore artifacts
dist
compiled
doc_build
3 changes: 1 addition & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"singleQuote": true,
"semi": false
"singleQuote": true
}
3 changes: 1 addition & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"semicolons": "asNeeded"
"quoteStyle": "single"
}
},
"linter": {
Expand Down
6 changes: 3 additions & 3 deletions e2e/cases/define/index.pw.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect, test } from '@playwright/test'
import { expect, test } from '@playwright/test';

test('todo', async () => {
expect(1).toBe(1)
})
expect(1).toBe(1);
});
20 changes: 10 additions & 10 deletions e2e/cases/define/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { build } from '@rslib/core'
import { expect, test } from 'vitest'
import { globContentJSON } from '#helper'
import { build } from '@rslib/core';
import { expect, test } from 'vitest';
import { globContentJSON } from '#helper';

test.fails('define', async () => {
// @ts-expect-error follow conventional
delete process.env.NODE_ENV
delete process.env.NODE_ENV;

const rslibConfig = {
root: __dirname,
entry: './js/src/index.js',
outDir: 'dist',
}
};

const instance = await build(rslibConfig)
const instance = await build(rslibConfig);
const results = await globContentJSON(instance.context.distPath, {
absolute: true,
ignore: ['/**/*.map'],
})
});

const entryJs = Object.keys(results).find((file) => file.endsWith('.js'))
expect(results[entryJs!]).not.toContain('console.info(VERSION)')
})
const entryJs = Object.keys(results).find((file) => file.endsWith('.js'));
expect(results[entryJs!]).not.toContain('console.info(VERSION)');
});
2 changes: 1 addition & 1 deletion e2e/cases/define/js/src/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.info(VERSION)
console.info(VERSION);
4 changes: 2 additions & 2 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from '@playwright/test'
import { defineConfig } from '@playwright/test';

export default defineConfig({
// Playwright test files with `.pw.` to distinguish from Vitest test files
testMatch: /.*pw.(test|spec).(js|ts|mjs)/,
})
});
28 changes: 14 additions & 14 deletions e2e/scripts/helper.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { platform } from 'node:os'
import { join } from 'node:path'
import { platform } from 'node:os';
import { join } from 'node:path';
import fg, {
type Options as GlobOptions,
convertPathToPattern,
} from 'fast-glob'
import fse from 'fs-extra'
} from 'fast-glob';
import fse from 'fs-extra';

export const getFiles = async (pattern: string) => {}
export const getFiles = async (pattern: string) => {};

// fast-glob only accepts posix path
// https://github.com/mrmlnc/fast-glob#convertpathtopatternpath
const convertPath = (path: string) => {
if (platform() === 'win32') {
return convertPathToPattern(path)
return convertPathToPattern(path);
}
return path
}
return path;
};

export const globContentJSON = async (path: string, options?: GlobOptions) => {
const files = await fg(convertPath(join(path, '**/*')), options)
const ret: Record<string, string> = {}
const files = await fg(convertPath(join(path, '**/*')), options);
const ret: Record<string, string> = {};

await Promise.all(
files.map((file) =>
fse.readFile(file, 'utf-8').then((content) => {
ret[file] = content
ret[file] = content;
}),
),
)
);

return ret
}
return ret;
};
2 changes: 1 addition & 1 deletion e2e/scripts/main.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import {} from '@rslib/core'
import {} from '@rslib/core';
6 changes: 3 additions & 3 deletions packages/core/bin/rslib.cjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env node

async function main() {
const { runCli } = require('../dist/cli')
runCli()
const { runCli } = require('../dist/cli');
runCli();
}

main()
main();
4 changes: 2 additions & 2 deletions packages/core/modern.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, moduleTools } from '@modern-js/module-tools'
import { defineConfig, moduleTools } from '@modern-js/module-tools';

export default defineConfig({
plugins: [moduleTools()],
Expand All @@ -11,4 +11,4 @@ export default defineConfig({
target: 'es2020',
},
],
})
});
14 changes: 7 additions & 7 deletions packages/core/src/build.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createRsbuild } from '@rsbuild/core'
import { composeCreateRsbuildConfig } from './config'
import type { RslibConfig } from './types'
import { createRsbuild } from '@rsbuild/core';
import { composeCreateRsbuildConfig } from './config';
import type { RslibConfig } from './types';

export async function build(config: RslibConfig) {
const createRsbuildConfig = composeCreateRsbuildConfig(config)
const rsbuildInstance = await createRsbuild(createRsbuildConfig)
const createRsbuildConfig = composeCreateRsbuildConfig(config);
const rsbuildInstance = await createRsbuild(createRsbuildConfig);
await rsbuildInstance.build({
mode: 'production',
})
return rsbuildInstance
});
return rsbuildInstance;
}
16 changes: 8 additions & 8 deletions packages/core/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { program } from 'commander'
import { build } from './build'
import type { RslibConfig } from './types'
import { program } from 'commander';
import { build } from './build';
import type { RslibConfig } from './types';

export function runCli() {
const buildCommand = program.command('build')
const buildCommand = program.command('build');

buildCommand
.description('build the app for production')
Expand All @@ -14,11 +14,11 @@ export function runCli() {
await build({
entry: options.entry,
outDir: options.outDir,
})
});
} catch (err) {
process.exit(1)
process.exit(1);
}
})
});

program.parse()
program.parse();
}
10 changes: 5 additions & 5 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {
type CreateRsbuildOptions,
defineConfig as defineRsbuildConfig,
} from '@rsbuild/core'
import type { RslibConfig } from './types'
} from '@rsbuild/core';
import type { RslibConfig } from './types';

export function composeCreateRsbuildConfig(
rslibConfig: RslibConfig,
): CreateRsbuildOptions {
const { root, entry, outDir } = rslibConfig
const { root, entry, outDir } = rslibConfig;

const rsbuildConfig = defineRsbuildConfig({
source: {
Expand Down Expand Up @@ -40,10 +40,10 @@ export function composeCreateRsbuildConfig(
js: './',
},
},
})
});

return {
cwd: root ?? process.cwd(),
rsbuildConfig,
}
};
}
2 changes: 1 addition & 1 deletion packages/core/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* Only to setup the basic infrastructure workflow.
*/

export { build } from './build'
export { build } from './build';
6 changes: 3 additions & 3 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export interface RslibConfig {
entry: string
root?: string
outDir?: string
entry: string;
root?: string;
outDir?: string;
}
8 changes: 4 additions & 4 deletions packages/core/tests/core.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { describe, expect, it } from 'vitest';

describe('core', () => {
it('should work', () => {
expect(1).toBe(1)
})
})
expect(1).toBe(1);
});
});
6 changes: 3 additions & 3 deletions vitest.workspace.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { defineWorkspace } from 'vitest/config'
import { defineWorkspace } from 'vitest/config';

const shared = {
globals: true,
environment: 'node',
testTimeout: 30000,
restoreMocks: true,
}
};

export default defineWorkspace([
{
Expand All @@ -24,4 +24,4 @@ export default defineWorkspace([
exclude: ['e2e/cases/**/*.pw.test.ts', '**/node_modules/**'],
},
},
])
]);

0 comments on commit c24f23c

Please sign in to comment.