Skip to content

Commit

Permalink
chore: remove source codes and tests from the same place (#218)
Browse files Browse the repository at this point in the history
* feat: orgnize tests

* chore: manage generate command
  • Loading branch information
veritem authored Aug 11, 2023
1 parent 373f858 commit 3f4550b
Show file tree
Hide file tree
Showing 79 changed files with 3,407 additions and 3,316 deletions.
5 changes: 5 additions & 0 deletions fixtures/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"plugin:vitest/all"
]
}
5 changes: 0 additions & 5 deletions fixtures/eslint.config.js

This file was deleted.

10 changes: 0 additions & 10 deletions fixtures/index.spec.ts

This file was deleted.

9 changes: 9 additions & 0 deletions fixtures/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { describe, it, expect } from 'vitest'

describe('foo', () => {
it.todo('mdmdms')

it('foo', () => {
expect(true).toBeTruthy()
})
})
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"release": "pnpm build && bumpp package.json --commit --push --tag && pnpm publish",
"stub": "unbuild --stub",
"test:ci": "vitest run",
"test": "vitest src/**/*.test.ts",
"test": "vitest",
"generate": "tsx scripts/generate.ts",
"update:eslint-docs": "pnpm build && eslint-doc-generator"
},
"devDependencies": {
Expand All @@ -55,6 +56,7 @@
"eslint-remote-tester-repositories": "^1.0.1",
"jiti": "^1.19.1",
"ts-node": "^10.9.1",
"tsx": "^3.12.7",
"unbuild": "^1.2.1",
"vitest": "^0.33.0"
},
Expand All @@ -73,4 +75,4 @@
"dependencies": {
"@typescript-eslint/utils": "^6.2.0"
}
}
}
61 changes: 61 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions scripts/generate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import fs from 'node:fs'
import url from 'node:url'
import path from 'node:path'

async function generate() {
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const rules = fs.readdirSync(path.resolve(__dirname, '../src/rules'))

const allRules = []
const recommendedRules = []

rules.forEach(async (rule) => {
const ruleName = rule.replace(/\.ts$/, '')
const content = await import(path.resolve(__dirname, `../src/rules/${ruleName}.ts`))

if (content.default.meta.docs.recommended) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
recommendedRules.push({
name: ruleName,
rule: content.default
})
} else {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
allRules.push({
name: ruleName,
rule: content.default
})
}
})

console.log(recommendedRules)
}

generate()
.catch((e) => {
console.error(e)
process.exit(1)
})
25 changes: 0 additions & 25 deletions src/rules/consistent-test-filename.test.ts

This file was deleted.

Loading

0 comments on commit 3f4550b

Please sign in to comment.