Skip to content

Commit

Permalink
chore: lint using @youcan/lint (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
azuradara authored Jan 7, 2025
1 parent 5bfaa00 commit 308eec2
Show file tree
Hide file tree
Showing 59 changed files with 1,770 additions and 1,672 deletions.
4 changes: 0 additions & 4 deletions .eslintrc

This file was deleted.

49 changes: 48 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
{
"eslint.experimental.useFlatConfig": false
// Disable the default formatter, use eslint instead
"prettier.enable": false,
"editor.formatOnSave": false,

// Auto fix
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},

// Silent the stylistic rules in you IDE, but still auto fix them
"eslint.rules.customizations": [
{ "rule": "style/*", "severity": "off", "fixable": true },
{ "rule": "format/*", "severity": "off", "fixable": true },
{ "rule": "*-indent", "severity": "off", "fixable": true },
{ "rule": "*-spacing", "severity": "off", "fixable": true },
{ "rule": "*-spaces", "severity": "off", "fixable": true },
{ "rule": "*-order", "severity": "off", "fixable": true },
{ "rule": "*-dangle", "severity": "off", "fixable": true },
{ "rule": "*-newline", "severity": "off", "fixable": true },
{ "rule": "*quotes", "severity": "off", "fixable": true },
{ "rule": "*semi", "severity": "off", "fixable": true }
],

// Enable eslint for all supported languages
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
"vue",
"html",
"markdown",
"json",
"json5",
"jsonc",
"yaml",
"toml",
"xml",
"gql",
"graphql",
"astro",
"css",
"less",
"scss",
"pcss",
"postcss"
]
}
5 changes: 5 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import youcan from '@youcan/lint'

export default youcan({
formatters: true,
})
13 changes: 6 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
},
"devDependencies": {
"@types/node": "^18.18.0",
"@youcan/eslint-config": "^2.5.8",
"@youcan/lint": "^3.0.6",
"bumpp": "^9.2.0",
"dotenv": "^16.3.1",
"eslint": "npm:eslint-ts-patch@^8.56.0-0",
"eslint-plugin-format": "^0.1.0",
"eslint-ts-patch": "8.56.0-0",
"eslint": "^9.16.0",
"eslint-plugin-format": "^0.1.3",
"glob": "^11.0.0",
"rollup": "^4.27.4",
"rollup-plugin-node-externals": "^6.1.1",
Expand All @@ -28,10 +27,10 @@
},
"pnpm": {
"overrides": {
"tar@<6.2.1": ">=6.2.1",
"ws@>=8.0.0 <8.17.1": ">=8.17.1",
"braces@<3.0.3": ">=3.0.3",
"ejs@<3.1.10": ">=3.1.10"
"ejs@<3.1.10": ">=3.1.10",
"tar@<6.2.1": ">=6.2.1",
"ws@>=8.0.0 <8.17.1": ">=8.17.1"
}
}
}
8 changes: 4 additions & 4 deletions packages/app/lib/cli/commands/app/dev.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Env, Filesystem, Http, Path, Services, Session, System, Tasks, UI } from '@youcan/cli-kit';
import type { Worker } from '@youcan/cli-kit';
import { bootAppWorker, bootExtensionWorker, bootTunnelWorker, bootWebWorker } from '@/cli/services/dev/workers';
import { APP_CONFIG_FILENAME } from '@/constants';
import { AppCommand } from '@/util/app-command';
import { load } from '@/util/app-loader';
import { APP_CONFIG_FILENAME } from '@/constants';
import { Env, Filesystem, Http, Path, Services, Session, System, Tasks, UI } from '@youcan/cli-kit';

interface Context {
cmd: Dev
workers: Worker.Interface[]
cmd: Dev;
workers: Worker.Interface[];
}

class Dev extends AppCommand {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/lib/cli/commands/app/env/show.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Color, Session, Tasks } from '@youcan/cli-kit';
import { AppCommand } from '@/util/app-command';
import { load } from '@/util/app-loader';
import { Color, Session, Tasks } from '@youcan/cli-kit';

