Skip to content

Commit

Permalink
refactor: small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Apr 8, 2024
1 parent 37f6f62 commit 0f44799
Show file tree
Hide file tree
Showing 7 changed files with 2,715 additions and 1,149 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
node_modules
*.log*
src/types.gen.d.ts
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ npx nypm install -D eslint typescript eslint-config-unjs
Create `eslint.config.mjs` in your project root:

```js
import unjs from 'eslint-config-unjs'
import unjs from "eslint-config-unjs";

export default unjs({
rules: {}
})
export default unjs({ ignores: [] }, { rules: {} });
```

Types for `rules` are auto generated using [`antfu/eslint-typegen`](https://github.com/antfu/eslint-typegen).
**Tips:**

- You can pass any number of flat configs to unjs preset wrapper
- Types for `rules` are auto generated using [`antfu/eslint-typegen`](https://github.com/antfu/eslint-typegen).

## License

Expand Down
28 changes: 15 additions & 13 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import {defineBuildConfig } from 'unbuild'
import fs from "node:fs/promises"
import { defineBuildConfig } from "unbuild";
import fs from "node:fs/promises";

export default defineBuildConfig({
hooks: {
async "build:before"() {
const unjsPreset = await import('./src/eslint.config').then(m => m.default)
const { flatConfigsToRulesDTS } = await import('eslint-typegen/core')
const dts = await flatConfigsToRulesDTS(unjsPreset(), {
includeAugmentation: false,
})
await fs.writeFile('src/types.gen.d.ts', dts)
}
}
})
hooks: {
async "build:before"() {
const unjsPreset = await import("./src/eslint.config").then(
(m) => m.default,
);
const { flatConfigsToRulesDTS } = await import("eslint-typegen/core");
const dts = await flatConfigsToRulesDTS(unjsPreset(), {
includeAugmentation: false,
});
await fs.writeFile("src/types.gen.d.ts", dts);
},
},
});
11 changes: 6 additions & 5 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import jiti from 'jiti'
import jiti from "jiti";

/** @type import("./src/eslint.config") */
const unjs = jiti(import.meta.url)('./src/eslint.config.ts')
const unjs = jiti(import.meta.url)("./src/eslint.config.ts");

export default unjs.default({
rules: {}
})
export default unjs.default(
{ ignores: ["**/types.gen.d.ts"] },
{ rules: {} }
);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"scripts": {
"build": "unbuild",
"dev": "eslint-config-inspector",
"lint": "eslint . && prettier -c *.js",
"lint": "eslint . && prettier -c src",
"lint:fix": "eslint . --fix && prettier -w src",
"prepack": "pnpm build",
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
"prerelease": "pnpm test && changelogen --release --prerelease && npm publish --tag rc && git push --follow-tags",
Expand Down
Loading

0 comments on commit 0f44799

Please sign in to comment.