Skip to content

Commit

Permalink
feat(factory): add overrides and fix some bugs
Browse files Browse the repository at this point in the history
also bump deps
  • Loading branch information
pauliesnug committed Jan 20, 2024
1 parent 66cb9dc commit 9c1946e
Show file tree
Hide file tree
Showing 14 changed files with 554 additions and 456 deletions.
4 changes: 2 additions & 2 deletions configs/create-petal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
"strip-json-comments": "^5.0.1"
},
"devDependencies": {
"@types/node": "^20.11.0",
"@types/node": "^20.11.5",
"rimraf": "^5.0.5",
"tempy": "^3.1.0",
"typescript": "^5.3.3",
"vitest": "^1.1.3"
"vitest": "^1.2.1"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion configs/eslint-config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export default petal({

// `.eslintignore` isn't supported in flat configs, use `ignores` instead
ignores: [
'./fixtures',
'**/fixtures',
// ...globs
],
});
Expand Down
25 changes: 13 additions & 12 deletions configs/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,31 @@
"@eslint-types/typescript-eslint": "^6.18.1",
"@eslint-types/unicorn": "^50.0.1",
"@flowr/petal-utils": "workspace:^",
"@stylistic/eslint-plugin": "^1.5.3",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"@typescript-eslint/parser": "^6.18.1",
"astro-eslint-parser": "^0.16.0",
"@stylistic/eslint-plugin": "^1.5.4",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"astro-eslint-parser": "^0.16.2",
"eslint-config-flat-gitignore": "^0.1.2",
"eslint-merge-processors": "^0.1.0",
"eslint-plugin-astro": "^0.31.0",
"eslint-plugin-astro": "^0.31.3",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-i": "^2.29.1",
"eslint-plugin-jest": "^27.6.2",
"eslint-plugin-jest": "^27.6.3",
"eslint-plugin-jsdoc": "^48.0.2",
"eslint-plugin-jsonc": "^2.11.1",
"eslint-plugin-jsonc": "^2.12.2",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-n": "^16.6.2",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-perfectionist": "^2.5.0",
"eslint-plugin-petal": "workspace:^",
"eslint-plugin-svelte": "^2.35.1",
"eslint-plugin-toml": "^0.8.0",
"eslint-plugin-toml": "^0.9.2",
"eslint-plugin-unicorn": "^50.0.1",
"eslint-plugin-unused-imports": "^3.0.0",
"eslint-plugin-vitest": "^0.3.20",
"eslint-plugin-vue": "^9.20.0",
"eslint-plugin-yml": "^1.11.0",
"eslint-plugin-vue": "^9.20.1",
"eslint-plugin-yml": "^1.12.2",
"eslint-processor-vue-blocks": "^0.1.1",
"globals": "^13.24.0",
"jsonc-eslint-parser": "^2.4.0",
Expand All @@ -111,7 +111,7 @@
"@types/eslint": "^8.56.2",
"@types/fs-extra": "^11.0.4",
"@types/jest": "^29.5.11",
"@types/node": "^20.11.0",
"@types/node": "^20.11.5",
"@types/prompts": "^2.4.9",
"@unocss/eslint-plugin": "^0.58.3",
"eslint": "^8.56.0",
Expand All @@ -123,8 +123,9 @@
"fast-glob": "^3.3.2",
"fs-extra": "^11.2.0",
"rimraf": "^5.0.5",
"svelte": "^4.2.9",
"typescript": "^5.2.2",
"vitest": "^1.1.3"
"vitest": "^1.2.1"
},
"publishConfig": {
"access": "public"
Expand Down
1 change: 0 additions & 1 deletion configs/eslint-config/src/configs/javascript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ export async function javascript(options: OptionsIsInEditor & OptionsOverrides =
'no-multi-str': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-symbol': 'error',
'no-new-wrappers': 'error',
'no-obj-calls': 'error',
Expand Down
1 change: 1 addition & 0 deletions configs/eslint-config/src/configs/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export async function svelte(options: OptionsHasTypeScript & OptionsOverrides &
},
},
name: 'petal:svelte:rules',
processor: pluginSvelte.processors['.svelte'],
rules: {
'import/no-mutable-exports': 'off',
'no-undef': 'off',
Expand Down
44 changes: 29 additions & 15 deletions configs/eslint-config/src/configs/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export async function typescript(options: OptionsComponentExts &
];

const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
const tsconfigPath = options?.tsconfigPath
? toArray(options.tsconfigPath)
: undefined;
const isTypeAware = !!tsconfigPath;

const typeAwareRules: FlatConfigItem['rules'] = {
'dot-notation': 'off',
Expand All @@ -51,10 +55,6 @@ export async function typescript(options: OptionsComponentExts &
'ts/unbound-method': 'error',
};

const tsconfigPath = options?.tsconfigPath
? toArray(options.tsconfigPath)
: undefined;

const [
pluginTs,
parserTs,
Expand All @@ -63,16 +63,10 @@ export async function typescript(options: OptionsComponentExts &
interopDefault(import('@typescript-eslint/parser')),
] as const);

return [
{
name: 'petal:typescript:setup',
plugins: {
petal: pluginPetal,
ts: pluginTs as any,
},
},
{
function makeParser(typeAware: boolean, files: string[], ignores?: string[]): FlatConfigItem {
return {
files,
...ignores ? { ignores } : {},
languageOptions: {
parser: parserTs,
parserOptions: {
Expand All @@ -82,15 +76,35 @@ export async function typescript(options: OptionsComponentExts &
ecmaVersion: 'latest',
extraFileExtensions: componentExts.map(e => `.${e}`),
sourceType: 'module',
...(tsconfigPath
...(typeAware
? {
projevt: tsconfigPath,
project: tsconfigPath,
tsconfigRootDir: process.cwd(),
}
: {}),
...(parserOptions as any),
},
},
name: `petal:typescript:${typeAware ? 'type-aware-parser' : 'parser'}`,
};
};

return [
{
name: 'petal:typescript:setup',
plugins: {
petal: pluginPetal,
ts: pluginTs as any,
},
},
...isTypeAware
? [
makeParser(true, filesTypeAware),
makeParser(false, files, filesTypeAware),
]
: [makeParser(false, files)],
{
files,
name: 'petal:typescript:rules',
rules: {
...renameRules(
Expand Down
2 changes: 1 addition & 1 deletion configs/eslint-config/src/configs/vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export async function vue(options: OptionsHasTypeScript & OptionsOverrides & Opt
'PascalCase',
],
'vue/component-options-name-casing': ['error', 'PascalCase'],
'vue/component-tags-order': 'off',
'vue/custom-event-name-casing': ['error', 'camelCase'],
'vue/define-macros-order': [
'error',
Expand All @@ -112,7 +113,6 @@ export async function vue(options: OptionsHasTypeScript & OptionsOverrides & Opt
'vue/multi-word-component-names': 'off',
'vue/no-dupe-keys': 'off',
'vue/no-empty-pattern': 'error',
'vue/no-extra-parens': ['error', 'functions'],
'vue/no-irregular-whitespace': 'error',
'vue/no-loss-of-precision': 'error',
'vue/no-restricted-syntax': [
Expand Down
2 changes: 2 additions & 0 deletions configs/eslint-config/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function petal(
configs.push(typescript({
...resolveSubOptions(options, 'typescript'),
componentExts,
overrides: getOverrides(options, 'typescript'),
}));
}

Expand All @@ -129,6 +130,7 @@ export function petal(
if (enableVue) {
configs.push(vue({
...resolveSubOptions(options, 'vue'),
overrides: getOverrides(options, 'vue'),
stylistic: stylisticOptions,
typescript: !!enableTypeScript,
}));
Expand Down
Loading

0 comments on commit 9c1946e

Please sign in to comment.