class EnvShow extends AppCommand {
static description = 'Display app environment variables';
Expand Down
4 changes: 2 additions & 2 deletions packages/app/lib/cli/commands/app/generate/extension.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Filesystem, Path, String, Tasks } from '@youcan/cli-kit';
import { AppCommand } from '@/util/app-command';
import type { AppConfig, InitialAppConfig } from '@/types';
import extensions from '@/cli/services/generate/extensions';
import { ensureExtensionDirectoryExists, initThemeExtension } from '@/cli/services/generate/generate';
import { APP_CONFIG_FILENAME } from '@/constants';
import { AppCommand } from '@/util/app-command';
import { Filesystem, Path, String, Tasks } from '@youcan/cli-kit';

class GenerateExtension extends AppCommand {
static description = 'Generate an app extension';
Expand Down
4 changes: 2 additions & 2 deletions packages/app/lib/cli/commands/app/install.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Env, Http, Session, System, Tasks } from '@youcan/cli-kit';
import { load } from '@/util/app-loader';
import { AppCommand } from '@/util/app-command';
import { load } from '@/util/app-loader';
import { Env, Http, Session, System, Tasks } from '@youcan/cli-kit';

export default class Install extends AppCommand {
static description = 'Generate an app installation URL';
Expand Down
4 changes: 2 additions & 2 deletions packages/app/lib/cli/services/dev/workers/app-worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Filesystem, Path, Worker } from '@youcan/cli-kit';
import type DevCommand from '@/cli/commands/app/dev';
import type { App } from '@/types';
import { APP_CONFIG_FILENAME } from '@/constants';
import type DevCommand from '@/cli/commands/app/dev';
import { Filesystem, Path, Worker } from '@youcan/cli-kit';

