Skip to content

Commit

Permalink
chore(lint): fix eslint
Browse files Browse the repository at this point in the history
- �change `default export` to `export`
  • Loading branch information
imjuni committed Mar 13, 2024
1 parent f5201bc commit 5264c17
Show file tree
Hide file tree
Showing 124 changed files with 476 additions and 492 deletions.
125 changes: 74 additions & 51 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,28 @@ module.exports = {
es6: true,
node: true,
},
ignorePatterns: ['__test__/*', '__tests__/*', 'examples/*', 'coverage/*', 'dist/*'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
extends: [
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
'airbnb-base',
'airbnb-typescript/base',
'prettier',
'plugin:prettier/recommended',
'plugin:import/errors',
'plugin:import/warnings',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.eslint.json',
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint', 'prettier', 'import'],
rules: {
// ----------------------------------------------------------------------------------------------------------
// eslint
// ----------------------------------------------------------------------------------------------------------
'max-len': [
'error',
{
Expand All @@ -32,30 +36,72 @@ module.exports = {
code: 120,
},
],
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'no-restricted-syntax': [
'error',
{
selector: 'TSEnumDeclaration:not([const=true])',
message: "Don't declare non-const enums",
},
],
// ----------------------------------------------------------------------------------------------------------
// @typescript-eslint
// ----------------------------------------------------------------------------------------------------------
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]+',
match: true,
},
},
{
selector: 'typeAlias',
format: ['PascalCase'],
custom: {
regex: '^T[A-Z]+',
match: true,
},
},
],
'@typescript-eslint/member-delimiter-style': [
'off',
{
multiline: {
delimiter: 'none',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{
varsIgnorePattern: '^_.+$',
argsIgnorePattern: '^_.+$',
ignoreRestSiblings: true,
},
],
'import/extensions': ['off'],
'@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
// static function use this: void
'@typescript-eslint/no-invalid-void-type': ['error', { allowAsThisParameter: true }],
'@typescript-eslint/no-unnecessary-boolean-literal-compare': ['off'],
'no-underscore-dangle': ['error', { allowAfterThis: true }],
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
},
],
// ----------------------------------------------------------------------------------------------------------
// eslint-plugin-import
// ----------------------------------------------------------------------------------------------------------
'import/prefer-default-export': ['off'],
'import/no-default-export': ['error'],
},
overrides: [
{
files: ['**/__test__/*.ts', '**/__tests__/*.ts', 'jest.config.cjs', 'prepublish.cjs'],
files: ['**/scripts/*.js'],
rules: {
'@typescript-eslint/no-unsafe-call': ['off'],
'@typescript-eslint/no-unsafe-assignment': ['off'],
'@typescript-eslint/no-unsafe-argument': ['off'],
'@typescript-eslint/no-unsafe-member-access': ['off'],
'@typescript-eslint/no-explicit-any': ['off'],
'no-console': ['off'],
},
},
Expand All @@ -67,45 +113,22 @@ module.exports = {
},
},
{
files: ['**/*.cjs'],
rules: {
'@typescript-eslint/no-var-requires': ['off'],
'import/no-extraneous-dependencies': ['off'],
},
},
{
files: ['src/cli.ts'],
rules: {
'@typescript-eslint/ban-types': ['off'],
},
},
{
files: ['examples/class-type/**/*.ts', 'examples/schema-type/**/*.ts'],
files: ['**/__tests__/*.ts'],
rules: {
'@typescript-eslint/consistent-type-imports': ['off'],
},
},
{
files: ['src/typeorm/loadDataSource.ts'],
rules: {
'no-restricted-syntax': ['off'],
'guard-for-in': ['off'],
'no-await-in-loop': ['off'],
'@typescript-eslint/no-explicit-any': ['off'],
'@typescript-eslint/no-unsafe-call': ['off'],
'@typescript-eslint/no-unsafe-assignment': ['off'],
'@typescript-eslint/no-unsafe-argument': ['off'],
'@typescript-eslint/no-unsafe-member-access': ['off'],
'@typescript-eslint/no-unsafe-return': ['off'],
'@typescript-eslint/ban-ts-comment': ['off'],
'no-console': ['off'],
},
},
{
files: ['src/creators/writeToImage.ts'],
files: ['vitest.config.ts'],
rules: {
'@typescript-eslint/no-unsafe-argument': ['off'],
'@typescript-eslint/no-unsafe-return': ['off'],
'@typescript-eslint/no-unsafe-assignment': ['off'],
'@typescript-eslint/no-unsafe-member-access': ['off'],
'@typescript-eslint/no-unsafe-call': ['off'],
'@typescript-eslint/no-explicit-any': ['off'],
'no-param-reassign': ['off'],
'import/no-extraneous-dependencies': ['off'],
'import/no-default-export': ['off'],
},
},
],
Expand Down
32 changes: 16 additions & 16 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import buildOptionBuilder from '#/cli/builders/buildOptionBuilder';
import commonOptionBuilder from '#/cli/builders/commonOptionBuilder';
import documentOptionBuilder from '#/cli/builders/documentOptionBuilder';
import outputOptionBuilder from '#/cli/builders/outputOptionBuilder';
import buildDocumentCommandHandler from '#/cli/commands/buildDocumentCommandHandler';
import cleanDocumentCommandHandler from '#/cli/commands/cleanDocumentCommandHandler';
import initConfigCommandHandler from '#/cli/commands/initConfigCommandHandler';
import templateEjectCommandHandler from '#/cli/commands/templateEjectCommandHandler';
import { buildOptionBuilder } from '#/cli/builders/buildOptionBuilder';
import { commonOptionBuilder } from '#/cli/builders/commonOptionBuilder';
import { documentOptionBuilder } from '#/cli/builders/documentOptionBuilder';
import { outputOptionBuilder } from '#/cli/builders/outputOptionBuilder';
import { buildDocumentCommandHandler } from '#/cli/commands/buildDocumentCommandHandler';
import { cleanDocumentCommandHandler } from '#/cli/commands/cleanDocumentCommandHandler';
import { initConfigCommandHandler } from '#/cli/commands/initConfigCommandHandler';
import { templateEjectCommandHandler } from '#/cli/commands/templateEjectCommandHandler';
import { CE_COMMAND_LIST } from '#/configs/const-enum/CE_COMMAND_LIST';
import type IBuildCommandOption from '#/configs/interfaces/IBuildCommandOption';
import type ICommonOption from '#/configs/interfaces/ICommonOption';
import preLoadConfig from '#/configs/modules/preLoadConfig';
import type { IBuildCommandOption } from '#/configs/interfaces/IBuildCommandOption';
import type { ICommonOption } from '#/configs/interfaces/ICommonOption';
import { preLoadConfig } from '#/configs/modules/preLoadConfig';
import consola from 'consola';
import { isError } from 'my-easy-fp';
import sourceMapSupport from 'source-map-support';
Expand Down Expand Up @@ -56,7 +56,7 @@ const cleanCmdModule: CommandModule<ICommonOption, ICommonOption> = {
},
};

