Skip to content

Commit

Permalink
chore: add eslint import
Browse files Browse the repository at this point in the history
  • Loading branch information
geekdada committed May 5, 2024
1 parent f114302 commit c0349a0
Show file tree
Hide file tree
Showing 68 changed files with 555 additions and 47 deletions.
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
},
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:import/recommended',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
Expand All @@ -16,10 +17,30 @@ module.exports = {
sourceType: 'module',
},
plugins: ['@typescript-eslint'],
settings: {
'import/resolver': {
typescript: true,
node: true,
},
},
rules: {
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'import/order': [
'error',
{
groups: [
['builtin', 'external', 'internal'],
'parent',
'sibling',
'index',
'object',
'type',
],
'newlines-between': 'always',
},
],
},
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@
"chai-jest-snapshot": "^2.0.0",
"conventional-changelog-cli": "^2.2.2",
"eslint-config-prettier": "^8.10.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"ini": "^3.0.1",
Expand Down
439 changes: 439 additions & 0 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/run-example.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const execa = require('execa')
const { resolve } = require('path')
const execa = require('execa')
const fs = require('fs-extra')

const { argv } = process
Expand Down
4 changes: 2 additions & 2 deletions src/base-command.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import 'source-map-support/register'
import { resolve } from 'path'
import { Command, Flags, Interfaces, Config } from '@oclif/core'
import { transports } from '@surgio/logger'
import ora from 'ora'
import { resolve } from 'path'
import redis from './redis'

import redis from './redis'
import { CommandConfig } from './types'
import { loadConfig } from './config'
import { errorHandler } from './utils/error-helper'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/check.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// istanbul ignore file
import path from 'path'
import { Args, ux } from '@oclif/core'
import fs from 'fs-extra'
import path from 'path'
import inquirer from 'inquirer'

import BaseCommand from '../base-command'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/clean-cache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// istanbul ignore file
import { ux } from '@oclif/core'
import os from 'os'
import path from 'path'
import { ux } from '@oclif/core'
import fs from 'fs-extra'

import BaseCommand from '../base-command'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/generate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import { Flags } from '@oclif/core'
import fs from 'fs-extra'
import path from 'path'

import BaseCommand from '../base-command'
import { Artifact, getEngine } from '../generator'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/new.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// istanbul ignore file
import { Args } from '@oclif/core'
import { join } from 'path'
import { Args } from '@oclif/core'
import { runner, Logger } from '@royli/hygen'

import BaseCommand from '../base-command'
Expand Down
2 changes: 1 addition & 1 deletion src/commands/upload.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// istanbul ignore file
import path from 'path'
import { Flags } from '@oclif/core'
import OSS from 'ali-oss'
import fs from 'fs-extra'
import dir from 'node-dir'
import path from 'path'

import BaseCommand from '../base-command'
import { setConfig } from '../config'
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs-extra'
import _ from 'lodash'
import path from 'path'
import { URL } from 'url'
import fs from 'fs-extra'
import _ from 'lodash'

import {
INTERNET_TEST_INTERVAL,
Expand Down
1 change: 1 addition & 0 deletions src/filters/filters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FLAGS, TAIWAN } from '../misc/flag_cn'
import { NodeFilterType, NodeTypeEnum } from '../types'

import { reverseFilter, mergeFilters } from './utils'

export const netflixFilter: NodeFilterType = (item) => {
Expand Down
1 change: 1 addition & 0 deletions src/filters/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
PossibleNodeConfigType,
SortedNodeFilterType,
} from '../types'

