Skip to content

Commit

Permalink
Optimize the scrolling effect & update eslint rules
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouhua committed Jul 9, 2024
1 parent fc0e254 commit 7a501d4
Show file tree
Hide file tree
Showing 17 changed files with 826 additions and 464 deletions.
3 changes: 0 additions & 3 deletions .eslintignore

This file was deleted.

24 changes: 0 additions & 24 deletions .eslintrc

This file was deleted.

8 changes: 4 additions & 4 deletions .typesafe-i18n.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"outputPath": "./i18n/",
"adapters": [],
"$schema": "https://unpkg.com/typesafe-i18n@5.26.2/schema/typesafe-i18n.json"
}
"outputPath": "./i18n/",
"adapters": [],
"$schema": "https://unpkg.com/typesafe-i18n@5.26.2/schema/typesafe-i18n.json"
}
68 changes: 35 additions & 33 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import builtins from 'builtin-modules';
import esbuild from 'esbuild';
import process from 'process';

const banner =
`/*
const banner
= `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
Expand All @@ -12,38 +12,40 @@ if you want to view the source, please visit the github repository of this plugi
const prod = (process.argv[2] === 'production');

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ['main.ts'],
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
...builtins],
format: 'cjs',
target: 'es2018',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
treeShaking: true,
minify: true,
outfile: 'main.js',
banner: {
js: banner,
},
entryPoints: ['main.ts'],
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
...builtins,
],
format: 'cjs',
target: 'es2018',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
treeShaking: true,
minify: true,
outfile: 'main.js',
});

