Skip to content

Commit

Permalink
chore: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 20, 2022
1 parent bd7da2a commit 7ee8e7f
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"unicorn/no-useless-undefined": 0,
"unicorn/no-await-expression-member": 0,
"unicorn/no-array-push-push": 0,
"unicorn/filename-case": 0
"unicorn/filename-case": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/no-non-null-assertion": 0
}
}
2 changes: 1 addition & 1 deletion scripts/bump-edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function loadPackage(dir: string) {
const save = () =>
fsp.writeFile(pkgPath, JSON.stringify(data, null, 2) + "\n");

const updateDeps = (reviver: Function) => {
const updateDeps = (reviver: (dep: any) => any) => {
for (const type of [
"dependencies",
"devDependencies",
Expand Down
2 changes: 1 addition & 1 deletion src/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const COMPRESSIBLE_MIMES_RE = new Set([
"text/x-component",
"text/x-java-source",
"text/x-script",
"vnd.apple.mpegurl"
"vnd.apple.mpegurl",
]);

function isCompressableMime(mimeType: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function loadOptions(
},
defaults: NitroDefaults,
resolve(id: string) {
const presets = _PRESETS as any as Map<String, NitroConfig>;
const presets = _PRESETS as any as Map<string, NitroConfig>;
let matchedPreset = presets[camelCase(id)] || presets[id];
if (!matchedPreset) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/prerender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export async function prerender(nitro: Nitro) {
// Start prerendering
const generatedRoutes = new Set();
const displayedLengthWarns = new Set();
const canPrerender = (route: string = "/") => {
const canPrerender = (route = "/") => {
// Skip if route is already generated
if (generatedRoutes.has(route)) {
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/rollup/plugins/replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function replace(options: RollupReplaceOptions): Plugin {
// https://github.com/rollup/plugins/blob/master/packages/replace/src/index.js#L94
renderChunk(code, chunk, options) {
if (!NO_REPLACE_RE.test(code)) {
return (_plugin.renderChunk as Function).call(
return (_plugin.renderChunk as () => any).call(
this,
code,
chunk,
Expand Down
2 changes: 1 addition & 1 deletion src/rollup/plugins/server-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { Nitro } from "../../types";
import { virtual } from "./virtual";

export interface ServerAssetOptions {
inline: Boolean;
inline: boolean;
dirs: {
[assetdir: string]: {
dir: string;
Expand Down
2 changes: 2 additions & 0 deletions src/rollup/plugins/timing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { extname } from "pathe";
import type { Plugin, RenderedChunk } from "rollup";

// TODO
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Options {}

const TIMING = "globalThis.__timing__";
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const getEnv = (key: string) => {
function isObject(input: unknown) {
return typeof input === "object" && !Array.isArray(input);
}
function overrideConfig(obj: object, parentKey: string = "") {
function overrideConfig(obj: object, parentKey = "") {
for (const key in obj) {
const subKey = parentKey ? `${parentKey}_${key}` : key;
const envValue = getEnv(subKey);
Expand Down
4 changes: 3 additions & 1 deletion src/runtime/route-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export function getRouteRules(event: H3Event): NitroRouteRules {
event.context._nitro = event.context._nitro || {};
if (!event.context._nitro.routeRules) {
const path = new URL(event.req.url, "http://localhost").pathname;
event.context._nitro.routeRules = getRouteRulesForPath(withoutBase(path, useRuntimeConfig().app.baseURL));
event.context._nitro.routeRules = getRouteRulesForPath(
withoutBase(path, useRuntimeConfig().app.baseURL)
);
}
return event.context._nitro.routeRules;
}
Expand Down
2 changes: 1 addition & 1 deletion src/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function scanMiddleware(nitro: Nitro) {
}));
}

export function scanRoutes(nitro: Nitro, dir: string, prefix: string = "/") {
export function scanRoutes(nitro: Nitro, dir: string, prefix = "/") {
return scanServerDir(nitro, dir, (file) => {
let route = file.path
.replace(/\.[A-Za-z]+$/, "")
Expand Down
7 changes: 4 additions & 3 deletions src/types/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import type { FetchRequest, FetchOptions, FetchResponse } from "ofetch";
import type { MatchedRoutes } from "./utils";

// An interface to extend in a local project
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface InternalApi {}

export type NitroFetchRequest =
| Exclude<keyof InternalApi, `/_${string}` | `/api/_${string}`>
| Exclude<FetchRequest, string>
// eslint-disable-next-line @typescript-eslint/ban-types
| (string & {});

export type MiddlewareOf<
Expand Down Expand Up @@ -92,11 +94,10 @@ export interface $Fetch<
}

declare global {
// eslint-disable-next-line no-var, no-unused-vars
// eslint-disable-next-line no-var
var $fetch: $Fetch;
// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace NodeJS {
// eslint-disable-next-line no-unused-vars
interface Global {
$fetch: $Fetch;
}
Expand Down
1 change: 1 addition & 0 deletions src/types/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ export interface NitroOptions extends PresetOptions {

// General
debug: boolean;
// eslint-disable-next-line @typescript-eslint/ban-types
preset: KebabCase<keyof typeof _PRESETS> | (string & {});
logLevel: LogLevel;
runtimeConfig: {
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const $fetch = {} as $Fetch;

describe("API routes", () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const dynamicString: string = "";
const dynamicString = "";

it("generates types for middleware, unknown and manual typed routes", () => {
expectTypeOf($fetch("/")).toMatchTypeOf<Promise<unknown>>(); // middleware
Expand Down

0 comments on commit 7ee8e7f

Please sign in to comment.