import {
SortFilterWithSortedFilters,
SortFilterWithSortedKeywords,
Expand Down
3 changes: 2 additions & 1 deletion src/generator/__tests__/artifact.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import test from 'ava'
import { join } from 'path'
import test from 'ava'

import { loadConfig } from '../../config'
import { Artifact } from '../artifact'
import { getEngine } from '../template'
Expand Down
2 changes: 1 addition & 1 deletion src/generator/__tests__/template.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// tslint:disable:no-expression-statement
import { join } from 'path'
import test from 'ava'
import fs from 'fs-extra'
import { join } from 'path'

import {
convertNewSurgeScriptRuleToQuantumultXRewriteRule,
Expand Down
5 changes: 3 additions & 2 deletions src/generator/artifact.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { EventEmitter } from 'events'
import path from 'path'
import { logger } from '@surgio/logger'
import Bluebird from 'bluebird'
import { EventEmitter } from 'events'
import fs from 'fs-extra'
import _ from 'lodash'
import { Environment } from 'nunjucks'
import path from 'path'

import {
CustomProvider,
Expand Down Expand Up @@ -55,6 +55,7 @@ import { resolveDomain } from '../utils/dns'
import { internalFilters, validateFilter } from '../filters'
import { prependFlag, removeFlag } from '../utils/flag'
import { ArtifactValidator } from '../validators'

import { loadLocalSnippet } from './template'
import { render as renderJSON } from './json-template'

Expand Down
2 changes: 1 addition & 1 deletion src/generator/json-template.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path'
import { JsonObject } from 'type-fest'
import _ from 'lodash'
import fs from 'fs-extra'
import { join } from 'path'

type ExtendContext = Record<string, any>

Expand Down
2 changes: 1 addition & 1 deletion src/generator/template.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path'
import fs from 'fs-extra'
import nunjucks from 'nunjucks'
import path from 'path'
import { JsonObject } from 'type-fest'
import YAML from 'yaml'

Expand Down
3 changes: 2 additions & 1 deletion src/provider/BlackSSLProvider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// istanbul ignore file

import { z } from 'zod'
import assert from 'assert'
import { z } from 'zod'

import {
BlackSSLProviderConfig,
Expand All @@ -13,6 +13,7 @@ import { SurgioError } from '../utils'
import { unifiedCache } from '../utils/cache'
import { getProviderCacheMaxage } from '../utils/env-flag'
import httpClient from '../utils/http-client'

import Provider from './Provider'
import { GetNodeListFunction, GetSubscriptionUserInfoFunction } from './types'

Expand Down
3 changes: 2 additions & 1 deletion src/provider/ClashProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import yaml from 'yaml'
import _ from 'lodash'
import { createLogger } from '@surgio/logger'
import { z } from 'zod'

import {
CLASH_META_SUPPORTED_VMESS_NETWORK,
STASH_SUPPORTED_VMESS_NETWORK,
} from '../constant'

import {
ClashProviderConfig,
HttpNodeConfig,
Expand All @@ -31,6 +31,7 @@ import {
parseBitrate,
} from '../utils'
import relayableUrl from '../utils/relayable-url'

import Provider from './Provider'
import { GetNodeListFunction, GetSubscriptionUserInfoFunction } from './types'

Expand Down
3 changes: 2 additions & 1 deletion src/provider/CustomProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
VmessNodeConfig,
} from '../types'
import { SurgioError } from '../utils'
import Provider from './Provider'
import {
WireguardNodeConfigValidator,
ShadowsocksNodeConfigValidator,
Expand All @@ -22,6 +21,8 @@ import {
Hysteria2NodeConfigValidator,
VlessNodeConfigValidator,
} from '../validators'

import Provider from './Provider'
import { GetNodeListFunction, GetNodeListParams } from './types'

export default class CustomProvider extends Provider {
Expand Down
1 change: 1 addition & 0 deletions src/provider/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getProviderCacheMaxage } from '../utils/env-flag'
import httpClient, { getUserAgent } from '../utils/http-client'
import { toMD5, parseSubscriptionUserInfo, SurgioError } from '../utils'
import { ProviderValidator } from '../validators'

import { GetNodeListFunction, GetSubscriptionUserInfoFunction } from './types'

const logger = createLogger({
Expand Down
1 change: 1 addition & 0 deletions src/provider/ShadowsocksJsonSubscribeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from '../types'
import { SurgioError } from '../utils'
import relayableUrl from '../utils/relayable-url'

import Provider from './Provider'
import { GetNodeListFunction } from './types'

Expand Down
1 change: 1 addition & 0 deletions src/provider/ShadowsocksSubscribeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { fromBase64, SurgioError } from '../utils'
import relayableUrl from '../utils/relayable-url'
import { parseSSUri } from '../utils/ss'

import Provider from './Provider'
import { GetNodeListFunction, GetSubscriptionUserInfoFunction } from './types'

Expand Down
3 changes: 2 additions & 1 deletion src/provider/ShadowsocksrSubscribeProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createLogger } from '@surgio/logger'
import assert from 'assert'
import { createLogger } from '@surgio/logger'
import { z } from 'zod'

import {
Expand All @@ -11,6 +11,7 @@ import { fromBase64, SurgioError } from '../utils'
import relayableUrl from '../utils/relayable-url'
import { parseSubscriptionNode } from '../utils/subscription'
import { parseSSRUri } from '../utils/ssr'

import Provider from './Provider'
import { GetNodeListFunction, GetSubscriptionUserInfoFunction } from './types'

Expand Down
3 changes: 2 additions & 1 deletion src/provider/SsdProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createLogger } from '@surgio/logger'
import assert from 'assert'
import { createLogger } from '@surgio/logger'
import bytes from 'bytes'
import { z } from 'zod'

Expand All @@ -11,6 +11,7 @@ import {
} from '../types'
import { decodeStringList, fromBase64, SurgioError } from '../utils'
import relayableUrl from '../utils/relayable-url'

import Provider from './Provider'
import { GetNodeListFunction, GetSubscriptionUserInfoFunction } from './types'

Expand Down
1 change: 1 addition & 0 deletions src/provider/TrojanProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { fromBase64, SurgioError } from '../utils'
import relayableUrl from '../utils/relayable-url'
import { parseTrojanUri } from '../utils/trojan'

import Provider from './Provider'
import { GetNodeListFunction, GetSubscriptionUserInfoFunction } from './types'

Expand Down
3 changes: 2 additions & 1 deletion src/provider/V2rayNSubscribeProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { logger } from '@surgio/logger'
import assert from 'assert'
import { logger } from '@surgio/logger'
import { z } from 'zod'
import _ from 'lodash'

Expand All @@ -12,6 +12,7 @@ import {
import { fromBase64, SurgioError } from '../utils'
import relayableUrl from '../utils/relayable-url'
import { parseSSUri } from '../utils/ss'

import Provider from './Provider'
import { GetNodeListFunction } from './types'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava'
import sinon from 'sinon'
import * as config from '../../config'

import * as config from '../../config'
import { getShadowsocksSubscription } from '../ShadowsocksSubscribeProvider'
import { NodeTypeEnum } from '../../types'

Expand Down
1 change: 1 addition & 0 deletions src/provider/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { PossibleProviderConfigType, SupportProviderEnum } from '../types'
import { ProviderDefineFunction } from '../configurables'

import BlackSSLProvider from './BlackSSLProvider'
import ClashProvider from './ClashProvider'
import CustomProvider from './CustomProvider'
Expand Down
1 change: 1 addition & 0 deletions src/provider/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PossibleNodeConfigType, SubscriptionUserinfo } from '../types'

import BlackSSLProvider from './BlackSSLProvider'
import ClashProvider from './ClashProvider'
import CustomProvider from './CustomProvider'
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { z } from 'zod'

import type { Provider, GetNodeListParams } from './provider'
import {
WireguardNodeConfigValidator,
ProviderValidator,
Expand All @@ -23,6 +22,8 @@ import {
VlessNodeConfigValidator,
} from './validators'

import type { Provider, GetNodeListParams } from './provider'

export enum NodeTypeEnum {
HTTPS = 'https',
HTTP = 'http',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/__tests__/dns.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { promises } from 'dns'
import test from 'ava'
import Bluebird from 'bluebird'
import sinon, { SinonStub } from 'sinon'
import { promises } from 'dns'

import { resolveDomain } from '../dns'

Expand Down
1 change: 1 addition & 0 deletions src/utils/__tests__/flag.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava'

import { addFlagMap, prependFlag, removeFlag } from '../flag'

test.before(() => {
Expand Down
1 change: 1 addition & 0 deletions src/utils/__tests__/ssr.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import test from 'ava'

import { NodeTypeEnum } from '../../types'
import { parseSSRUri } from '../ssr'

Expand Down
4 changes: 2 additions & 2 deletions src/utils/__tests__/tmp-helper.file.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import test from 'ava'
import fs from 'fs-extra'
import path from 'path'
import os from 'os'
import test from 'ava'
import fs from 'fs-extra'
import Bluebird from 'bluebird'

import { TMP_FOLDER_NAME } from '../../constant'
Expand Down
Loading

0 comments on commit c0349a0

Please sign in to comment.