export default class AppWorker extends Worker.Abstract {
private logger: Worker.Logger;
Expand Down
12 changes: 6 additions & 6 deletions packages/app/lib/cli/services/dev/workers/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type DevCommand from '@/cli/commands/app/dev';
import type { App, Extension, Web } from '@/types';
import type { AppCommand } from '@/util/app-command';
import type { Cli, Services, Worker } from '@youcan/cli-kit';
import ThemeExtensionWorker from './theme-extension-worker';
import WebWorker from './web-worker';
import AppWorker from './app-worker';
import ThemeExtensionWorker from './theme-extension-worker';
import TunnelWorker from './tunnel-worker';
import type { App, Extension, Web } from '@/types';
import type DevCommand from '@/cli/commands/app/dev';
import type { AppCommand } from '@/util/app-command';
import WebWorker from './web-worker';

export interface ExtensionWorkerCtor {
new(command: Cli.Command, app: App, extension: Extension): Worker.Interface
new(command: Cli.Command, app: App, extension: Extension): Worker.Interface;
}

const EXTENSION_WORKERS: Record<string, ExtensionWorkerCtor> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { App, Extension, ExtensionFileDescriptor, ExtensionMetadata } from '@/types';
import type { Cli } from '@youcan/cli-kit';
import { Env, Filesystem, Form, Http, Path, Session, Worker } from '@youcan/cli-kit';
import type { App, Extension, ExtensionFileDescriptor, ExtensionMetadata } from '@/types';

export default class ThemeExtensionWorker extends Worker.Abstract {
private logger: Worker.Logger;
Expand Down
6 changes: 3 additions & 3 deletions packages/app/lib/cli/services/dev/workers/tunnel-worker.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { System, Worker } from '@youcan/cli-kit';

import type { Services } from '@youcan/cli-kit';
import type { App } from '@/types';

import type { AppCommand } from '@/util/app-command';
import type { Services } from '@youcan/cli-kit';
import { System, Worker } from '@youcan/cli-kit';

export default class TunnelWorker extends Worker.Abstract {
private readonly logger: Worker.Logger;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/lib/cli/services/dev/workers/web-worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type Cli, System, Worker } from '@youcan/cli-kit';
import type { App, Web } from '@/types';
import { type Cli, System, Worker } from '@youcan/cli-kit';

export default class WebWorker extends Worker.Abstract {
private logger: Worker.Logger;
Expand Down
12 changes: 6 additions & 6 deletions packages/app/lib/cli/services/generate/generate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Filesystem, Git, Path } from '@youcan/cli-kit';
import type { ExtensionFlavor, ExtensionTemplateType, InitialAppConfig } from '@/types';
import { EXTENSION_CONFIG_FILENAME } from '@/constants';
import { Filesystem, Git, Path } from '@youcan/cli-kit';

export async function ensureExtensionDirectoryExists(name: string) {
const dir = Path.join(Path.cwd(), 'extensions', name);
Expand All @@ -14,11 +14,11 @@ export async function ensureExtensionDirectoryExists(name: string) {
}

export interface InitExtensionOptions {
name: string
app: InitialAppConfig
directory: string
type: ExtensionTemplateType
flavor?: ExtensionFlavor
name: string;
app: InitialAppConfig;
directory: string;
type: ExtensionTemplateType;
flavor?: ExtensionFlavor;
}

export async function initThemeExtension(options: InitExtensionOptions) {
Expand Down
110 changes: 55 additions & 55 deletions packages/app/lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
export interface InitialAppConfig {
[key: string]: unknown
name: string
[key: string]: unknown;
name: string;
}

export type AppConfig = {
id: string
app_url: string
redirect_urls: string[]
id: string;
app_url: string;
redirect_urls: string[];

oauth: {
client_id: string
scopes: string[]
}
client_id: string;
scopes: string[];
};
} & InitialAppConfig;

export interface RemoteAppConfig {
id: string
name: string
app_url: string
owner_id: string
client_id: string
client_secret: string
redirect_urls: string[]
scopes: string[]
id: string;
name: string;
app_url: string;
owner_id: string;
client_id: string;
client_secret: string;
redirect_urls: string[];
scopes: string[];
}

export interface ExtensionConfig {
[key: string]: unknown
type: string
name: string
[key: string]: unknown;
type: string;
name: string;
}

export interface ExtensionFlavor {
name: string
path?: string
value: 'liquid'
name: string;
path?: string;
value: 'liquid';
}

export interface ExtensionTemplateType {
url: string
type: string
flavors: ExtensionFlavor[]
url: string;
type: string;
flavors: ExtensionFlavor[];
}

export interface ExtensionTemplate {
identifier: string
name: string
description: string
types: ExtensionTemplateType[]
identifier: string;
name: string;
description: string;
types: ExtensionTemplateType[];
}

export interface Extension {
// post boot
id?: string
metadata?: ExtensionMetadata
id?: string;
metadata?: ExtensionMetadata;

root: string
config: ExtensionConfig
root: string;
config: ExtensionConfig;
}

export interface WebConfig {
name?: string
name?: string;
commands: {
dev: string
build?: string
}
dev: string;
build?: string;
};
}

export interface Web {
root: string
config: WebConfig
framework?: string
root: string;
config: WebConfig;
framework?: string;
}

export interface App {
root: string
webs: Web[]
config: AppConfig
remote_config?: RemoteAppConfig
root: string;
webs: Web[];
config: AppConfig;
remote_config?: RemoteAppConfig;
network_config?: {
app_url: string
app_port: number
}
extensions: Extension[]
app_url: string;
app_port: number;
};
extensions: Extension[];
}

export interface ExtensionFileDescriptor {
id: string
type: string
name: string
file_name: string
size: number
hash: string
id: string;
type: string;
name: string;
file_name: string;
size: number;
hash: string;
}

export interface ExtensionMetadata {
[key: string]: ExtensionFileDescriptor[]
[key: string]: ExtensionFileDescriptor[];
}
4 changes: 2 additions & 2 deletions packages/app/lib/util/app-command.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Session } from '@youcan/cli-kit';
import { Cli, Env, Filesystem, Http, Path } from '@youcan/cli-kit';
import type { App, RemoteAppConfig } from '@/types';
import type { Session } from '@youcan/cli-kit';
import { APP_CONFIG_FILENAME } from '@/constants';
import { Cli, Env, Filesystem, Http, Path } from '@youcan/cli-kit';

export abstract class AppCommand extends Cli.Command {
protected app!: App;
Expand Down
2 changes: 1 addition & 1 deletion packages/app/lib/util/app-loader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Filesystem, Path } from '@youcan/cli-kit';
import type { App, AppConfig, Extension, ExtensionConfig, Web, WebConfig } from '@/types';
import { APP_CONFIG_FILENAME, DEFAULT_EXTENSIONS_DIR, DEFAULT_WEBS_DIR, EXTENSION_CONFIG_FILENAME, WEB_CONFIG_FILENAME } from '@/constants';
import { Filesystem, Path } from '@youcan/cli-kit';

export async function load() {
const path = Path.resolve(Path.cwd(), APP_CONFIG_FILENAME);
Expand Down
Loading

0 comments on commit 308eec2

Please sign in to comment.