if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
await context.rebuild();
process.exit(0);
}
else {
await context.watch();
}
179 changes: 179 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
import stylistic from '@stylistic/eslint-plugin';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config({
extends: [
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
stylistic.configs['recommended-flat'],
],
plugins: {
'@stylistic': stylistic,
},
languageOptions: {
parserOptions: {
project: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
ignores: [
'main.js',
'typings/**',
],
},
{

rules: {
'no-unused-vars': 'off',
'no-dupe-class-members': 'off',
'no-loop-func': 'off',
'no-shadow': 'off',
'no-unused-expressions': 'off',
'no-use-before-define': 'off',
'no-throw-literal': 'off',
'prefer-destructuring': 'off',

'@stylistic/ban-ts-comment': 'off',
'@stylistic/no-prototype-builtins': 'off',
'@stylistic/no-empty-function': 'off',
'@stylistic/semi': ['error', 'always'],
'@stylistic/arrow-parens': ['error', 'as-needed'],
'@stylistic/array-bracket-newline': 'error',
'@stylistic/array-element-newline': ['error', 'consistent'],
'@stylistic/function-call-argument-newline': ['error', 'consistent'],
'@stylistic/function-call-spacing': ['error', 'never'],
'@stylistic/generator-star-spacing': ['error', 'before'],
'@stylistic/max-len': [
'error', {
code: 120,
ignoreComments: true,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
ignoreTrailingComments: true,
},
],
'@stylistic/linebreak-style': ['error', 'unix'],
'@stylistic/no-confusing-arrow': 'error',
'@stylistic/no-extra-semi': 'error',
'@stylistic/object-curly-newline': [
'error', {
multiline: true,
consistent: true,
},
],
'@stylistic/one-var-declaration-per-line': ['error', 'always'],
'@stylistic/semi-style': ['error', 'last'],
'@stylistic/switch-colon-spacing': ['error', { after: true, before: false }],
'@stylistic/jsx-pascal-case': [
'error', {
allowAllCaps: false,
allowLeadingUnderscore: false,
allowNamespace: true,
},
],
'@stylistic/jsx-props-no-multi-spaces': 'error',
'@stylistic/jsx-self-closing-comp': [
'error', {
component: true,
html: false,
},
],
'@stylistic/jsx-sort-props': [
'error', {
callbacksLast: true,
shorthandFirst: true,
multiline: 'first',
noSortAlphabetically: true,
reservedFirst: true,
},
],
'@stylistic/member-delimiter-style': [
'error', {
multiline: {
delimiter: 'semi',
requireLast: true,
},
multilineDetection: 'brackets',
singleline: {
delimiter: 'semi',
requireLast: true,
},
},
],
'@typescript-eslint/no-floating-promises': 'off',
'@stylistic/object-property-newline': [
'error', {
allowAllPropertiesOnSameLine: true,
},
],

'@typescript-eslint/no-unused-vars': ['error', { args: 'none' }],
'@typescript-eslint/adjacent-overload-signatures': 'error',
'@typescript-eslint/consistent-indexed-object-style': 'error',
'@typescript-eslint/consistent-type-assertions': ['error', { assertionStyle: 'never' }],
'@typescript-eslint/consistent-type-definitions': 'error',
'@typescript-eslint/consistent-type-exports': ['error', { fixMixedExportsWithInlineTypeSpecifier: false }],
'@typescript-eslint/consistent-type-imports': [
'error', {
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
disallowTypeAnnotations: true,
},
],
'@typescript-eslint/member-ordering': ['warn'],
'@typescript-eslint/no-array-delete': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
'@typescript-eslint/no-empty-interface': 'error',
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-invalid-void-type': 'error',
'@typescript-eslint/no-loop-func': 'error',
'@typescript-eslint/no-meaningless-void-operator': 'error',
'@typescript-eslint/no-mixed-enums': 'error',
'@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-shadow': [
'error',
{
builtinGlobals: false,
hoist: 'all',
allow: [],
ignoreTypeValueShadow: false,
ignoreFunctionTypeParameterNameValueShadow: false,
},
],
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'error',
'@typescript-eslint/no-unnecessary-condition': 'error',
'@typescript-eslint/no-unnecessary-qualifier': 'error',
'@typescript-eslint/no-unnecessary-template-expression': 'error',
'@typescript-eslint/no-unused-expressions': [
'error', {
allowShortCircuit: true,
allowTernary: true,
allowTaggedTemplates: true,
},
],
'@typescript-eslint/no-use-before-define': 'error',
'@typescript-eslint/no-useless-empty-export': 'error',
'@typescript-eslint/only-throw-error': 'error',
'@typescript-eslint/prefer-destructuring': 'error',
'@typescript-eslint/prefer-enum-initializers': 'error',
'@typescript-eslint/prefer-find': 'error',
'@typescript-eslint/prefer-for-of': 'error',
'@typescript-eslint/prefer-includes': 'error',
'@typescript-eslint/prefer-namespace-keyword': 'error',
'@typescript-eslint/prefer-optional-chain': 'error',
'@typescript-eslint/prefer-reduce-type-parameter': 'error',
'@typescript-eslint/prefer-string-starts-ends-with': 'error',
'@typescript-eslint/require-array-sort-compare': 'error',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
'@typescript-eslint/unified-signatures': 'error',
},
});
26 changes: 13 additions & 13 deletions i18n/en/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { BaseTranslation } from "../i18n-types";
import type { BaseTranslation } from '../i18n-types';

const en: BaseTranslation = {
setting: {
mode: {
title: "Mode",
description: "By default, display the current heading, the parent heading, and the siblings of the parent heading. In concise mode, only display the current heading and the parent heading.",
default: "Default",
concise: "Concise",
},
max: {
title: "Display quantity limit",
description: 'Maximum number of headings that can be displayed. 0 indicates no limit.'
}
}
setting: {
mode: {
title: 'Mode',
description: 'By default, display the current heading, the parent heading, and the siblings of the parent heading. In concise mode, only display the current heading and the parent heading.',
default: 'Default',
concise: 'Concise',
},
max: {
title: 'Display quantity limit',
description: 'Maximum number of headings that can be displayed. 0 indicates no limit.',
},
},
};

export default en;
15 changes: 7 additions & 8 deletions i18n/formatters.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { FormattersInitializer } from 'typesafe-i18n'
import type { Locales, Formatters } from './i18n-types'
import type { FormattersInitializer } from 'typesafe-i18n';
import type { Locales, Formatters } from './i18n-types';

export const initFormatters: FormattersInitializer<Locales, Formatters> = (locale: Locales) => {
const formatters: Formatters = {
// add your formatter functions here
};

const formatters: Formatters = {
// add your formatter functions here
}

return formatters
}
return formatters;
};
26 changes: 13 additions & 13 deletions i18n/zh/index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { Translation } from "../i18n-types";
import type { Translation } from '../i18n-types';

const zh: Translation = {
setting: {
mode: {
title: "模式",
description: "默认情况下,显示当前标题、父标题和父标题的兄弟标题。简洁模式下,仅显示当前标题和父标题。",
default: "默认",
concise: "简洁",
},
max: {
title: "显示数量限制",
description: '最大显示标题数量,0 表示不限制。',
}
}
setting: {
mode: {
title: '模式',
description: '默认情况下,显示当前标题、父标题和父标题的兄弟标题。简洁模式下,仅显示当前标题和父标题。',
default: '默认',
concise: '简洁',
},
max: {
title: '显示数量限制',
description: '最大显示标题数量,0 表示不限制。',
},
},
};

export default zh;
Loading

0 comments on commit 7a501d4

Please sign in to comment.