Skip to content
This repository was archived by the owner on Sep 17, 2022. It is now read-only.

Commit 34cb013

Browse files
committed
Fix eslint warnings
1 parent 4406a6e commit 34cb013

File tree

9 files changed

+53
-53
lines changed

9 files changed

+53
-53
lines changed

.eslintrc.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
'extends': [
3-
'@antfu'
4-
]
2+
extends: [
3+
'@antfu',
4+
],
55
}

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111

1212
jobs:
1313
test:
14-
name: "Test on Node.js ${{ matrix.node }} OS: ${{ matrix.os }}"
14+
name: 'Test on Node.js ${{ matrix.node }} OS: ${{ matrix.os }}'
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
@@ -37,7 +37,7 @@ jobs:
3737

3838
lint:
3939
runs-on: ubuntu-latest
40-
name: "Lint source code"
40+
name: Lint source code
4141
steps:
4242
- uses: actions/[email protected]
4343
with:

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import fluentPlugin from 'rollup-plugin-fluent-vue'
2929

3030
module.exports = {
3131
plugins: [
32-
fluentPlugin()
33-
]
32+
fluentPlugin(),
33+
],
3434
}
3535
```
3636

@@ -41,7 +41,7 @@ import vue from '@vitejs/plugin-vue'
4141
import fluentPlugin from 'rollup-plugin-fluent-vue'
4242

4343
export default {
44-
plugins: [vue(), fluentPlugin()]
44+
plugins: [vue(), fluentPlugin()],
4545
}
4646
```
4747

@@ -65,7 +65,7 @@ Example of `App.vue` with custom block:
6565
6666
<script>
6767
export default {
68-
name: 'app'
68+
name: 'App',
6969
}
7070
</script>
7171

__tests__/fixtures/blockType.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</div>
66
</template>
77

8-
<i18n locale="en">
8+
<custom locale="en">
99
# Simple things are simple.
1010
hello-user = Hello, {$userName}!
1111

@@ -19,4 +19,4 @@ shared-photos =
1919
[female] her stream
2020
*[other] their stream
2121
}.
22-
</i18n>
22+
</custom>

__tests__/fixtures/noLocale.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ shared-photos =
1919
[female] her stream
2020
*[other] their stream
2121
}.
22-
</fluent>
22+
</fluent>

__tests__/fixtures/test.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ shared-photos =
1919
[female] her stream
2020
*[other] their stream
2121
}.
22-
</fluent>
22+
</fluent>

__tests__/test.spec.ts

+25-23
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import { describe, it, expect } from 'vitest'
2-
import { resolve, dirname } from 'path'
1+
import { dirname, resolve } from 'path'
32
import { fileURLToPath } from 'url'
3+
import { describe, expect, it } from 'vitest'
44

5-
import { rollup, RollupOptions } from 'rollup'
5+
import type { RollupOptions } from 'rollup'
6+
import { rollup } from 'rollup'
67
import vue from 'rollup-plugin-vue'
78
import { createVuePlugin } from 'vite-plugin-vue2'
89

910
import fluentPlugin from '../src'
1011

1112
const baseDir = dirname(fileURLToPath(import.meta.url))
1213

