Skip to content

Commit

Permalink
consolidate lint cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Nov 24, 2024
1 parent cbc2819 commit 499dbcf
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
10 changes: 10 additions & 0 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ async function parseCliArgs(argv: string[]) {
.showHelpOnFail(true)
.parse()

const cmd = args._[0]
if (cmd === 'prepare' || cmd === 'lint') {
return {
cmd,
}
}

const source: string = args._[0] as string
const parsedArgs: CliArgs = {
source,
Expand Down Expand Up @@ -340,6 +347,9 @@ async function main() {
// if (!error) help()
return exit(error as Error)
}
if ('cmd' in params) {
return
}
await run(params)
}

Expand Down
1 change: 1 addition & 0 deletions test/integration/lint/cjs-pkg-esm-main-field/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('integration cjs-pkg-esm-main-field', () => {
it('should warn if main field with .mjs extension in CJS package', async () => {
await createIntegrationTest(
{
args: ['lint'],
directory: __dirname,
},
({ stderr }) => {
Expand Down
9 changes: 3 additions & 6 deletions test/integration/lint/invalid-exports-cjs/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { assertFilesContent, createIntegrationTest } from '../../utils'
import { createIntegrationTest } from '../../utils'

describe('integration invalid-exports-cjs', () => {
it('should warn on invalid exports as CJS', async () => {
await createIntegrationTest(
{
args: ['lint'],
directory: __dirname,
},
async ({ stderr, distDir }) => {
assertFilesContent(distDir, {
'./index.esm.js': 'export { index }',
})

async ({ stderr }) => {
expect(stderr).toContain('Missing package name')
expect(stderr).toContain(
'Cannot export `require` field with .mjs extension in CJS package, only .cjs and .js extensions are allowed',
Expand Down
1 change: 1 addition & 0 deletions test/integration/lint/invalid-exports-esm/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('integration invalid-exports-esm', () => {
it('should warn on invalid exports as ESM', async () => {
await createIntegrationTest(
{
args: ['lint'],
directory: __dirname,
},
async ({ stderr }) => {
Expand Down
1 change: 1 addition & 0 deletions test/integration/lint/missing-files-exports/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('integration - lint - missing-files-exports', () => {
it('should warn on missing files', async () => {
await createIntegrationTest(
{
args: ['lint'],
directory: __dirname,
},
async ({ stderr }) => {
Expand Down
1 change: 1 addition & 0 deletions test/integration/lint/missing-files-main/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('integration - lint - missing-files-main', () => {
it('should warn on missing files', async () => {
await createIntegrationTest(
{
args: ['lint'],
directory: __dirname,
},
async ({ stderr }) => {
Expand Down

0 comments on commit 499dbcf

Please sign in to comment.