Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
sobird committed Nov 18, 2024
1 parent bf834dd commit c4b0ab6
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 92 deletions.
37 changes: 7 additions & 30 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
module.exports = {
root: true,
extends: [
'sobird/react.cjs',
'sobird/typescript-react.cjs',
'sobird/typescript.cjs',
'plugin:@next/next/recommended',
'plugin:@next/next/core-web-vitals',
],
plugins: [
'@next/next',
],
overrides: [
{
files: ['**/*.ts?(x)'],
extends: [
'sobird/typescript-react.cjs',
],
rules: {
'import/prefer-default-export': 'off',
'import/no-extraneous-dependencies': 'off',
'no-param-reassign': [
'error',
{
props: true,
ignorePropertyModificationsFor: [
'ctx', // for Koa routing
'req', // for Express requests
'request', // for Express requests
'res', // for Express responses
'response', // for Express responses
'state', // for store state
'model', // for store state
],
},
],
'prefer-promise-reject-errors': 'off',
},
},
],
overrides: [],
rules: {

'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': 'off',
'no-restricted-syntax': ['error', 'ForInStatement', 'LabeledStatement', 'WithStatement'],
},
};
5 changes: 3 additions & 2 deletions app/dashboard/role/components/role-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

'use client';

import React, { PropsWithChildren } from 'react';
import { Form, Input } from 'antd';
import { RoleFormRule } from '@/zod/role';
import React, { PropsWithChildren } from 'react';

import withActionForm from '@/components/with-action-form';
import { RoleFormRule } from '@/zod/role';

const RoleForm: React.FC<PropsWithChildren> = ({ children }) => {
return (
Expand Down
11 changes: 6 additions & 5 deletions app/dashboard/role/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
* sobird<i@sobird.me> at 2023/12/05 15:10:21 created.
*/

import React from 'react';
import { Button } from 'antd';
import { Metadata } from 'next';
import Link from 'next/link';
import { Button } from 'antd';
import RoleTable from './table';
import { RoleModel } from '@/models';
import React from 'react';

import RoleForm from './components/role-form';
import { createRoleAction } from '@/actions/role';
import withActionFormModal from '@/components/with-action-form-modal';
import { RoleModel } from '@/models';

import RoleForm from './components/role-form';
import RoleTable from './table';

export const metadata: Metadata = {
title: '角色管理',
Expand Down
9 changes: 4 additions & 5 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { subject } from '@casl/ability';
import { getToken } from 'next-auth/jwt';
import { cookies, headers } from 'next/headers';
import { getToken } from 'next-auth/jwt';
import { getCsrfToken } from 'next-auth/react';

import {
LoginButton,
LogoutButton,
ProfileButton,
RegisterButton,
} from '@/components/buttons';

import { defineAbilityFor } from '@/lib/ability';
import { getServerAuthToken } from '@/lib/auth';
import {
UserModel, SessionModel, AccountModel, sequelize,
} from '@/models';

import { defineAbilityFor } from '@/lib/ability';
import { getServerAuthToken } from '@/lib/auth';

const HomePage: IAppPage<{ id: string }> = async () => {
const token = await getServerAuthToken();
console.log('getServerAuthToken', token);
Expand Down
12 changes: 6 additions & 6 deletions models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

import { sequelize } from '@/lib/sequelize';

import User from './user';
import Role from './role';
import Permission from './permission';
import Account from './account';
import Session from './session';
import VerificationToken from './verificationToken';
import Menu from './menu';
import Group from './group';
import Menu from './menu';
import Permission from './permission';
import Role from './role';
// Associations Model
import RolePermission from './role-permission';
import Session from './session';
import User from './user';
import UserRole from './user-role';
import VerificationToken from './verificationToken';

export type { UserAttributes, UserCreationAttributes } from './user';
export type { RoleAttributes, RoleCreationAttributes } from './role';
Expand Down
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
// output: 'standalone',
output: 'standalone',
experimental: {
// typedRoutes: true,
esmExternals: false,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"@types/react": "18.2.38",
"@types/react-dom": "^18.2.17",
"@types/uuid": "^9.0.7",
"eslint-config-sobird": "^0.1.18",
"eslint-config-sobird": "^0.2.14",
"raw-loader": "^4.0.2",
"sass": "^1.69.5",
"typescript": "^5.3.2",
"typescript": "^5.6.3",
"zod-prisma": "^0.5.4"
},
"keywords": [
Expand Down
71 changes: 30 additions & 41 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig to read more about this file */

/* Projects */
"incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
"incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": ["dom", "dom.iterable", "esnext"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"lib": [
"dom",
"dom.iterable",
"esnext"
], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "preserve", /* Specify what JSX code is generated. */// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
Expand All @@ -23,35 +23,27 @@
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */

/* Modules */
"module": "ESNext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"module": "ESNext", /* Specify what module code is generated. */// "rootDir": "./", /* Specify the root folder within your source files. */
"moduleResolution": "bundler", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"paths": {
"@/*": [
"./*"
]
}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
}, /* Specify a set of entries that re-map imports to additional lookup locations. */// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
"allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
"resolveJsonModule": true, /* Enable importing .json files. */
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
"resolveJsonModule": true, /* Enable importing .json files. */// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */

/* JavaScript Support */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
Expand All @@ -61,8 +53,7 @@
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
// "outDir": "./", /* Specify an output folder for all emitted files. */
// "removeComments": true, /* Disable emitting comments. */
"noEmit": true, /* Disable emitting files from a compilation. */
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
"noEmit": true, /* Disable emitting files from a compilation. */// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
Expand All @@ -76,19 +67,13 @@
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */

/* Interop Constraints */
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
"isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": false, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
"strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. *//* Type Checking */
"strict": false, /* Enable all strict type-checking options. */// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
Expand All @@ -105,25 +90,29 @@
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"skipLibCheck": true, /* Skip type checking all .d.ts files. */
"plugins": [
{
"name": "next"
}
]
],
"strictNullChecks": true
},
"include": [
"app.d.ts",
"next-env.d.ts",
".next/types/**/*.ts",
"**/*.ts",
"**/*.tsx",
".eslintrc.cjs"
],
"exclude": [
"node_modules"
"node_modules",
"dist"
],
"ts-node": { "esm": true }
"ts-node": {
"esm": true
}
}

0 comments on commit c4b0ab6

Please sign in to comment.