Skip to content

Commit

Permalink
rework button action code
Browse files Browse the repository at this point in the history
  • Loading branch information
mProjectsCode committed Nov 5, 2024
1 parent 7af4b01 commit 94e5083
Show file tree
Hide file tree
Showing 51 changed files with 1,066 additions and 681 deletions.
5 changes: 0 additions & 5 deletions .eslintignore

This file was deleted.

146 changes: 0 additions & 146 deletions .eslintrc.cjs

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
143 changes: 143 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// @ts-check

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import only_warn from 'eslint-plugin-only-warn';
import no_relative_import_paths from 'eslint-plugin-no-relative-import-paths';
import * as plugin_import from 'eslint-plugin-import';
import eslintPluginSvelte from 'eslint-plugin-svelte';

import projectConfig from './automation/config.json' with { type: 'json' };

/** @type {{files: string[], rules: Record<string, [string, {patterns: {group: string[], message: string }[]}]>}[]} */
const overrides = [];

for (const corePackage of projectConfig.corePackages) {
const patterns = [];

for (const nonCorePackage of projectConfig.packages) {
patterns.push({
group: [`packages/${nonCorePackage}/*`],
message: `Core package "${corePackage}" should not import from the non core "${nonCorePackage}" package.`,
});
}

overrides.push({
files: [`packages/${corePackage}/src/**/*.ts`],
rules: {
'no-restricted-imports': [
'error',
{
patterns: patterns,
},
],
},
});
}

for (const nonCorePackage of projectConfig.packages) {
const patterns = [];

for (const otherNonCorePackage of projectConfig.packages) {
if (otherNonCorePackage === nonCorePackage) {
continue;
}
patterns.push({
group: [`packages/${otherNonCorePackage}/*`],
message: `Non core package "${nonCorePackage}" should not import from the non core "${otherNonCorePackage}" package.`,
});
}

overrides.push({
files: [`packages/${nonCorePackage}/src/**/*.ts`],
rules: {
'no-restricted-imports': [
'error',
{
patterns: patterns,
},
],
},
});
}

const flatOverrides = overrides.map(o => ({
files: o.files,
restrictedImports: o.rules['no-restricted-imports'][1].patterns.map(p => p.group).flat(),
}));

console.log('Import restrictions:');
console.log(flatOverrides);

export default tseslint.config(
{
ignores: ['npm/', 'node_modules/', 'exampleVault/', 'automation/', 'main.js', '**/*.svelte', '**/*.d.ts'],
},
...eslintPluginSvelte.configs['flat/recommended'],
...eslintPluginSvelte.configs['flat/prettier'],
{
files: ['packages/**/*.ts'],
extends: [
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true,
},
},
plugins: {
// @ts-ignore
'only-warn': only_warn,
'no-relative-import-paths': no_relative_import_paths,
import: plugin_import,
},
rules: {
'@typescript-eslint/no-explicit-any': ['warn'],

'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/consistent-type-imports': [
'error',
{ prefer: 'type-imports', fixStyle: 'separate-type-imports' },
],

'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
'import/order': [
'error',
{
'newlines-between': 'never',
alphabetize: { order: 'asc', orderImportKind: 'asc', caseInsensitive: true },
},
],

'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
'@typescript-eslint/restrict-template-expressions': 'off',

'no-relative-import-paths/no-relative-import-paths': ['warn', { allowSameFolder: false }],

'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/explicit-function-return-type': ['warn'],
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/no-unused-expressions': [
'warn',
{
allowShortCircuit: true,
},
],
},
},
...overrides,
);
21 changes: 10 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"test:log": "LOG_TESTS=true bun test --conditions=browser",
"format": "prettier --write --plugin prettier-plugin-svelte .",
"format:check": "prettier --check --plugin prettier-plugin-svelte .",
"lint": "eslint --max-warnings=0 packages/**",
"lint:fix": "eslint --max-warnings=0 --fix packages/**",
"lint": "eslint --max-warnings=0 packages/** --no-warn-ignored",
"lint:fix": "eslint --max-warnings=0 --fix packages/** --no-warn-ignored",
"svelte-check": "svelte-check --compiler-warnings \"unused-export-let:ignore\"",
"types": "tsc -p \"./tsconfig.types.json\"",
"check": "bun run format:check && bun run tsc && bun run svelte-check && bun run lint && bun run test",
Expand All @@ -32,17 +32,15 @@
"@elysiajs/cors": "^1.1.1",
"@happy-dom/global-registrator": "^14.12.3",
"@tsconfig/svelte": "^5.0.4",
"@types/bun": "^1.1.12",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"@types/bun": "^1.1.13",
"builtin-modules": "^4.0.0",
"elysia": "^1.1.23",
"elysia": "^1.1.24",
"esbuild": "^0.24.0",
"esbuild-plugin-copy-watch": "^2.3.1",
"esbuild-svelte": "^0.8.2",
"eslint": "^8.57.1",
"eslint": "^9.14.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-isaacscript": "^3.12.2",
"eslint-plugin-isaacscript": "^4.0.0",
"eslint-plugin-no-relative-import-paths": "^1.5.5",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-svelte": "^2.46.0",
Expand All @@ -51,17 +49,18 @@
"string-argv": "^0.3.2",
"svelte-check": "^4.0.5",
"svelte-preprocess": "^6.0.3",
"tslib": "^2.8.0",
"tslib": "^2.8.1",
"typescript": "^5.6.3",
"typescript-eslint": "^8.13.0",
"yaml": "^2.6.0"
},
"dependencies": {
"@codemirror/legacy-modes": "^6.4.1",
"@codemirror/legacy-modes": "^6.4.2",
"@lemons_dev/parsinom": "^0.0.12",
"itertools-ts": "^1.27.1",
"mathjs": "^13.2.0",
"moment": "^2.30.1",
"svelte": "5.1.4",
"svelte": "^5.1.9",
"zod": "^3.23.8",
"zod-validation-error": "^3.4.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/api/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export abstract class API<Plugin extends IPlugin> {
filePath: string,
scope: BindTargetScope | undefined,
renderChildType: RenderChildType = RenderChildType.INLINE,
position?: NotePosition | undefined,
position?: NotePosition,
honorExcludedSetting: boolean = true,
): FieldMountable {
validateAPIArgs(
Expand Down Expand Up @@ -247,7 +247,7 @@ export abstract class API<Plugin extends IPlugin> {
filePath: string,
scope: BindTargetScope | undefined,
renderChildType: RenderChildType = RenderChildType.INLINE,
position?: NotePosition | undefined,
position?: NotePosition,
honorExcludedSetting: boolean = true,
): FieldMountable {
validateAPIArgs(
Expand Down
Loading

0 comments on commit 94e5083

Please sign in to comment.