Skip to content

Commit

Permalink
🐛 fix: prepare for release + 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 26, 2024
1 parent 2c1e430 commit 4163ee8
Show file tree
Hide file tree
Showing 34 changed files with 797 additions and 698 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ A monorepo of configs and packages used to speed up development @ Pulseflow and
- [ESLint]: used for static code analysis with auto-fixing.
- [Vitest]: our preferred JavaScript test framework.

[eslint]: https://eslint.org/
[typescript]: https://www.typescriptlang.org/
[vitest]: https://vitest.dev/
[ESLint]: https://eslint.org/
[TypeScript]: https://www.typescriptlang.org/
[Vitest]: https://vitest.dev/
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@
"devDependencies": {
"@flowr/eslint-config": "workspace:^",
"@flowr/tsconfig": "workspace:^",
"@types/node": "^22.5.5",
"@types/node": "^22.7.2",
"bumpp": "^9.5.2",
"esbuild": "^0.24.0",
"eslint": "^9.10.0",
"jiti": "^1.21.6",
"eslint": "^9.11.1",
"jiti": "^2.0.0",
"tsup": "^8.3.0",
"tsx": "^4.19.1",
"typescript": "^5.6.2",
"unbuild": "^2.0.0",
"vite": "^5.4.7",
"vite": "^5.4.8",
"vitest": "^2.1.1"
},
"resolutions": {
"@eslint-community/eslint-utils": "^4.4.0",
"@typescript-eslint/utils": "^8.6.0",
"eslint": "^9.10.0",
"@typescript-eslint/utils": "^8.7.0",
"eslint": "^9.11.1",
"tsx": "^4.19.1"
}
}
4 changes: 3 additions & 1 deletion packages/create-petal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"create-app",
"petal",
"tooling",
"build"
"build",
"create-petal",
"flowr"
],
"sideEffects": false,
"exports": {
Expand Down
23 changes: 13 additions & 10 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"keywords": [
"eslint-config",
"eslint",
"style"
"style",
"typescript",
"flowr",
"petal"
],
"sideEffects": false,
"exports": {
Expand Down Expand Up @@ -56,7 +59,7 @@
"@tanstack/eslint-plugin-query": "^5.52.0",
"@unocss/eslint-plugin": ">=0.60.0 < 1",
"astro-eslint-parser": "^1.0.2",
"eslint": "^9.10.0",
"eslint": "^9.11.1",
"eslint-plugin-astro": "^1.2.3",
"eslint-plugin-format": ">=0.1.0",
"eslint-plugin-json-schema-validator": "^5.1.2",
Expand Down Expand Up @@ -138,18 +141,18 @@
"@eslint/compat": "^1.1.1",
"@eslint/markdown": "^6.1.0",
"@stylistic/eslint-plugin": "^2.8.0",
"@typescript-eslint/eslint-plugin": "^8.6.0",
"@typescript-eslint/parser": "^8.6.0",
"@typescript-eslint/eslint-plugin": "^8.7.0",
"@typescript-eslint/parser": "^8.7.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",
"eslint-plugin-jsdoc": "^50.2.4",
"eslint-plugin-import-x": "^4.3.0",
"eslint-plugin-jsdoc": "^50.2.5",
"eslint-plugin-jsonc": "^2.16.0",
"eslint-plugin-n": "^17.10.3",
"eslint-plugin-perfectionist": "^3.6.0",
"eslint-plugin-perfectionist": "^3.7.0",
"eslint-plugin-petal": "workspace:^",
"eslint-plugin-regexp": "^2.6.0",
"eslint-plugin-toml": "^0.11.1",
Expand All @@ -167,13 +170,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.57.1",
"@tanstack/eslint-plugin-query": "^5.57.2",
"@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.10.0",
"eslint": "^9.11.1",
"eslint-plugin-astro": "^1.2.4",
"eslint-plugin-format": "^0.1.2",
"eslint-plugin-json-schema-validator": "^5.1.3",
Expand All @@ -188,7 +191,7 @@
"execa": "^9.4.0",
"fast-glob": "^3.3.2",
"fs-extra": "^11.2.0",
"jiti": "^1.21.6",
"jiti": "^2.0.0",
"pathe": "^1.1.2",
"prettier-plugin-astro": "^0.14.1",
"prettier-plugin-slidev": "^1.0.5",
Expand Down
21 changes: 21 additions & 0 deletions packages/eslint-config/src/builder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { TypedFlatConfigItem } from './types';

interface Builder {
(type: string, sub: TypedFlatConfigItem): Builder;
build: () => TypedFlatConfigItem[];
}

export function builder(name: string, configs: TypedFlatConfigItem[] = []): Builder {
const builderInstance = (type: string, sub: TypedFlatConfigItem): Builder => {
configs.push({
name: `${name}/${type}`,
...sub,
});

return builderInstance;
};

builderInstance.build = () => configs;

return builderInstance;
}
74 changes: 38 additions & 36 deletions packages/eslint-config/src/configs/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem, VendoredPrettierOptions, VendoredPrettierXMLOptions } from '../types';
import type { OptionsFormatters, StylisticConfig, TypedFlatConfigItem, VendoredPrettierOptions, VendoredPrettierRuleOptions, VendoredPrettierXMLOptions } from '../types';
import { isPackageExists } from 'local-pkg';
import { GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_GRAPHQL, GLOB_HTML, GLOB_LESS, GLOB_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SVG, GLOB_XML } from '../globs';
import { ensurePackages, interopDefault, isPackageInScope, parserPlain } from '../utils';
import { StylisticConfigDefaults } from './stylistic';

function mergePrettierOptions(
options: VendoredPrettierOptions,
overrides: VendoredPrettierRuleOptions = {},
): VendoredPrettierRuleOptions {
return {
...options,
...overrides,
plugins: [
...overrides.plugins || [],
...options.plugins || [],
],
};
}

export async function formatters(options: OptionsFormatters | true = {}, stylistic: StylisticConfig = {}): Promise<TypedFlatConfigItem[]> {
const isXmlInScope = isPackageInScope('@prettier/plugin-xml');
if (options === true)
Expand Down Expand Up @@ -40,7 +54,7 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
useTabs: indent === 'tab',
} satisfies VendoredPrettierOptions, options.prettierOptions || {});

