Skip to content

Commit

Permalink
style: update eslint stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Apr 11, 2023
1 parent e90ed2e commit 74b7010
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 77 deletions.
27 changes: 19 additions & 8 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
root: true

extends:
- 'plugin:@typescript-eslint/recommended'
- plugin:node/recommended
- plugin:github/recommended
- plugin:promise/recommended
Expand All @@ -16,6 +17,7 @@ extends:
- prettier

plugins:
- '@typescript-eslint'
- node
- github
- promise
Expand All @@ -35,18 +37,18 @@ parser: '@typescript-eslint/parser'

parserOptions:
ecmaVersion: 2020
project: './tsconfig.eslint.json'
project: './tsconfig*.json'

overrides:
- files: '*.{c,m,}ts'
- files: '*.ts'
extends:
- plugin:github/typescript
- plugin:import/typescript
- xo-typescript
- prettier
parserOptions:
ecmaVersion: 2020
project: './tsconfig.eslint.json'
project: './tsconfig*.json'
rules:
'@typescript-eslint/naming-convention':
[
Expand Down Expand Up @@ -78,6 +80,17 @@ overrides:
]
'@typescript-eslint/restrict-template-expressions': off
'@typescript-eslint/no-shadow': warn
'@typescript-eslint/no-unused-vars':
[
warn,
{
args: after-used,
ignoreRestSiblings: true,
varsIgnorePattern: '^_',
argsIgnorePattern: '^_',
},
]
'@typescript-eslint/consistent-type-definitions': [warn, interface]

rules:
notice/notice:
Expand All @@ -92,7 +105,9 @@ rules:
*/
onNonMatchingHeader: append
nonMatchingTolerance: 0.7
unicorn/prefer-node-protocol: off
unicorn/prevent-abbreviations:
[warn, { replacements: { db: false, req: false, doc: false, docs: false } }]
'@typescript-eslint/no-shadow': [warn, { allow: [_] }]
sonarjs/no-duplicate-string: [warn, 5]
sonarjs/cognitive-complexity: warn
eslint-comments/no-unused-disable: off
Expand All @@ -113,7 +128,3 @@ rules:
no-constructor-bind/no-constructor-bind: error
no-constructor-bind/no-constructor-state: error
sort-imports: [warn, { allowSeparatedGroups: true }]
ava/no-ignored-test-files: off
ava/no-import-test-files: off
ava/no-skip-test: warn
ava/no-skip-assert: warn
6 changes: 3 additions & 3 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
spec: '@yarnpkg/plugin-typescript'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.5.0.cjs
11 changes: 5 additions & 6 deletions src/BaseCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import { importable } from './io.js';
/**
* Global config stuff
*/
export type Config<D extends DomainConfig = DomainConfig> = {
export interface Config<D extends DomainConfig = DomainConfig> {
domains?: Record<string, D>;
domain?: string;
token?: string;
tty?: boolean;
ws?: boolean;
};
}

/**
* Internal Config type, with defaults filled out
Expand All @@ -46,7 +46,7 @@ export type IConfig = Record<string, unknown> &
/**
* Config per OADA domain
*/
type DomainConfig = {
interface DomainConfig {
/**
* OADA API token
*/
Expand All @@ -59,7 +59,7 @@ type DomainConfig = {
* Allow passing in an OADAClient?
*/
connection?: Promise<OADAClient>;
};
}

/**
* Defaults for settings
Expand Down Expand Up @@ -108,9 +108,8 @@ async function loadUserConfig(
paths: readonly string[]
): Promise<Partial<Config>> {
const config = {};
for (const path of paths) {
for await (const path of paths) {
try {
// eslint-disable-next-line no-await-in-loop
const { default: userConfig } = (await import(path)) as {
default: unknown;
};
Expand Down
4 changes: 0 additions & 4 deletions src/commands/config/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ export default class ShowConfig extends Command {

static override aliases = ['config'];

static override flags = {
...Command.flags,
};

async run() {
const config = this.iconfig;
console.error(this.configFiles, 'Loading configs');
Expand Down
1 change: 1 addition & 0 deletions src/commands/fs/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default class Copy extends Command {
// eslint-disable-next-line require-yield
await input(conn, `${file}`, this.iconfig, async function* (source) {
for await (const data of source) {
// eslint-disable-next-line security/detect-object-injection
await conn[method]({ path, data: data as any });
}
});
Expand Down
8 changes: 4 additions & 4 deletions src/commands/humanize/humanize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ function humanize(value: unknown): unknown {
return value;
}

type Item = {
interface Item {
k: unknown;
v: unknown;
};
type Transform = {
}
interface Transform {
match(value: Item): boolean;
apply(value: Item): Item;
};
}
const transforms: readonly Transform[] = [
// KSUIDs transform
{
Expand Down
4 changes: 2 additions & 2 deletions src/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import {

import type { IConfig } from './BaseCommand.js';

type Connections = {
interface Connections {
/**
* Default OADA connection
*
* Used when no OADA host is specified (e.g., GET /bookmarks)
*/
connection?: Promise<OADAClient>;
domains: Map<string, Promise<OADAClient>>;
};
}