13-
const testBundle = async (options: RollupOptions): Promise<string> => {
14+
const testBundle = async(options: RollupOptions): Promise<string> => {
1415
const bundle = await rollup({
1516
...options,
16-
external: ['vue', '@fluent/bundle']
17+
external: ['vue', '@fluent/bundle'],
1718
})
1819

1920
const { output } = await bundle.generate({ format: 'cjs', exports: 'auto' })
@@ -22,75 +23,76 @@ const testBundle = async (options: RollupOptions): Promise<string> => {
2223
}
2324

2425
describe('rollup plugin', () => {
25-
it('generates custom block code', async () => {
26+
it('generates custom block code', async() => {
2627
// Arrange
2728
// Act
2829
const code = await testBundle({
2930
input: resolve(baseDir, 'fixtures/test.vue'),
3031
plugins: [
3132
vue({
32-
customBlocks: ['fluent']
33+
customBlocks: ['fluent'],
3334
}),
34-
fluentPlugin()
35-
]
35+
fluentPlugin(),
36+
],
3637
})
3738

3839
// Assert
3940
expect(code).toMatchSnapshot()
4041
})
4142

42-
it('works with vue 2', async () => {
43+
it('works with vue 2', async() => {
4344
// Arrange
4445
// Act
4546
const code = await testBundle({
4647
input: resolve(baseDir, 'fixtures/test.vue'),
4748
plugins: [
4849
createVuePlugin(),
49-
fluentPlugin()
50-
]
50+
fluentPlugin(),
51+
],
5152
})
5253

5354
// Assert
5455
expect(code).toMatchSnapshot()
5556
})
5657

57-
it('custom blockType', async () => {
58+
it('custom blockType', async() => {
5859
// Arrange
5960
// Act
6061
const code = await testBundle({
6162
input: resolve(baseDir, 'fixtures/blockType.vue'),
6263
plugins: [
6364
vue({
64-
customBlocks: ['i18n']
65+
customBlocks: ['custom'],
6566
}), fluentPlugin({
66-
blockType: 'i18n'
67-
})
67+
blockType: 'custom',
68+
}),
6869
],
69-
external: ['vue', '@fluent/bundle']
70+
external: ['vue', '@fluent/bundle'],
7071
})
7172

7273
// Assert
7374
expect(code).toMatchSnapshot()
7475
})
7576

76-
it('errors with no locale attr', async () => {
77+
it('errors with no locale attr', async() => {
7778
// Arrange
78-
const func = async (): Promise<string> => await testBundle({
79+
const func = async(): Promise<string> => await testBundle({
7980
input: resolve(baseDir, 'fixtures/noLocale.vue'),
8081
plugins: [
8182
vue({
82-
customBlocks: ['fluent']
83+
customBlocks: ['fluent'],
8384
}),
84-
fluentPlugin()
85+
fluentPlugin(),
8586
],
86-
external: ['vue', '@fluent/bundle']
87+
external: ['vue', '@fluent/bundle'],
8788
})
8889

8990
// TODO: Use rejects
9091
try {
9192
// Act
9293
await func()
93-
} catch (err) {
94+
}
95+
catch (err) {
9496
// Assert
9597
expect(err).toMatchSnapshot()
9698
}

package.json

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
"rollup-plugin",
2121
"vite-plugin"
2222
],
23+
"license": "MIT",
24+
"author": "Ivan Demchuk <[email protected]>",
25+
"repository": {
26+
"type": "git",
27+
"url": "https://github.com/Demivan/fluent-vue"
28+
},
2329
"main": "dist/index.js",
2430
"module": "dist/index.mjs",
2531
"types": "dist/index.d.ts",
@@ -31,19 +37,16 @@
3137
"dist",
3238
"README.md"
3339
],
34-
"author": "Ivan Demchuk <[email protected]>",
35-
"repository": {
36-
"type": "git",
37-
"url": "https://github.com/Demivan/fluent-vue"
38-
},
3940
"homepage": "https://fluent-vue.demivan.me/integrations/rollup.html",
40-
"license": "MIT",
4141
"scripts": {
4242
"build": "tsup src/index.ts --format esm,cjs --dts",
4343
"test": "vitest run",
4444
"test:watch": "vitest",
4545
"lint": "eslint ."
4646
},
47+
"dependencies": {
48+
"magic-string": "^0.26.1"
49+
},
4750
"devDependencies": {
4851
"@antfu/eslint-config": "^0.18.9",
4952
"@types/node": "17.0.23",
@@ -59,8 +62,5 @@
5962
"vite-plugin-vue2": "1.9.3",
6063
"vitest": "0.7.12",
6164
"vue-template-compiler": "2.6.14"
62-
},
63-
"dependencies": {
64-
"magic-string": "^0.26.1"
6565
}
6666
}

src/index.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import type { Plugin } from 'rollup'
21
import { URLSearchParams } from 'url'
2+
import type { Plugin } from 'rollup'
33

44
export interface PluginOptions {
55
blockType?: string
66
}
77

8-
export default function fluentPlugin ({ blockType = 'fluent' }: PluginOptions = {}): Plugin {
8+
export default function fluentPlugin({ blockType = 'fluent' }: PluginOptions = {}): Plugin {
99
return {
1010
name: 'rollup-plugin-fluent-vue',
11-
transform (code, id) {
12-
if (!id.includes(`vue&type=${blockType}`)) {
11+
transform(code, id) {
12+
if (!id.includes(`vue&type=${blockType}`))
1313
return
14-
}
1514

1615
// vite-plugin-vue2 pads SFC file sections with newlines - trim those
1716
const data = code.replace(/^(\n|\r\n)+|(\n|\r\n)+$/g, '')
@@ -21,9 +20,8 @@ export default function fluentPlugin ({ blockType = 'fluent' }: PluginOptions =
2120

2221
const locale = query.get('locale')
2322

24-
if (locale == null) {
23+
if (locale == null)
2524
return this.error('Custom block does not have locale attribute')
26-
}
2725

2826
return `
2927
import { FluentResource } from '@fluent/bundle'
@@ -33,6 +31,6 @@ export default function (Component) {
3331
target.fluent = target.fluent || {}
3432
target.fluent['${locale}'] = new FluentResource(\`${data}\`)
3533
}`
36-
}
34+
},
3735
}
3836
}

0 commit comments

Comments
 (0)