Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ccb499066 | |||
| 65eb2ce3cb |
@@ -1,9 +1,10 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import yaml from 'js-yaml';
|
|
||||||
import { themes as prismThemes } from 'prism-react-renderer';
|
|
||||||
import type { Config } from '@docusaurus/types';
|
|
||||||
import type * as Preset from '@docusaurus/preset-classic';
|
import type * as Preset from '@docusaurus/preset-classic';
|
||||||
import type { NavbarItem } from '@docusaurus/theme-common';
|
import type { NavbarItem } from '@docusaurus/theme-common';
|
||||||
|
import type { Config } from '@docusaurus/types';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
|
import { themes as prismThemes } from 'prism-react-renderer';
|
||||||
|
|
||||||
interface DocsConfig {
|
interface DocsConfig {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -19,7 +20,7 @@ const url = process.env.DOCUSERVIX_URL;
|
|||||||
|
|
||||||
const { org, repo } = docsConfig.project;
|
const { org, repo } = docsConfig.project;
|
||||||
|
|
||||||
const { docs: docsDir = 'docs', blog: blogDir } = docsConfig.dirs || {};
|
const { docs: _docsDir = 'docs', blog: blogDir } = docsConfig.dirs || {};
|
||||||
|
|
||||||
const giteaUrl = 'https://git.jt4d.ru';
|
const giteaUrl = 'https://git.jt4d.ru';
|
||||||
const onBrokenLinks =
|
const onBrokenLinks =
|
||||||
@@ -116,7 +117,8 @@ const config: Config = {
|
|||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
style: 'dark',
|
style: 'dark',
|
||||||
copyright: `Проект хостится на JT4D.ru, документация собрана с использованием Docuservix и Docusaurus.`,
|
copyright:
|
||||||
|
'Проект хостится на JT4D.ru, документация собрана с использованием Docuservix и Docusaurus.',
|
||||||
},
|
},
|
||||||
prism: {
|
prism: {
|
||||||
theme: prismThemes.github,
|
theme: prismThemes.github,
|
||||||
|
|||||||
@@ -0,0 +1,351 @@
|
|||||||
|
import path from 'node:path';
|
||||||
|
import { fileURLToPath } from 'node:url';
|
||||||
|
|
||||||
|
import { fixupPluginRules } from '@eslint/compat';
|
||||||
|
import { FlatCompat } from '@eslint/eslintrc';
|
||||||
|
import js from '@eslint/js';
|
||||||
|
import typescriptEslint from '@typescript-eslint/eslint-plugin';
|
||||||
|
import tsParser from '@typescript-eslint/parser';
|
||||||
|
import etc from 'eslint-plugin-etc';
|
||||||
|
import _import from 'eslint-plugin-import';
|
||||||
|
import noOnlyTests from 'eslint-plugin-no-only-tests';
|
||||||
|
import noSkipTests from 'eslint-plugin-no-skip-tests';
|
||||||
|
import react from 'eslint-plugin-react';
|
||||||
|
import reactHooks from 'eslint-plugin-react-hooks';
|
||||||
|
import unusedImports from 'eslint-plugin-unused-imports';
|
||||||
|
import globals from 'globals';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
const compat = new FlatCompat({
|
||||||
|
baseDirectory: __dirname,
|
||||||
|
recommendedConfig: js.configs.recommended,
|
||||||
|
allConfig: js.configs.all,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
ignores: [
|
||||||
|
'**/.eslintrc.js',
|
||||||
|
'**/node_modules',
|
||||||
|
'**/coverage',
|
||||||
|
'**/build',
|
||||||
|
'**/.docusaurus',
|
||||||
|
'**/vite.config.*.timestamp*',
|
||||||
|
'**/vitest.config.*.timestamp*',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
...compat.extends(
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:prettier/recommended',
|
||||||
|
'prettier',
|
||||||
|
'plugin:eslint-comments/recommended',
|
||||||
|
),
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
import: fixupPluginRules(_import),
|
||||||
|
react,
|
||||||
|
'react-hooks': fixupPluginRules(reactHooks),
|
||||||
|
'@typescript-eslint': typescriptEslint,
|
||||||
|
etc,
|
||||||
|
'no-only-tests': noOnlyTests,
|
||||||
|
'no-skip-tests': noSkipTests,
|
||||||
|
'unused-imports': unusedImports,
|
||||||
|
},
|
||||||
|
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...globals.jest,
|
||||||
|
},
|
||||||
|
|
||||||
|
parser: tsParser,
|
||||||
|
ecmaVersion: 6,
|
||||||
|
sourceType: 'module',
|
||||||
|
|
||||||
|
parserOptions: {
|
||||||
|
ecmaFeatures: {
|
||||||
|
modules: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
settings: {
|
||||||
|
'import/resolver': {
|
||||||
|
node: {
|
||||||
|
extensions: ['.js', '.ts', '.tsx', '.json'],
|
||||||
|
},
|
||||||
|
|
||||||
|
typescript: {
|
||||||
|
alwaysTryTypes: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
react: {
|
||||||
|
version: 'detect',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/interface-name-prefix': 'off',
|
||||||
|
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||||
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||||
|
|
||||||
|
curly: ['error', 'all'],
|
||||||
|
'max-params': 'off',
|
||||||
|
|
||||||
|
'no-console': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
allow: ['warn', 'error'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'no-warning-comments': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
terms: ['fixme'],
|
||||||
|
location: 'anywhere',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'no-unused-vars': 'off',
|
||||||
|
'space-before-blocks': 'error',
|
||||||
|
|
||||||
|
'padding-line-between-statements': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
blankLine: 'always',
|
||||||
|
prev: '*',
|
||||||
|
next: ['break', 'continue', 'return'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
blankLine: 'always',
|
||||||
|
prev: ['const', 'let'],
|
||||||
|
next: '*',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
blankLine: 'any',
|
||||||
|
prev: ['const', 'let'],
|
||||||
|
next: ['const', 'let'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
blankLine: 'always',
|
||||||
|
prev: 'directive',
|
||||||
|
next: '*',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
blankLine: 'any',
|
||||||
|
prev: 'directive',
|
||||||
|
next: 'directive',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
blankLine: 'always',
|
||||||
|
prev: 'block-like',
|
||||||
|
next: '*',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
blankLine: 'always',
|
||||||
|
prev: '*',
|
||||||
|
next: 'block-like',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'import/order': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
pathGroups: [
|
||||||
|
{
|
||||||
|
pattern: 'react,bem-css-modules',
|
||||||
|
group: 'builtin',
|
||||||
|
position: 'before',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
pattern: '@docuservix/**',
|
||||||
|
group: 'internal',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
pathGroupsExcludedImportTypes: ['react'],
|
||||||
|
'newlines-between': 'always',
|
||||||
|
groups: ['builtin', 'external', 'internal', 'parent', ['sibling', 'index']],
|
||||||
|
|
||||||
|
alphabetize: {
|
||||||
|
order: 'asc',
|
||||||
|
caseInsensitive: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'react/no-direct-mutation-state': 'error',
|
||||||
|
'react/no-deprecated': 'error',
|
||||||
|
'react/no-unsafe': 'error',
|
||||||
|
'react/jsx-uses-vars': 'error',
|
||||||
|
'react/jsx-uses-react': 'error',
|
||||||
|
'react/jsx-curly-brace-presence': ['error', 'never'],
|
||||||
|
'react-hooks/rules-of-hooks': 'error',
|
||||||
|
'react-hooks/exhaustive-deps': 'warn',
|
||||||
|
|
||||||
|
quotes: [
|
||||||
|
'error',
|
||||||
|
'single',
|
||||||
|
{
|
||||||
|
avoidEscape: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'quote-props': ['warn', 'as-needed'],
|
||||||
|
|
||||||
|
'@typescript-eslint/no-explicit-any': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
ignoreRestArgs: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'@typescript-eslint/member-ordering': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
default: [
|
||||||
|
'public-static-field',
|
||||||
|
'protected-static-field',
|
||||||
|
'private-static-field',
|
||||||
|
|
||||||
|
'public-instance-field',
|
||||||
|
'protected-instance-field',
|
||||||
|
'private-instance-field',
|
||||||
|
|
||||||
|
'constructor',
|
||||||
|
|
||||||
|
'public-instance-method',
|
||||||
|
'protected-instance-method',
|
||||||
|
'private-instance-method',
|
||||||
|
|
||||||
|
'public-static-method',
|
||||||
|
'protected-static-method',
|
||||||
|
'private-static-method',
|
||||||
|
|
||||||
|
'signature',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'etc/prefer-interface': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
allowLocal: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'@typescript-eslint/ban-ts-comment': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'ts-ignore': 'allow-with-description',
|
||||||
|
'ts-nocheck': 'allow-with-description',
|
||||||
|
'ts-check': false,
|
||||||
|
'ts-expect-error': false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'@typescript-eslint/no-empty-interface': 'warn',
|
||||||
|
'@typescript-eslint/no-empty-function': 'warn',
|
||||||
|
'@typescript-eslint/no-unused-vars': 'off',
|
||||||
|
// todo изучить и включить
|
||||||
|
'@typescript-eslint/no-unused-expressions': 'off',
|
||||||
|
|
||||||
|
// todo изучить и включить
|
||||||
|
'@typescript-eslint/no-empty-object-type': 'off',
|
||||||
|
|
||||||
|
'no-restricted-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
paths: [
|
||||||
|
{
|
||||||
|
name: '@nestjs/swagger',
|
||||||
|
importNames: ['PartialType'],
|
||||||
|
message:
|
||||||
|
"Please import 'PartialType' from '@src/server/common/nest' instead.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'react-bootstrap',
|
||||||
|
importNames: [
|
||||||
|
'Card',
|
||||||
|
'CardHeader',
|
||||||
|
'CardBody',
|
||||||
|
'CardFooter',
|
||||||
|
'Row',
|
||||||
|
'Col',
|
||||||
|
'Modal',
|
||||||
|
],
|
||||||
|
message: "Please use project's components with same name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'react-bootstrap/Modal',
|
||||||
|
message: "Please use project's components with same name",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '@nestjs/common',
|
||||||
|
importNames: ['Logger'],
|
||||||
|
message: "Please import 'Logger' from '@src/server/logger' instead.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'nestjs-pino',
|
||||||
|
importNames: ['Logger', 'PinoLogger'],
|
||||||
|
message: "Please import 'Logger' from '@src/server/logger' instead.",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'unused-imports/no-unused-imports': 'error',
|
||||||
|
|
||||||
|
'unused-imports/no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
vars: 'all',
|
||||||
|
args: 'after-used',
|
||||||
|
ignoreRestSiblings: true,
|
||||||
|
argsIgnorePattern: '^_',
|
||||||
|
varsIgnorePattern: '^_',
|
||||||
|
caughtErrorsIgnorePattern: '^_',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'eslint-comments/require-description': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
ignore: ['eslint-enable'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'eslint-comments/disable-enable-pair': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
allowWholeFile: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
complexity: ['warn', 10],
|
||||||
|
eqeqeq: ['error'],
|
||||||
|
'func-style': ['warn', 'declaration'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['**/*.spec.{js,jsx,ts,tsx}'],
|
||||||
|
|
||||||
|
rules: {
|
||||||
|
'no-only-tests/no-only-tests': 'error',
|
||||||
|
'no-skip-tests/no-skip-tests': 'warn',
|
||||||
|
|
||||||
|
'no-console': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
allow: ['warn', 'error'],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
+25
-1
@@ -7,6 +7,10 @@
|
|||||||
"clear": "docusaurus clear",
|
"clear": "docusaurus clear",
|
||||||
"deploy": "docusaurus deploy",
|
"deploy": "docusaurus deploy",
|
||||||
"docusaurus": "docusaurus",
|
"docusaurus": "docusaurus",
|
||||||
|
"eslint:check": "yarn eslint",
|
||||||
|
"eslint:fix": "yarn eslint --fix",
|
||||||
|
"lint": "run-s eslint:fix prettier:fix",
|
||||||
|
"lint:check": "run-s eslint:check prettier:check",
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"prettier:check": "prettier --check \"**/*.{ts,tsx,js,mjs,json,yml,yaml,md,mdx}\"",
|
"prettier:check": "prettier --check \"**/*.{ts,tsx,js,mjs,json,yml,yaml,md,mdx}\"",
|
||||||
"prettier:fix": "prettier --write \"**/*.{ts,tsx,js,mjs,json,yml,yaml,md,mdx}\"",
|
"prettier:fix": "prettier --write \"**/*.{ts,tsx,js,mjs,json,yml,yaml,md,mdx}\"",
|
||||||
@@ -18,7 +22,8 @@
|
|||||||
"write-translations": "docusaurus write-translations"
|
"write-translations": "docusaurus write-translations"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{json,ts,tsx,js,jsx,js,mjs,md,mdx,yaml,yml}": "prettier --write"
|
"*.{json,ts,tsx,js,jsx,js,mjs,md,mdx,yaml,yml}": "prettier --write",
|
||||||
|
"{src,e2e}/**/*.{ts,tsx}": "eslint --quiet --fix"
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
@@ -48,10 +53,29 @@
|
|||||||
"@docusaurus/module-type-aliases": "3.10.1",
|
"@docusaurus/module-type-aliases": "3.10.1",
|
||||||
"@docusaurus/tsconfig": "3.10.1",
|
"@docusaurus/tsconfig": "3.10.1",
|
||||||
"@docusaurus/types": "3.10.1",
|
"@docusaurus/types": "3.10.1",
|
||||||
|
"@eslint/compat": "^1.1.1",
|
||||||
|
"@eslint/eslintrc": "^3.1.0",
|
||||||
|
"@eslint/js": "^9.8.0",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/react": "^19.0.0",
|
"@types/react": "^19.0.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
||||||
|
"@typescript-eslint/parser": "^8.0.0",
|
||||||
|
"eslint": "^9.8.0",
|
||||||
|
"eslint-config-prettier": "^9.1.0",
|
||||||
|
"eslint-import-resolver-typescript": "^4.4.5",
|
||||||
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||||
|
"eslint-plugin-etc": "^2.0.3",
|
||||||
|
"eslint-plugin-import": "^2.32.0",
|
||||||
|
"eslint-plugin-no-only-tests": "^3.1.0",
|
||||||
|
"eslint-plugin-no-skip-tests": "^1.1.0",
|
||||||
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
|
"eslint-plugin-react": "^7.37.5",
|
||||||
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
|
"eslint-plugin-unused-imports": "^4.0.1",
|
||||||
|
"globals": "^17.6.0",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"lint-staged": "^17.0.7",
|
"lint-staged": "^17.0.7",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^3.8.4",
|
"prettier": "^3.8.4",
|
||||||
"typescript": "~6.0.2"
|
"typescript": "~6.0.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable no-console -- logs required */
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
@@ -10,16 +12,25 @@ pinIndexToTop();
|
|||||||
*/
|
*/
|
||||||
function pinIndexToTop() {
|
function pinIndexToTop() {
|
||||||
const indexPath = path.join(docsDir, 'index.md');
|
const indexPath = path.join(docsDir, 'index.md');
|
||||||
if (!fs.existsSync(indexPath)) return;
|
|
||||||
|
if (!fs.existsSync(indexPath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let content = fs.readFileSync(indexPath, 'utf8');
|
let content = fs.readFileSync(indexPath, 'utf8');
|
||||||
|
|
||||||
if (content.startsWith('---\n')) {
|
if (content.startsWith('---\n')) {
|
||||||
const endIdx = content.indexOf('\n---\n', 4);
|
const endIdx = content.indexOf('\n---\n', 4);
|
||||||
if (endIdx === -1) return;
|
|
||||||
|
if (endIdx === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const frontMatter = content.slice(4, endIdx);
|
const frontMatter = content.slice(4, endIdx);
|
||||||
if (/^sidebar_position\s*:/m.test(frontMatter)) return;
|
|
||||||
|
if (/^sidebar_position\s*:/m.test(frontMatter)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
content =
|
content =
|
||||||
'---\nsidebar_position: 0\n' + frontMatter + '\n---\n' + content.slice(endIdx + 5);
|
'---\nsidebar_position: 0\n' + frontMatter + '\n---\n' + content.slice(endIdx + 5);
|
||||||
|
|||||||
+5
-3
@@ -1,14 +1,15 @@
|
|||||||
import type { ReactNode } from 'react';
|
|
||||||
import clsx from 'clsx';
|
|
||||||
import Link from '@docusaurus/Link';
|
import Link from '@docusaurus/Link';
|
||||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
import Layout from '@theme/Layout';
|
|
||||||
import Heading from '@theme/Heading';
|
import Heading from '@theme/Heading';
|
||||||
|
import Layout from '@theme/Layout';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
import styles from './index.module.css';
|
import styles from './index.module.css';
|
||||||
|
|
||||||
function HomepageHeader() {
|
function HomepageHeader() {
|
||||||
const { siteConfig } = useDocusaurusContext();
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className={clsx('hero hero--primary', styles.heroBanner)}>
|
<header className={clsx('hero hero--primary', styles.heroBanner)}>
|
||||||
<div className="container">
|
<div className="container">
|
||||||
@@ -34,6 +35,7 @@ function HomepageHeader() {
|
|||||||
|
|
||||||
export default function Home(): ReactNode {
|
export default function Home(): ReactNode {
|
||||||
const { siteConfig } = useDocusaurusContext();
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout
|
<Layout
|
||||||
title={`Hello from ${siteConfig.title}`}
|
title={`Hello from ${siteConfig.title}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user