Skip to content

Commit d119646

Browse files
codebender828pi0
authored andcommitted
fix: linting problems
1 parent 287669d commit d119646

File tree

8 files changed

+59
-60
lines changed

8 files changed

+59
-60
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"dev": "nuxi dev playground",
2323
"dev:build": "nuxi build playground",
2424
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
25+
"lint": "eslint --ext .js,.vue,.ts .",
2526
"test": "vitest"
2627
},
2728
"dependencies": {

playground/app.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<template>
2-
<div :class="styles.root">Nuxt module playground!</div>
3-
<button :class="styles.button">Hello World</button>
2+
<div>
3+
<div :class="styles.root">Nuxt module playground!</div>
4+
<button :class="styles.button">Hello World</button>
5+
</div>
46
</template>
57

68
<script setup>
@@ -34,10 +36,6 @@ const styles = reactive({
3436
cursor: "pointer",
3537
transitionProperty:
3638
"color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,-webkit-backdrop-filter",
37-
transitionProperty:
38-
"color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter",
39-
transitionProperty:
40-
"color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter,-webkit-backdrop-filter",
4139
transitionTimingFunction: "cubic-bezier(.4,0,.2,1)",
4240
transitionDuration: ".15s",
4341
"&:hover": {

playground/nuxt.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { defineNuxtConfig } from "nuxt/config";
2-
import emotionModule from "..";
1+
import { defineNuxtConfig } from 'nuxt/config'
2+
import emotionModule from '..'
33

44
export default defineNuxtConfig({
5-
modules: [emotionModule],
6-
});
5+
modules: [emotionModule]
6+
})

src/module.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { fileURLToPath } from "url";
1+
import { fileURLToPath } from 'url'
22
import {
33
defineNuxtModule,
44
addPlugin,
55
createResolver,
6-
addServerPlugin,
7-
} from "@nuxt/kit";
6+
addServerPlugin
7+
} from '@nuxt/kit'
88

99
declare global {
1010
interface Window {
@@ -15,31 +15,31 @@ declare global {
1515

1616
export default defineNuxtModule({
1717
meta: {
18-
name: "@nuxtjs/emotion",
19-
configKey: "emotion",
20-
compatibilty: ">=3.0.0",
18+
name: '@nuxtjs/emotion',
19+
configKey: 'emotion',
20+
compatibilty: '>=3.0.0'
2121
},
22-
setup(options, nuxt) {
22+
setup (options, nuxt) {
2323
// ensure `nitro.plugins` is initialized
24-
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins || [];
24+
nuxt.options.nitro.plugins = nuxt.options.nitro.plugins || []
2525

26-
nuxt.hook("nitro:config", (config) => {
26+
nuxt.hook('nitro:config', (config) => {
2727
// Prevent inlining emotion (+ the crucial css cache!) in dev mode
2828
if (nuxt.options.dev) {
2929
if (config.externals) {
30-
config.externals.external ||= [];
31-
config.externals.external.push("@emotion/server");
30+
config.externals.external ||= []
31+
config.externals.external.push('@emotion/server')
3232
}
3333
}
34-
});
34+
})
3535

3636
/**
3737
* Register emotion plugin
3838
*/
39-
const { resolve } = createResolver(import.meta.url);
40-
const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
41-
nuxt.options.build.transpile.push(runtimeDir);
42-
addServerPlugin(resolve(runtimeDir, "emotion.server"));
43-
addPlugin(resolve(runtimeDir, "emotion.client"));
44-
},
45-
});
39+
const { resolve } = createResolver(import.meta.url)
40+
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
41+
nuxt.options.build.transpile.push(runtimeDir)
42+
addServerPlugin(resolve(runtimeDir, 'emotion.server'))
43+
addPlugin(resolve(runtimeDir, 'emotion.client'))
44+
}
45+
})

src/runtime/emotion.client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { defineNuxtPlugin } from "#app";
21
import { hydrate } from "@emotion/css";
2+
import { defineNuxtPlugin } from "#app";
33

4-
export default defineNuxtPlugin((nuxtApp) => {
4+
export default defineNuxtPlugin((_) => {
55
if (window.$emotionSSRIds) {
66
const ids = window.$emotionSSRIds;
77
hydrate(ids);

src/runtime/emotion.server.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { extractCritical } from "@emotion/server";
2-
import { NitroApp } from "nitropack";
1+
import { extractCritical } from '@emotion/server'
2+
import { NitroApp } from 'nitropack'
33

44
/**
55
* Why are we declaring types for `defineNitroPlugin`?
@@ -20,18 +20,18 @@ export interface NitroAppPlugin {
2020
(nitro: NitroApp): void;
2121
}
2222

23-
export function defineNitroPlugin(def: NitroAppPlugin): NitroAppPlugin {
24-
return def;
23+
export function defineNitroPlugin (def: NitroAppPlugin): NitroAppPlugin {
24+
return def
2525
}
2626

2727
export default defineNitroPlugin((nitroApp) => {
28-
nitroApp.hooks.hook("render:html", (html) => {
29-
const { ids, css } = extractCritical(html.body);
30-
html.head.push(`<style data-emotion="${ids.join(" ")}">${css}</style>`);
28+
nitroApp.hooks.hook('render:html', (html) => {
29+
const { ids, css } = extractCritical(html.body)
30+
html.head.push(`<style data-emotion="${ids.join(' ')}">${css}</style>`)
3131
html.head.push(
3232
`<script data-emotion="${ids.join(
33-
" "
33+
' '
3434
)}">window.$emotionIds=${JSON.stringify(ids)}</script>`
35-
);
36-
});
37-
});
35+
)
36+
})
37+
})

test/basic.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { describe, it, expect } from "vitest";
2-
import { fileURLToPath } from "node:url";
3-
import { setup, $fetch } from "@nuxt/test-utils";
4-
describe("nust emotion ssr", async () => {
1+
import { fileURLToPath } from 'node:url'
2+
import { describe, it, expect } from 'vitest'
3+
import { setup, $fetch } from '@nuxt/test-utils'
4+
describe('nust emotion ssr', async () => {
55
await setup({
6-
rootDir: fileURLToPath(new URL("../playground", import.meta.url)),
7-
});
8-
it("renders the index page", async () => {
9-
const html = await $fetch("/");
10-
expect(html).toContain("<style data-emotion");
11-
expect(html).toContain("<script data-emotion");
12-
expect(html).toContain("window.$emotionIds");
13-
expect(html).toMatchSnapshot();
14-
});
15-
});
6+
rootDir: fileURLToPath(new URL('../playground', import.meta.url))
7+
})
8+
it('renders the index page', async () => {
9+
const html = await $fetch('/')
10+
expect(html).toContain('<style data-emotion')
11+
expect(html).toContain('<script data-emotion')
12+
expect(html).toContain('window.$emotionIds')
13+
expect(html).toMatchSnapshot()
14+
})
15+
})

test/fixture/nuxt.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { defineNuxtConfig } from "nuxt/config";
2-
import emotionModule from "../..";
1+
import { defineNuxtConfig } from 'nuxt/config'
2+
import emotionModule from '../..'
33

44
export default defineNuxtConfig({
5-
modules: [emotionModule],
6-
});
5+
modules: [emotionModule]
6+
})

0 commit comments

Comments
 (0)