Skip to content

Commit

Permalink
🔨 chore: bump + type fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Pauline <git@ethanlibs.co>
  • Loading branch information
pauliesnug committed Sep 22, 2024
1 parent f1ee675 commit de63967
Show file tree
Hide file tree
Showing 18 changed files with 518 additions and 105 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"@flowr/tsconfig": "workspace:^",
"@types/node": "^22.5.5",
"bumpp": "^9.5.2",
"esbuild": "^0.23.1",
"eslint": "^9.11.0",
"esbuild": "^0.24.0",
"eslint": "^9.10.0",
"jiti": "^1.21.6",
"tsup": "^8.3.0",
"tsx": "^4.19.1",
Expand Down
7 changes: 4 additions & 3 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"@typescript-eslint/parser": "^8.6.0",
"@vitest/eslint-plugin": "^1.1.4",
"eslint-flat-config-utils": "^0.4.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-merge-processors": "^0.1.0",
"eslint-plugin-command": "^0.2.5",
"eslint-plugin-import-x": "^4.2.1",
Expand All @@ -166,13 +167,13 @@
"@eslint-react/eslint-plugin": "^1.14.2",
"@eslint/config-inspector": "^0.5.4",
"@prettier/plugin-xml": "^3.4.1",
"@tanstack/eslint-plugin-query": "^5.56.1",
"@tanstack/eslint-plugin-query": "^5.57.1",
"@types/eslint-plugin-jsx-a11y": "^6.9.0",
"@types/fs-extra": "^11.0.4",
"@types/prompts": "^2.4.9",
"@unocss/eslint-plugin": "^0.62.4",
"astro-eslint-parser": "^1.0.3",
"eslint": "^9.11.0",
"eslint": "^9.10.0",
"eslint-plugin-astro": "^1.2.4",
"eslint-plugin-format": "^0.1.2",
"eslint-plugin-json-schema-validator": "^5.1.3",
Expand All @@ -193,7 +194,7 @@
"prettier-plugin-slidev": "^1.0.5",
"svelte": "^4.2.19",
"svelte-eslint-parser": "^0.41.1",
"vue": "^3.5.7",
"vue": "^3.5.8",
"vue-eslint-parser": "^9.4.3"
},
"publishConfig": {
Expand Down
28 changes: 27 additions & 1 deletion packages/eslint-config/src/configs/imports.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
import type { FileExtension, ImportResolver } from 'eslint-plugin-import-x/types.js';
import type { OptionsImports, TypedFlatConfigItem } from '../types';
import { interopDefault } from '../utils';

export async function imports(options: OptionsImports = {}): Promise<TypedFlatConfigItem[]> {
const { stylistic = true } = options;
const { overrides = {}, stylistic = true, tsResolverOptions } = options;

const [pluginImport, pluginPetal] = await Promise.all([
interopDefault(import('eslint-plugin-import-x')),
interopDefault(import('eslint-plugin-petal')),
] as const);

const importResolver: ImportResolver = {
node: {
extensions: [
'.js',
'.jsx',
...options.typescript ? ['.ts', '.tsx'] : [],
],
...options.typescript && {
typescript: tsResolverOptions ?? true,
},
},
};

const importParsers: Record<string, readonly FileExtension[]> = {
'@typescript-eslint/parser': ['.ts', '.tsx'],
};

return [
{
name: 'petal/imports/rules',
Expand All @@ -33,6 +51,14 @@ export async function imports(options: OptionsImports = {}): Promise<TypedFlatCo
'import/newline-after-import': ['error', { count: 1 }],
}
: {},

...overrides,
},
settings: {
...options.typescript && {
'import-x/parsers': importParsers,
},
'import-x/resolver': importResolver,
},
},
];
Expand Down
4 changes: 3 additions & 1 deletion packages/eslint-config/src/configs/jsdoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { OptionsJsdoc, TypedFlatConfigItem } from '../types';
import { interopDefault } from '../utils';

export async function jsdoc(options: OptionsJsdoc = {}): Promise<TypedFlatConfigItem[]> {
const { stylistic = true } = options;
const { overrides = {}, stylistic = true } = options;

const pluginJsdoc = await interopDefault(import('eslint-plugin-jsdoc'));

Expand Down Expand Up @@ -35,6 +35,8 @@ export async function jsdoc(options: OptionsJsdoc = {}): Promise<TypedFlatConfig
'jsdoc/multiline-blocks': 'warn',
}
: {},