const prettierXmlOptions: VendoredPrettierXMLOptions = {
const prettierXmlOptions: VendoredPrettierOptions = {
xmlQuoteAttributes: 'double',
xmlSelfClosingSpace: true,
xmlSortAttributesByKey: false,
Expand Down Expand Up @@ -75,10 +89,9 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierOptions,
mergePrettierOptions(prettierOptions, {
parser: 'css',
},
}),
],
},
},
Expand All @@ -91,10 +104,9 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierOptions,
mergePrettierOptions(prettierOptions, {
parser: 'scss',
},
}),
],
},
},
Expand All @@ -107,10 +119,9 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierOptions,
mergePrettierOptions(prettierOptions, {
parser: 'less',
},
}),
],
},
},
Expand All @@ -126,10 +137,9 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierOptions,
mergePrettierOptions(prettierOptions, {
parser: 'html',
},
}),
],
},
});
Expand All @@ -144,12 +154,10 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierXmlOptions,
...prettierOptions,
mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
parser: 'xml',
plugins: ['@prettier/plugin-xml'],
},
}),
],
},
});
Expand All @@ -164,12 +172,10 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierXmlOptions,
...prettierOptions,
mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
parser: 'xml',
plugins: ['@prettier/plugin-xml'],
},
}),
],
},
});
Expand All @@ -196,11 +202,10 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
[`format/${formatter}`]: [
'error',
formatter === 'prettier'
? {
...prettierOptions,
embeddedLanguageFormatting: 'off',
parser: 'markdown',
}
? mergePrettierOptions(prettierOptions, {
embeddedLanguageFormatting: 'off',
parser: 'markdown',
})
: {
...dprintOptions,
language: 'markdown',
Expand All @@ -219,12 +224,11 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierOptions,
mergePrettierOptions(prettierOptions, {
embeddedLannguageFormatting: 'off',
parser: 'slidev',
plugins: ['prettier-plugin-slidev'],
},
}),
],
},
});
Expand All @@ -240,11 +244,10 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierOptions,
mergePrettierOptions(prettierOptions, {
parser: 'astro',
plugins: ['prettier-plugin-astro'],
},
}),
],
},
});
Expand Down Expand Up @@ -274,10 +277,9 @@ export async function formatters(options: OptionsFormatters | true = {}, stylist
rules: {
'format/prettier': [
'error',
{
...prettierOptions,
mergePrettierOptions(prettierOptions, {
parser: 'graphql',
},
}),
],
},
});
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-config/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type FactoryComposer = FlatConfigComposer<TypedFlatConfigItem, ConfigNames>;
* @param {FactoryOptions} options The options for generating the ESLint configurations.
* @param {UserConfigs} userConfigs The user configurations to be merged with the generated configurations.
* @returns {FactoryComposer} The merged ESLint configurations.
* @public
*/
export function defineConfig(options: FactoryOptions = {}, ...userConfigs: UserConfig[]): FactoryComposer {
const {
Expand Down
35 changes: 35 additions & 0 deletions packages/eslint-config/src/types/prettier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

export type VendoredPrettierOptions = Partial<VendoredPrettierOptionsRequired>;

export interface VendoredPrettierRuleOptions extends VendoredPrettierOptions {
parser?: ParserName;
[k: string]: unknown | undefined;
};

export interface VendoredPrettierOptionsRequired {
/**
* Specify the line length that the printer will wrap on.
Expand Down Expand Up @@ -119,3 +124,33 @@ export interface VendoredPrettierOptionsRequired {
*/
xmlWhitespaceSensitivity: 'ignore' | 'strict' | 'preserve';
}

export type ParserName = BuiltInParserName | ExternalParserName;

export type BuiltInParserName =
| 'acorn'
| 'angular'
| 'babel-flow'
| 'babel-ts'
| 'babel'
| 'css'
| 'espree'
| 'flow'
| 'glimmer'
| 'graphql'
| 'html'
| 'json-stringify'
| 'json'
| 'json5'
| 'less'
| 'lwc'
| 'markdown'
| 'mdx'
| 'meriyah'
| 'scss'
| 'typescript'
| 'vue'
| 'xml'
| 'yaml';

export type ExternalParserName = 'slidev' | 'astro';
3 changes: 2 additions & 1 deletion packages/eslint-config/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const scopeUrl = fileURLToPath(new URL('.', import.meta.url));
const isCwdInScope = isPackageExists('@flowr/eslint-config');

/**
* A simple parser for use in AST-agnostic configs (i.e. markdown formatters, `eslint-plugin-format`)
* A simple parser for use in AST-agnostic configs (i.e. `@eslint/markdown`, `eslint-plugin-format`).
*
* @public
*/
export const parserPlain: Linter.Parser = {
Expand Down
Loading

0 comments on commit 4163ee8

Please sign in to comment.