// Wrap OADAClient with magics
const methods = ['get', 'head', 'put', 'post', 'delete'] as const;
Expand Down
2 changes: 1 addition & 1 deletion src/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async function outputType(outString: string, { tty }: IConfig) {
* @todo make this more extensible?
* @todo support these extensions coming from remote??
*/
export const importable = ['.json6', '.json5', '.hjson', '.ts', '.js'] as const;
export const importable = ['.ts', '.js'] as const;

/**
* Load a support file as JSON
Expand Down
2 changes: 0 additions & 2 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
*/

declare module 'concatjson' {
import { Readable, Stream, type Transform, Writable } from 'node:stream';

export function parse(): Transform;
export function serialize(): Transform;
}
Expand Down
47 changes: 0 additions & 47 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,6 @@ __metadata:
"@oclif/plugin-plugins": ^2.4.4
"@tsconfig/node16": ^1.0.3
"@types/glob": ^8.1.0
"@types/hjson": ^2.4.3
"@types/json5": ^2.2.0
"@types/minimatch": ^5.1.2
"@types/ndjson": ^2.0.1
"@types/node": ^16.18.23
Expand Down Expand Up @@ -505,8 +503,6 @@ __metadata:
gaxios: ^5.1.0
glob: ^10.0.0
globby: ^13.1.3
hjson: ^3.2.2
json-6: ^1.1.4
ksuid: ^3.0.0
minimatch: ^9.0.0
ndjson: ^2.0.0
Expand Down Expand Up @@ -936,13 +932,6 @@ __metadata:
languageName: node
linkType: hard

"@types/hjson@npm:^2.4.3":
version: 2.4.3
resolution: "@types/hjson@npm:2.4.3"
checksum: 4f90e9a41becd3a3ba2636ae7b421e419d102222fcfb729434406bc98cede61a1ecd32bc928f89693d71ab443696bfdb77cb1a7561b6bf44c530ab3506048eef
languageName: node
linkType: hard

"@types/http-cache-semantics@npm:*":
version: 4.0.1
resolution: "@types/http-cache-semantics@npm:4.0.1"
Expand Down Expand Up @@ -971,15 +960,6 @@ __metadata:
languageName: node
linkType: hard

"@types/json5@npm:^2.2.0":
version: 2.2.0
resolution: "@types/json5@npm:2.2.0"
dependencies:
json5: "*"
checksum: a295f489dd53fd075181b9c24d489efc2655d68a80636e5edcb5aa785b0afefe3ac8bb68d613f318e177b4c7a0394690243497d54b1da9ac129ddaa901e28fdb
languageName: node
linkType: hard

"@types/keyv@npm:*":
version: 3.1.4
resolution: "@types/keyv@npm:3.1.4"
Expand Down Expand Up @@ -4202,15 +4182,6 @@ __metadata:
languageName: node
linkType: hard

"hjson@npm:^3.2.2":
version: 3.2.2
resolution: "hjson@npm:3.2.2"
bin:
hjson: bin/hjson
checksum: 556086424f719c82fc8ae880d388e617e88f38213f69a6c380704fa6808790c68f9233ef480cdb22d6f24549b2edfc19aea67ab2c40013b231001f8168d56e33
languageName: node
linkType: hard

"hosted-git-info@npm:^2.1.4":
version: 2.8.9
resolution: "hosted-git-info@npm:2.8.9"
Expand Down Expand Up @@ -4967,15 +4938,6 @@ __metadata:
languageName: node
linkType: hard

"json-6@npm:^1.1.4":
version: 1.1.4
resolution: "json-6@npm:1.1.4"
bin:
json-6: lib/cli.js
checksum: 0cd3df156616646f4f53d7fbf58f08a5f06387744f1bd2c65a2897ff9fc5678b5b5f1f6c2c3c356c1e9136862a8e0275948ddb46afc2d0c105acedfa4811be98
languageName: node
linkType: hard

"json-buffer@npm:3.0.1, json-buffer@npm:~3.0.1":
version: 3.0.1
resolution: "json-buffer@npm:3.0.1"
Expand Down Expand Up @@ -5032,15 +4994,6 @@ __metadata:
languageName: node
linkType: hard

"json5@npm:*":
version: 2.2.1
resolution: "json5@npm:2.2.1"
bin:
json5: lib/cli.js
checksum: 74b8a23b102a6f2bf2d224797ae553a75488b5adbaee9c9b6e5ab8b510a2fc6e38f876d4c77dea672d4014a44b2399e15f2051ac2b37b87f74c0c7602003543b
languageName: node
linkType: hard

"json5@npm:^1.0.1":
version: 1.0.1
resolution: "json5@npm:1.0.1"
Expand Down

0 comments on commit 74b7010

Please sign in to comment.