...overrides,
},
},
];
Expand Down
6 changes: 2 additions & 4 deletions packages/eslint-config/src/configs/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { interopDefault, parserPlain } from '../utils';
export async function markdown(options: OptionsMarkdown = {}): Promise<TypedFlatConfigItem[]> {
const { componentExts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
const pluginMarkdown = await interopDefault(import('@eslint/markdown'));
const passthroughProcessor = mergeProcessors([pluginMarkdown.processors!.markdown, processorPassThrough]);

return [
{
Expand All @@ -21,10 +22,7 @@ export async function markdown(options: OptionsMarkdown = {}): Promise<TypedFlat
// `@eslint/markdown` only creates virtual files for code blocks,
// but not the markdown file itself. we use `eslint-merge-processors` to
// add a pass-through processor for the markdown file itself.
processor: mergeProcessors([
pluginMarkdown.processors!.markdown,
processorPassThrough,
]),
processor: passthroughProcessor,
},
{
files,
Expand Down
17 changes: 12 additions & 5 deletions packages/eslint-config/src/configs/perfectionist.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
import type { TypedFlatConfigItem } from '../types';
import { interopDefault } from '../utils';

type SortConfig = ['error', {
type?: ('alphabetical' | 'natural' | 'line-length');
order?: ('asc' | 'desc');
}];

/**
* Perfectionist plugin for props and items sorting.
*
* @see https://github.com/azat-io/eslint-plugin-perfectionist
*/
export async function perfectionist(): Promise<TypedFlatConfigItem[]> {
const sortConfig: SortConfig = ['error', { order: 'asc', type: 'natural' }];

return [
{
name: 'petal/perfectionist/setup',
plugins: {
perfectionist: await interopDefault(import('eslint-plugin-perfectionist')),
},
rules: {
'perfectionist/sort-array-includes': ['error', { order: 'asc', type: 'natural' }],
'perfectionist/sort-exports': ['error', { order: 'asc', type: 'natural' }],
'perfectionist/sort-array-includes': sortConfig,
'perfectionist/sort-exports': sortConfig,
'perfectionist/sort-imports': ['error', {
groups: [
'type',
Expand All @@ -33,9 +40,9 @@ export async function perfectionist(): Promise<TypedFlatConfigItem[]> {
order: 'asc',
type: 'natural',
}],
'perfectionist/sort-named-exports': ['error', { order: 'asc', type: 'natural' }],
'perfectionist/sort-named-imports': ['error', { order: 'asc', type: 'natural' }],
'perfectionist/sort-sets': ['error', { order: 'asc', type: 'natural' }],
'perfectionist/sort-named-exports': sortConfig,
'perfectionist/sort-named-imports': sortConfig,
'perfectionist/sort-sets': sortConfig,
},
},
];
Expand Down
12 changes: 11 additions & 1 deletion packages/eslint-config/src/configs/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { GLOB_TESTS } from '../globs';
import { interopDefault } from '../utils';

export async function test(options: OptionsTest = {}): Promise<TypedFlatConfigItem[]> {
const { files = GLOB_TESTS, overrides = {} } = options;
const { files = GLOB_TESTS, overrides = {}, typecheck = false } = options;

const [pluginTest, pluginPetal] = await Promise.all([
interopDefault(import('@vitest/eslint-plugin')),
Expand All @@ -12,11 +12,21 @@ export async function test(options: OptionsTest = {}): Promise<TypedFlatConfigIt

return [
{
languageOptions: {
globals: {
...pluginTest.environments.env.globals,
},
},
name: 'petal/test/setup',
plugins: {
petal: pluginPetal,
test: pluginTest,
},
settings: {
vitest: {
typecheck,
},
},
},
{
files,
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config/src/configs/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export async function typescript(options: OptionsTypeScript = {}): Promise<Typed
tsconfigRootDir: process.cwd(),
}
: {},
...parserOptions as Linter.ParserOptions,
},
...parserOptions,
} as import('@typescript-eslint/parser').ParserOptions,
},
name: `petal/typescript/${typeAware ? 'type-aware-parser' : 'parser'}`,
});
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config/src/configs/unicorn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export async function unicorn(options: OptionsUnicorn = {}): Promise<TypedFlatCo
'unicorn/prefer-type-error': 'error',
'unicorn/throw-new-error': 'error',
}),

...options.overrides,
},
},
];
Expand Down
13 changes: 3 additions & 10 deletions packages/eslint-config/src/configs/unocss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,9 @@ export async function unocss(options: OptionsUnoCSS = {}): Promise<TypedFlatConf
},
rules: {
'unocss/order': 'warn',
...attributify
? {
'unocss/order-attributify': 'warn',
}
: {},
...strict
? {
'unocss/blocklist': 'error',
}
: {},

...attributify ? { 'unocss/order-attributify': 'warn' } : {},
...strict ? { 'unocss/blocklist': 'error' } : {},
},
},
];
Expand Down
21 changes: 19 additions & 2 deletions packages/eslint-config/src/types/configs/accessibility.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface OptionsAccessibility {
import type { TypedFlatConfigItem } from '../index';

export interface OptionsAccessibility<T = DefaultAccessibility> {
/**
* Enable accessibility rules.
*
Expand All @@ -10,5 +12,20 @@ export interface OptionsAccessibility {
* @see https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility
* @default false
*/
accessibility?: boolean;
accessibility?: boolean | T;
}

export interface DefaultAccessibility {
/**
* Override accessibility rules.
*
* Requires installing:
* - `eslint-plugin-jsx-a11y` for JSX
* - `eslint-plugin-vuejs-accessibility` for Vue
*
* @see https://github.com/jsx-eslint/eslint-plugin-jsx-a11y
* @see https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility
* @default {}
*/
overrideA11y: TypedFlatConfigItem['rules'];
}
7 changes: 6 additions & 1 deletion packages/eslint-config/src/types/configs/imports.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import type { TsResolverOptions } from 'eslint-plugin-import-x/types.js';
import type { OptionsOverrides } from './overrides';
import type { OptionsStylistic } from './stylistic';
import type { OptionsHasTypeScript } from './typescript';

export type OptionsImports = OptionsStylistic;
export interface OptionsImports extends OptionsStylistic, OptionsOverrides, OptionsHasTypeScript {
tsResolverOptions?: Pick<TsResolverOptions, 'alwaysTryTypes' | 'project'>;
};
2 changes: 1 addition & 1 deletion packages/eslint-config/src/types/configs/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ import type { OptionsOverrides } from './overrides';
import type { OptionsStylistic } from './stylistic';

export type OptionsJavascript = OptionsOverrides & OptionsIsInEditor;
export type OptionsJsdoc = OptionsStylistic;
export type OptionsJsdoc = OptionsOverrides & OptionsStylistic;
9 changes: 8 additions & 1 deletion packages/eslint-config/src/types/configs/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type { OptionsFiles } from './files';
import type { OptionsOverrides } from './overrides';

export type OptionsTest = OptionsOverrides & OptionsFiles;
export interface OptionsTest extends OptionsOverrides, OptionsFiles {
/**
* Enable test type checking support.
*
* @default false
*/
typecheck?: boolean;
};
3 changes: 2 additions & 1 deletion packages/eslint-config/src/types/configs/unicorn.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { OptionsOverrides } from './overrides';
import type { OptionsRecommended } from './recommended';

export type OptionsUnicorn = OptionsRecommended;
export type OptionsUnicorn = OptionsOverrides & OptionsRecommended;
2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"devDependencies": {
"@typescript-eslint/utils": "^8.6.0",
"eslint": "^9.11.0",
"eslint": "^9.10.0",
"eslint-vitest-rule-tester": "^0.6.1",
"jsonc-eslint-parser": "^2.4.0"
},
Expand Down
17 changes: 17 additions & 0 deletions packages/utils/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import { isFunction, isString } from './core';

/**
* Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
*/
export type Primitive =
| null
| undefined
| string
| number
| boolean
| symbol
| bigint;

export type LiteralUnion<
LiteralType,
BaseType extends Primitive,
> = LiteralType | (BaseType & Record<never, never>);

/** Possibly a `Promise<T>` */
export type Awaitable<T> = T | PromiseLike<T>;
export type StrictAwaitable<T> = T | Promise<T>;
Expand Down
Loading

0 comments on commit de63967

Please sign in to comment.