const initCmdModule: CommandModule<{}, {}> = {
const initCmdModule: CommandModule<object, object> = {
command: CE_COMMAND_LIST.INIT,
aliases: CE_COMMAND_LIST.INIT_ALIAS,
describe: 'generate configuration file: `.erdiarc`',
Expand Down Expand Up @@ -91,10 +91,10 @@ const ejectCmdModule: CommandModule<Pick<ICommonOption, 'output'>, Pick<ICommonO
const parser = yargs(hideBin(process.argv));

parser
.command(buildCmdModule as CommandModule<{}, IBuildCommandOption>)
.command(cleanCmdModule as CommandModule<{}, ICommonOption>)
.command(initCmdModule as CommandModule<{}, ICommonOption>)
.command(ejectCmdModule as CommandModule<{}, ICommonOption>)
.command(buildCmdModule as CommandModule<object, IBuildCommandOption>)
.command(cleanCmdModule as CommandModule<object, ICommonOption>)
.command(initCmdModule as CommandModule<object, ICommonOption>)
.command(ejectCmdModule as CommandModule<object, ICommonOption>)
.demandCommand()
.recommendCommands()
.config(preLoadConfig())
Expand Down
2 changes: 1 addition & 1 deletion src/cli/builders/buildOptionBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Argv } from 'yargs';

export default function buildOptionBuilder<T>(args: Argv<T>) {
export function buildOptionBuilder<T>(args: Argv<T>) {
// option
args

Expand Down
4 changes: 2 additions & 2 deletions src/cli/builders/commonOptionBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import outputOptionBuilder from '#/cli/builders/outputOptionBuilder';
import { outputOptionBuilder } from '#/cli/builders/outputOptionBuilder';
import type { Argv } from 'yargs';

export default function commonOptionBuilder<T>(args: Argv<T>) {
export function commonOptionBuilder<T>(args: Argv<T>) {
// option
outputOptionBuilder(args)
.option('config', {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/builders/documentOptionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CE_OUTPUT_FORMAT } from '#/configs/const-enum/CE_OUTPUT_FORMAT';
import { CE_PROJECT_NAME_FROM } from '#/configs/const-enum/CE_PROJECT_NAME_FROM';
import type { Argv } from 'yargs';

export default function documentOptionBuilder<T>(args: Argv<T>) {
export function documentOptionBuilder<T>(args: Argv<T>) {
// option
args
.option('components', {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/builders/outputOptionBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Argv } from 'yargs';

export default function outputOptionBuilder<T>(args: Argv<T>) {
export function outputOptionBuilder<T>(args: Argv<T>) {
// option
args.option('output', {
alias: 'o',
Expand Down
46 changes: 23 additions & 23 deletions src/cli/commands/buildDocumentCommandHandler.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import getDatabaseName from '#/common/getDatabaseName';
import getMetadata from '#/common/getMetadata';
import { getDatabaseName } from '#/common/getDatabaseName';
import { getMetadata } from '#/common/getMetadata';
import { CE_MERMAID_THEME } from '#/configs/const-enum/CE_MERMAID_THEME';
import { CE_OUTPUT_FORMAT } from '#/configs/const-enum/CE_OUTPUT_FORMAT';
import type IBuildCommandOption from '#/configs/interfaces/IBuildCommandOption';
import createHtml from '#/creators/createHtml';
import createImageHtml from '#/creators/createImageHtml';
import createMarkdown from '#/creators/createMarkdown';
import createPdfHtml from '#/creators/createPdfHtml';
import getRenderData from '#/creators/getRenderData';
import type IReason from '#/creators/interfaces/IReason';
import writeToImage from '#/creators/writeToImage';
import writeToPdf from '#/creators/writeToPdf';
import compareDatabase from '#/databases/compareDatabase';
import flushDatabase from '#/databases/flushDatabase';
import type IRelationRecord from '#/databases/interfaces/IRelationRecord';
import openDatabase from '#/databases/openDatabase';
import processDatabase from '#/databases/processDatabase';
import type { IBuildCommandOption } from '#/configs/interfaces/IBuildCommandOption';
import { createHtml } from '#/creators/createHtml';
import { createImageHtml } from '#/creators/createImageHtml';
import { createMarkdown } from '#/creators/createMarkdown';
import { createPdfHtml } from '#/creators/createPdfHtml';
import { getRenderData } from '#/creators/getRenderData';
import type { IReason } from '#/creators/interfaces/IReason';
import { writeToImage } from '#/creators/writeToImage';
import { writeToPdf } from '#/creators/writeToPdf';
import { compareDatabase } from '#/databases/compareDatabase';
import { flushDatabase } from '#/databases/flushDatabase';
import type { IRelationRecord } from '#/databases/interfaces/IRelationRecord';
import { openDatabase } from '#/databases/openDatabase';
import { processDatabase } from '#/databases/processDatabase';
import { loadTemplates } from '#/template/loadTemplates';
import getColumnRecord from '#/typeorm/columns/getColumnRecord';
import getEntityRecords from '#/typeorm/entities/getEntityRecords';
import getDataSource from '#/typeorm/getDataSource';
import getIndexRecords from '#/typeorm/indices/getIndexRecords';
import dedupeManaToManyRelationRecord from '#/typeorm/relations/dedupeManaToManyRelationRecord';
import getRelationRecords from '#/typeorm/relations/getRelationRecords';
import { getColumnRecord } from '#/typeorm/columns/getColumnRecord';
import { getEntityRecords } from '#/typeorm/entities/getEntityRecords';
import { getDataSource } from '#/typeorm/getDataSource';
import { getIndexRecords } from '#/typeorm/indices/getIndexRecords';
import { dedupeManaToManyRelationRecord } from '#/typeorm/relations/dedupeManaToManyRelationRecord';
import { getRelationRecords } from '#/typeorm/relations/getRelationRecords';
import { showLogo } from '@maeum/cli-logo';
import chalk from 'chalk';
import consola from 'consola';
Expand All @@ -32,7 +32,7 @@ import { isFail, isPass, type IFail, type IPass } from 'my-only-either';
import fs from 'node:fs';
import type { DataSource } from 'typeorm';

export default async function buildDocumentCommandHandler(option: IBuildCommandOption) {
export async function buildDocumentCommandHandler(option: IBuildCommandOption) {
let localDataSource: DataSource | undefined;

try {
Expand Down
12 changes: 6 additions & 6 deletions src/cli/commands/cleanDocumentCommandHandler.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import getMetadata from '#/common/getMetadata';
import { getMetadata } from '#/common/getMetadata';
import { CE_DEFAULT_VALUE } from '#/configs/const-enum/CE_DEFAULT_VALUE';
import type ICommonOption from '#/configs/interfaces/ICommonOption';
import getCwd from '#/configs/modules/getCwd';
import getOutputDirectory from '#/tools/files/getOutputDirectory';
import getDataSource from '#/typeorm/getDataSource';
import type { ICommonOption } from '#/configs/interfaces/ICommonOption';
import { getCwd } from '#/configs/modules/getCwd';
import { getOutputDirectory } from '#/tools/files/getOutputDirectory';
import { getDataSource } from '#/typeorm/getDataSource';
import { showLogo } from '@maeum/cli-logo';
import consola from 'consola';
import del from 'del';
Expand All @@ -12,7 +12,7 @@ import { isError, isFalse } from 'my-easy-fp';
import path from 'path';
import type { DataSource } from 'typeorm';

export default async function cleanDocumentCommandHandler(option: ICommonOption) {
export async function cleanDocumentCommandHandler(option: ICommonOption) {
let localDataSource: DataSource | undefined;

try {
Expand Down
6 changes: 3 additions & 3 deletions src/cli/commands/initConfigCommandHandler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { CE_DEFAULT_VALUE } from '#/configs/const-enum/CE_DEFAULT_VALUE';
import getConfigContent from '#/configs/modules/getConfigContent';
import applyPrettier from '#/creators/applyPretter';
import { getConfigContent } from '#/configs/modules/getConfigContent';
import { applyPrettier } from '#/creators/applyPretter';
import consola from 'consola';
import fs from 'fs';

export default async function initConfigCommandHandler() {
export async function initConfigCommandHandler() {
const rawConfig = await getConfigContent();
const prettiered = await applyPrettier(rawConfig, 'json');

Expand Down
10 changes: 5 additions & 5 deletions src/cli/commands/templateEjectCommandHandler.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type ICommonOption from '#/configs/interfaces/ICommonOption';
import getCwd from '#/configs/modules/getCwd';
import type { ICommonOption } from '#/configs/interfaces/ICommonOption';
import { getCwd } from '#/configs/modules/getCwd';
import { CE_TEMPLATE_NAME } from '#/template/cosnt-enum/CE_TEMPLATE_NAME';
import defaultTemplates from '#/template/defaultTemplates';
import getOutputDirectory from '#/tools/files/getOutputDirectory';
import { defaultTemplates } from '#/template/defaultTemplates';
import { getOutputDirectory } from '#/tools/files/getOutputDirectory';
import { showLogo } from '@maeum/cli-logo';
import consola from 'consola';
import fs from 'fs';
import { isFalse } from 'my-easy-fp';
import { exists, getDirname } from 'my-node-fp';
import path from 'path';

export default async function templateEjectCommandHandler(option: Pick<ICommonOption, 'output' | 'showLogo'>) {
export async function templateEjectCommandHandler(option: Pick<ICommonOption, 'output' | 'showLogo'>) {
if (option.showLogo != null) {
await showLogo({
message: 'erdia',
Expand Down
6 changes: 3 additions & 3 deletions src/common/__tests__/common.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import getDatabaseName from '#/common/getDatabaseName';
import getPlainRelationType from '#/common/getPlainRelationType';
import getRelationHash from '#/common/getRelationHash';
import { getDatabaseName } from '#/common/getDatabaseName';
import { getPlainRelationType } from '#/common/getPlainRelationType';
import { getRelationHash } from '#/common/getRelationHash';
import 'jest';

describe('getDatabaseName', () => {
Expand Down
Loading

0 comments on commit 5264c17

Please sign in to comment.