Skip to content

Commit b6142f4

Browse files
committed
frontend/pdf/print: set type to module in package.json
And switch to esm syntax for the matchingTranslationKeys eslint plugin. Because there cannot be dashes in an identifier, the rule is now called 'matchingTranslationKeys'. jest-serializer-vue-tjw loads the vue config with require, and seems to expect a commonjs module. We switched to a esm module, and now the structure is not pluginOptions.jestSerializer, but default.pluginOptions.jestSerializer -> with the added export we can support vue itself and jest-serializer-vue-tjw. This might enable us to update vite-plugin-comlink - #6220 And might help with - #6038 Fix checked in dist files in pdf/dist/
1 parent e5d850d commit b6142f4

File tree

22 files changed

+67
-72
lines changed

22 files changed

+67
-72
lines changed

common/eslint-local-rules/__tests__/matchingTranslationKeys.spec.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import rule from '../matchingTranslationKeys.js'
1+
import createMatchingTranslationKeys from '../matchingTranslationKeys.js'
22
import { RuleTester } from 'eslint'
3-
import path from 'path'
4-
import fs from 'fs'
5-
import utils from 'eslint-plugin-vue/lib/utils/index.js'
63
import { describe, it } from 'vitest'
74
import localRules from 'eslint-plugin-local-rules'
85
import globals from 'globals'
6+
import utils from 'eslint-plugin-vue/lib/utils/index.js'
97
import eslintParser from 'vue-eslint-parser'
108

119
RuleTester.describe = describe
@@ -28,7 +26,7 @@ const ruleTester = new RuleTester({
2826
},
2927
},
3028
})
31-
const ruleInstance = rule(path, utils, fs)
29+
const ruleInstance = createMatchingTranslationKeys(utils)
3230

3331
const options = [
3432
{

common/eslint-local-rules/__tests__/packageDirectory.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { describe, expect, it } from 'vitest'
2-
import factory from '../packageDirectory.js'
2+
import { packageDirectory } from '../packageDirectory.js'
33
import path from 'path'
44
import fs from 'fs'
55

6-
const { packageDirectory } = factory(path, fs)
7-
86
describe('packageDirectory', () => {
97
it('resolves the location of the closest package.json', () => {
108
const packageJsonFile = path.resolve(__dirname, '../../package.json')

common/eslint-local-rules/matchingTranslationKeys.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
module.exports = (path, utils, fs) => {
2-
const { packageDirectory } = require('./packageDirectory.js')(path, fs)
1+
import { packageDirectory } from "./packageDirectory.js"
2+
import path from "path"
3+
4+
export default function createMatchingTranslationKeys(utils) {
35

46
/**
57
* Convert a file path to our convention for translation key structures

common/eslint-local-rules/packageDirectory.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
module.exports = (path, fs) => ({
2-
packageDirectory: function (filename) {
1+
import path from "path";
2+
import fs from "fs";
3+
4+
export function packageDirectory(filename) {
35
const { root } = path.parse(filename)
46

57
let directory = filename
@@ -16,5 +18,4 @@ module.exports = (path, fs) => ({
1618
}
1719

1820
return ''
19-
},
20-
})
21+
}

frontend/babel.config.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
module.exports = {
2-
presets: ['@vue/app'],
3-
env: {
4-
test: {
5-
plugins: ['require-context-hook'],
6-
},
1+
// noinspection JSUnusedGlobalSymbols
2+
export const presets = ['@vue/app']
3+
export const env = {
4+
test: {
5+
plugins: ['require-context-hook'],
76
},
87
}

frontend/docker-setup.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ set -euo pipefail
44
BASEDIR=$(dirname "$0")
55
PDF_DIST=$BASEDIR"/src/pdf"
66

7-
if [ ! -f "$PDF_DIST/pdf.mjs" ] || [ ! -f "$PDF_DIST/prepareInMainThread.mjs" ]; then
7+
if [ ! -f "$PDF_DIST/pdf.js" ] || [ ! -f "$PDF_DIST/prepareInMainThread.js" ]; then
88
# Copy dummy versions of the pdf build outputs, to make sure there is always something to import
9-
cp "$PDF_DIST/pdf.mjs.dist" "$PDF_DIST/pdf.mjs"
10-
cp "$PDF_DIST/prepareInMainThread.mjs.dist" "$PDF_DIST/prepareInMainThread.mjs"
9+
cp "$PDF_DIST/pdf.js.dist" "$PDF_DIST/pdf.js"
10+
cp "$PDF_DIST/prepareInMainThread.js.dist" "$PDF_DIST/prepareInMainThread.js"
1111
fi
1212

1313
if [ "$CI" = 'true' ] ; then
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
const path = require('path')
2-
const fs = require('fs')
3-
const utils = require('eslint-plugin-vue/lib/utils/index.js')
4-
const matchingTranslationKeys = require('../src/common/eslint-local-rules/matchingTranslationKeys.js')
1+
import utils from 'eslint-plugin-vue/lib/utils/index.js'
2+
// noinspection ES6UnusedImports
3+
import createMatchingTranslationKeys from '../../common/eslint-local-rules/matchingTranslationKeys.js'
54

6-
module.exports = {
7-
'matching-translation-keys': matchingTranslationKeys(path, utils, fs),
8-
}
5+
// noinspection JSUnusedGlobalSymbols
6+
export const matchingTranslationKeys = createMatchingTranslationKeys(utils)

frontend/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export default [
7777
},
7878
],
7979

80-
'local-rules/matching-translation-keys': [
80+
'local-rules/matchingTranslationKeys': [
8181
'error',
8282
{
8383
ignoreKeysRegex:

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@ecamp3/frontend",
33
"private": true,
4+
"type": "module",
45
"scripts": {
56
"serve": "vite --host 0.0.0.0",
67
"preview": "vite preview --host 0.0.0.0 --port 3000",

frontend/src/components/print/print-client/generatePdf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { prepareInMainThread } from '@/pdf/prepareInMainThread.mjs'
1+
import { prepareInMainThread } from '@/pdf/prepareInMainThread.js'
22
import cloneDeep from 'lodash/cloneDeep.js'
33

44
export const generatePdf = async (data) => {

0 commit comments

Comments
 (0)