Skip to content

Commit

Permalink
build(deps-dev): replace standard with neostandard
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Dec 8, 2024
1 parent c179f54 commit 89375ae
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![CI](https://github.com/fastify/point-of-view/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/point-of-view/actions/workflows/ci.yml)
[![NPM version](https://img.shields.io/npm/v/@fastify/view.svg?style=flat)](https://www.npmjs.com/package/@fastify/view)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)

Templates rendering plugin support for Fastify.

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"example": "node examples/example.js",
"example-with-options": "node examples/example-ejs-with-some-options.js",
"example-typescript": "npx ts-node types/index.test-d.ts",
"lint": "standard",
"lint": "eslint",
"lint:fix": "eslint --fix",
"test-with-snapshot": "cross-env TAP_SNAPSHOT=1 tap test/snap/*",
"test": "npm run test:unit && npm run test-with-snapshot && npm run test:typescript",
"test:unit": "tap",
Expand Down Expand Up @@ -58,12 +59,12 @@
"html-minifier-terser": "^7.2.0",
"liquidjs": "^10.11.0",
"mustache": "^4.2.0",
"neostandard": "^0.11.9",
"nunjucks": "^3.2.4",
"pino": "^9.0.0",
"pug": "^3.0.2",
"simple-get": "^4.0.1",
"split2": "^4.2.0",
"standard": "^17.1.0",
"tap": "^21.0.0",
"tsd": "^0.31.0",
"twig": "^1.17.1"
Expand Down
46 changes: 23 additions & 23 deletions types/index-global-layout.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
import fastify from "fastify";
import fastifyView, { FastifyViewOptions } from "..";
import { expectAssignable } from "tsd";
import * as path from "path";
import fastify from 'fastify'
import fastifyView, { FastifyViewOptions } from '..'
import { expectAssignable } from 'tsd'
import * as path from 'path'

interface Locals {
appVersion: string,
}

declare module "fastify" {
declare module 'fastify' {
interface FastifyReply {
locals: Partial<Locals> | undefined
}
}
const app = fastify();
const app = fastify()

app.register(fastifyView, {
engine: {
ejs: require("ejs"),
ejs: require('ejs'),
},
templates: "templates",
templates: 'templates',
includeViewExtension: true,
defaultContext: {
dev: true,
},
options: {},
charset: "utf-8",
layout: "layout-ts",
charset: 'utf-8',
layout: 'layout-ts',
maxCache: 100,
production: false,
root: path.resolve(__dirname, "../templates"),
viewExt: "ejs",
});
root: path.resolve(__dirname, '../templates'),
viewExt: 'ejs',
})

app.get("/", (request, reply) => {
reply.view("/layout-ts-content-no-data");
});
app.get('/', (request, reply) => {
reply.view('/layout-ts-content-no-data')
})

app.get("/data", (request, reply) => {
app.get('/data', (request, reply) => {
if (!reply.locals) {
reply.locals = {}
}

// reply.locals.appVersion = 1 // not a valid type
reply.locals.appVersion = '4.14.0'
reply.view("/layout-ts-content-with-data", { text: "Sample data" });
});
reply.view('/layout-ts-content-with-data', { text: 'Sample data' })
})

app.get("/dataTyped", (request, reply) => {
app.get('/dataTyped', (request, reply) => {
if (!reply.locals) {
reply.locals = {}
}

// reply.locals.appVersion = 1 // not a valid type
reply.locals.appVersion = '4.14.0'
reply.view<{ text: string; }>("/layout-ts-content-with-data", { text: "Sample data" });
});
reply.view<{ text: string; }>('/layout-ts-content-with-data', { text: 'Sample data' })
})

app.listen({port: 3000}, (err, address) => {
app.listen({ port: 3000 }, (err, address) => {
if (err) throw err
console.log(`server listening on ${address} ...`)
})
Expand Down
6 changes: 3 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FastifyPluginAsync } from 'fastify';
import { FastifyPluginAsync } from 'fastify'

declare module "fastify" {
declare module 'fastify' {

interface RouteSpecificOptions {
layout?: string;
Expand Down Expand Up @@ -59,5 +59,5 @@ declare namespace fastifyView {
export const fastifyViewCache: Symbol
}

declare function fastifyView(...params: Parameters<FastifyView>): ReturnType<FastifyView>
declare function fastifyView (...params: Parameters<FastifyView>): ReturnType<FastifyView>
export = fastifyView
74 changes: 37 additions & 37 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
import fastify from "fastify";
import fastifyView, { PointOfViewOptions, FastifyViewOptions } from "..";
import { expectAssignable, expectNotAssignable, expectDeprecated, expectType } from "tsd";
import * as path from "path";
import fastify from 'fastify'
import fastifyView, { PointOfViewOptions, FastifyViewOptions } from '..'
import { expectAssignable, expectNotAssignable, expectDeprecated, expectType } from 'tsd'
import * as path from 'path'

interface Locals {
appVersion: string,
}

declare module "fastify" {
declare module 'fastify' {
interface FastifyReply {
locals: Partial<Locals> | undefined
}
}
const app = fastify();
const app = fastify()

app.register(fastifyView, {
engine: {
ejs: require("ejs"),
ejs: require('ejs'),
},
templates: "templates",
templates: 'templates',
includeViewExtension: true,
defaultContext: {
dev: true,
},
options: {},
charset: "utf-8",
charset: 'utf-8',
maxCache: 100,
production: false,
root: path.resolve(__dirname, "../templates"),
viewExt: "ejs",
});
root: path.resolve(__dirname, '../templates'),
viewExt: 'ejs',
})

app.get("/", (request, reply) => {
reply.view("/index-with-no-data");
});
app.get('/', (request, reply) => {
reply.view('/index-with-no-data')
})

app.get("/data", (request, reply) => {
app.get('/data', (request, reply) => {
if (!reply.locals) {
reply.locals = {}
}
Expand All @@ -44,10 +44,10 @@ app.get("/data", (request, reply) => {
expectNotAssignable<NonNullable<(typeof reply)['locals']>['appVersion']>(1)

reply.locals.appVersion = '4.14.0'
reply.view("/index", { text: "Sample data" });
});
reply.view('/index', { text: 'Sample data' })
})

app.get("/dataTyped", (request, reply) => {
app.get('/dataTyped', (request, reply) => {
if (!reply.locals) {
reply.locals = {}
}
Expand All @@ -56,42 +56,42 @@ app.get("/dataTyped", (request, reply) => {
expectNotAssignable<NonNullable<(typeof reply)['locals']>['appVersion']>(1)

reply.locals.appVersion = '4.14.0'
reply.view<{ text: string; }>("/index", { text: "Sample data" });
});
reply.view<{ text: string; }>('/index', { text: 'Sample data' })
})

app.get("/use-layout", (request, reply) => {
reply.view("/layout-ts-content-with-data", {text: "Using a layout"}, {layout: "/layout-ts"})
});
app.get('/use-layout', (request, reply) => {
reply.view('/layout-ts-content-with-data', { text: 'Using a layout' }, { layout: '/layout-ts' })
})

app.get("/view-async", async (request, reply) => {
app.get('/view-async', async (request, reply) => {
expectAssignable<NonNullable<(typeof reply)['locals']>['appVersion']>('4.14.0')
expectNotAssignable<NonNullable<(typeof reply)['locals']>['appVersion']>(1)

type ViewAsyncDataParamType = Parameters<typeof reply.viewAsync>[1]
expectAssignable<ViewAsyncDataParamType>({ text: "Sample data" })
expectAssignable<ViewAsyncDataParamType>({ notText: "Sample data "})
expectAssignable<ViewAsyncDataParamType>({ text: 'Sample data' })
expectAssignable<ViewAsyncDataParamType>({ notText: 'Sample data ' })

const html = await reply.viewAsync("/index", { text: "Sample data" });
const html = await reply.viewAsync('/index', { text: 'Sample data' })
expectType<string>(html)
return html
});
})

app.get("/view-async-generic-provided", async (request, reply) => {
app.get('/view-async-generic-provided', async (request, reply) => {
type ViewAsyncDataParamType = Parameters<typeof reply.viewAsync<{ text: string; }>>[1]
expectAssignable<ViewAsyncDataParamType>({ text: "Sample data" })
expectNotAssignable<ViewAsyncDataParamType>({ notText: "Sample data "})
expectAssignable<ViewAsyncDataParamType>({ text: 'Sample data' })
expectNotAssignable<ViewAsyncDataParamType>({ notText: 'Sample data ' })

const html = reply.viewAsync<{ text: string; }>("/index", { text: "Sample data" });
const html = reply.viewAsync<{ text: string; }>('/index', { text: 'Sample data' })
expectType<Promise<string>>(html)
return html
});
})

app.listen({port: 3000}, (err, address) => {
app.listen({ port: 3000 }, (err, address) => {
if (err) throw err
console.log(`server listening on ${address} ...`)
})

expectType<Promise<string>>(app.view("/index", {}, { layout: "/layout-ts"}))
expectType<Promise<string>>(app.view('/index', {}, { layout: '/layout-ts' }))

expectAssignable<FastifyViewOptions>({ engine: { twig: require('twig') }, propertyName: 'mobile' })

Expand All @@ -117,4 +117,4 @@ expectType<Promise<string>>(nunjucksApp.view('/', { text: 'Hello world' }))

expectAssignable<FastifyViewOptions>({ engine: { nunjucks: require('nunjucks') }, templates: 'templates' })

expectAssignable<FastifyViewOptions>({ engine: { nunjucks: require('nunjucks') }, templates: ['templates/nunjucks-layout', 'templates/nunjucks-template']})
expectAssignable<FastifyViewOptions>({ engine: { nunjucks: require('nunjucks') }, templates: ['templates/nunjucks-layout', 'templates/nunjucks-template'] })

0 comments on commit 89375ae

Please sign in to comment.