Skip to content

Commit

Permalink
update to latest antfu rule names (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Apr 2, 2024
1 parent d858381 commit ec790c6
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 144 deletions.
5 changes: 5 additions & 0 deletions .changeset/smooth-panthers-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@huntabyte/eslint-config": minor
---

update to latest antfu rule names
6 changes: 3 additions & 3 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@antfu/ni": "^0.21.12",
"@types/eslint": "^8.56.6",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.12.2",
"@types/node": "^20.12.3",
"@types/yargs": "^17.0.32",
"eslint": "^8.56.0",
"eslint-plugin-svelte": "2.36.0-next.13",
Expand All @@ -47,12 +47,12 @@
"svelte-eslint-parser": "^0.33.1"
},
"dependencies": {
"@antfu/eslint-config": "^2.11.6",
"@antfu/eslint-config": "^2.12.1",
"@antfu/install-pkg": "^0.3.2",
"@clack/prompts": "^0.7.0",
"@huntabyte/eslint-plugin": "workspace:*",
"chalk": "^5.3.0",
"eslint-flat-config-utils": "^0.1.2",
"eslint-flat-config-utils": "^0.2.0",
"local-pkg": "^0.5.0",
"parse-gitignore": "^2.0.0",
"yargs": "^17.7.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function updateEslintFiles(result: PromptResult) {
const pathPackageJSON = path.join(cwd, 'package.json');

const pkgContent = await fsp.readFile(pathPackageJSON, 'utf-8');
const pkg: Record<string, any> = JSON.parse(pkgContent);
const pkg: Record<string, unknown> = JSON.parse(pkgContent);

const configFileName = pkg.type === 'module' ? 'eslint.config.js' : 'eslint.config.mjs';
const pathFlatConfig = path.join(cwd, configFileName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export async function updatePackageJson(result: PromptResult) {
p.log.step(c.cyan(`Bumping @huntabyte/eslint-config to v${pkgJson.version}`));

const pkgContent = await fsp.readFile(pathPackageJSON, 'utf-8');
// eslint-disable-next-line ts/no-explicit-any
const pkg: Record<string, any> = JSON.parse(pkgContent);

pkg.dependencies ??= {};
Expand Down
23 changes: 12 additions & 11 deletions packages/eslint-config/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import antfu, {
} from '@antfu/eslint-config';
import pluginHuntabyte from '@huntabyte/eslint-plugin';
import { isPackageExists } from 'local-pkg';
import type { FlatConfigPipeline } from 'eslint-flat-config-utils';
import type { FlatConfigComposer } from 'eslint-flat-config-utils';

export type Options = OptionsConfig & TypedFlatConfigItem;
export type UserConfig = Awaitable<
TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigPipeline<any>
// eslint-disable-next-line ts/no-explicit-any
TypedFlatConfigItem | TypedFlatConfigItem[] | FlatConfigComposer<any>
>;

export const DEFAULT_IGNORES = ['**/.svelte-kit', '**/dist', '**/build', '**/static', '**/*.md'];
Expand All @@ -25,13 +26,13 @@ const defaultOptions: Options = {
export function huntabyte(
options?: Options,
...userConfigs: UserConfig[]
): FlatConfigPipeline<TypedFlatConfigItem> {
): FlatConfigComposer<TypedFlatConfigItem> {
defaultOptions.svelte = isPackageExists('svelte');

const withDefaults = { ...defaultOptions, ...options };

const factory = antfu(withDefaults, ...userConfigs)
.override('antfu:javascript', {
.override('antfu/javascript/rules', {
plugins: {
huntabyte: pluginHuntabyte,
},
Expand All @@ -53,17 +54,17 @@ export function huntabyte(
'huntabyte/top-level-function': 'error',
},
})
.override('antfu:typescript:setup', {
.override('antfu/typescript/setup', {
plugins: {
huntabyte: pluginHuntabyte,
},
})
.override('antfu:unicorn', {
.override('antfu/unicorn/rules', {
rules: {
'unicorn/prefer-dom-node-text-content': 'off',
},
})
.override('antfu:typescript:rules', {
.override('antfu/typescript/rules', {
rules: {
'ts/consistent-type-definitions': ['error', 'type'],
'ts/ban-types': [
Expand All @@ -81,14 +82,14 @@ export function huntabyte(

if (withDefaults.svelte) {
return factory
.override('antfu:svelte:setup', {
name: 'huntabyte:svelte:setup',
.override('antfu/svelte/setup', {
name: 'huntabyte/svelte/setup',
plugins: {
huntabyte: pluginHuntabyte,
},
})
.override('antfu:svelte:rules', {
name: 'huntabyte:svelte:rules',
.override('antfu/svelte/rules', {
name: 'huntabyte/svelte/rules',
rules: {
'no-unused-vars': 'off',
'unused-imports/no-unused-vars': [
Expand Down
Loading

0 comments on commit ec790c6

Please sign in to comment.