Skip to content

Commit

Permalink
Merge pull request #6571 from BacLuc/frontend-switch-to-module
Browse files Browse the repository at this point in the history
frontend/pdf/print: set type to module in package.json
  • Loading branch information
BacLuc authored Jan 14, 2025
2 parents ad74c72 + b6142f4 commit da7cc45
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 72 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import rule from '../matchingTranslationKeys.js'
import createMatchingTranslationKeys from '../matchingTranslationKeys.js'
import { RuleTester } from 'eslint'
import path from 'path'
import fs from 'fs'
import utils from 'eslint-plugin-vue/lib/utils/index.js'
import { describe, it } from 'vitest'
import localRules from 'eslint-plugin-local-rules'
import globals from 'globals'
import utils from 'eslint-plugin-vue/lib/utils/index.js'
import eslintParser from 'vue-eslint-parser'

RuleTester.describe = describe
Expand All @@ -28,7 +26,7 @@ const ruleTester = new RuleTester({
},
},
})
const ruleInstance = rule(path, utils, fs)
const ruleInstance = createMatchingTranslationKeys(utils)

const options = [
{
Expand Down
4 changes: 1 addition & 3 deletions common/eslint-local-rules/__tests__/packageDirectory.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { describe, expect, it } from 'vitest'
import factory from '../packageDirectory.js'
import { packageDirectory } from '../packageDirectory.js'
import path from 'path'
import fs from 'fs'

const { packageDirectory } = factory(path, fs)

describe('packageDirectory', () => {
it('resolves the location of the closest package.json', () => {
const packageJsonFile = path.resolve(__dirname, '../../package.json')
Expand Down
6 changes: 4 additions & 2 deletions common/eslint-local-rules/matchingTranslationKeys.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = (path, utils, fs) => {
const { packageDirectory } = require('./packageDirectory.js')(path, fs)
import { packageDirectory } from "./packageDirectory.js"
import path from "path"

export default function createMatchingTranslationKeys(utils) {

/**
* Convert a file path to our convention for translation key structures
Expand Down
9 changes: 5 additions & 4 deletions common/eslint-local-rules/packageDirectory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module.exports = (path, fs) => ({
packageDirectory: function (filename) {
import path from "path";
import fs from "fs";

export function packageDirectory(filename) {
const { root } = path.parse(filename)

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

return ''
},
})
}
11 changes: 5 additions & 6 deletions frontend/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module.exports = {
presets: ['@vue/app'],
env: {
test: {
plugins: ['require-context-hook'],
},
// noinspection JSUnusedGlobalSymbols
export const presets = ['@vue/app']
export const env = {
test: {
plugins: ['require-context-hook'],
},
}
6 changes: 3 additions & 3 deletions frontend/docker-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ set -euo pipefail
BASEDIR=$(dirname "$0")
PDF_DIST=$BASEDIR"/src/pdf"

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

if [ "$CI" = 'true' ] ; then
Expand Down
12 changes: 5 additions & 7 deletions frontend/eslint-local-rules/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const path = require('path')
const fs = require('fs')
const utils = require('eslint-plugin-vue/lib/utils/index.js')
const matchingTranslationKeys = require('../src/common/eslint-local-rules/matchingTranslationKeys.js')
import utils from 'eslint-plugin-vue/lib/utils/index.js'
// noinspection ES6UnusedImports
import createMatchingTranslationKeys from '../../common/eslint-local-rules/matchingTranslationKeys.js'

module.exports = {
'matching-translation-keys': matchingTranslationKeys(path, utils, fs),
}
// noinspection JSUnusedGlobalSymbols
export const matchingTranslationKeys = createMatchingTranslationKeys(utils)
2 changes: 1 addition & 1 deletion frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default [
},
],

'local-rules/matching-translation-keys': [
'local-rules/matchingTranslationKeys': [
'error',
{
ignoreKeysRegex:
Expand Down
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@ecamp3/frontend",
"private": true,
"type": "module",
"scripts": {
"serve": "vite --host 0.0.0.0",
"preview": "vite preview --host 0.0.0.0 --port 3000",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/print/print-client/generatePdf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prepareInMainThread } from '@/pdf/prepareInMainThread.mjs'
import { prepareInMainThread } from '@/pdf/prepareInMainThread.js'
import cloneDeep from 'lodash/cloneDeep.js'

export const generatePdf = async (data) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/print/print-client/renderPdf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import wrap from './minimalHalJsonVuex.js'
import createI18n from './i18n.js'
import { render, prepare } from '@/pdf/pdf.mjs'
import { render, prepare } from '@/pdf/pdf.js'

export const renderPdf = async ({ config, storeData, translationData }) => {
const result = {
Expand Down
32 changes: 16 additions & 16 deletions frontend/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
module.exports = {
export const pluginOptions = {
jestSerializer: {
attributesToClear: ['id', 'for'],
formatting: {
indent_char: ' ',
indent_inner_html: true,
indent_size: 5,
inline: [],
sep: '\n',
wrap_attributes: 'force-aligned',
},
},
}

export default {
devServer: {
useLocalIp: false,
allowedHosts: ['ecamp3', 'localhost', '127.0.0.1'],
},

transpileDependencies: ['vuetify'],

pluginOptions: {
jestSerializer: {
attributesToClear: ['id', 'for'],
formatting: {
indent_char: ' ',
indent_inner_html: true,
indent_size: 5,
inline: [],
sep: '\n',
wrap_attributes: 'force-aligned',
},
},
},

pluginOptions,
css: {
sourceMap: true,
},
Expand Down
3 changes: 2 additions & 1 deletion pdf/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ lerna-debug.log*

node_modules
.DS_Store
dist
/dist/*
!/dist/*.dist
dist-ssr
coverage
*.local
Expand Down
11 changes: 5 additions & 6 deletions pdf/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module.exports = {
presets: ['@vue/app'],
env: {
test: {
plugins: ['require-context-hook'],
},
// noinspection JSUnusedGlobalSymbols
export const presets = ['@vue/app']
export const env = {
test: {
plugins: ['require-context-hook'],
},
}
File renamed without changes.
File renamed without changes.
12 changes: 5 additions & 7 deletions pdf/eslint-local-rules/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const path = require('path')
const fs = require('fs')
const utils = require('eslint-plugin-vue/lib/utils/index.js')
const matchingTranslationKeys = require('../common/eslint-local-rules/matchingTranslationKeys.js')
import utils from 'eslint-plugin-vue/lib/utils/index.js'
// noinspection ES6UnusedImports
import createMatchingTranslationKeys from '../../common/eslint-local-rules/matchingTranslationKeys.js'

module.exports = {
'matching-translation-keys': matchingTranslationKeys(path, utils, fs),
}
// noinspection JSUnusedGlobalSymbols
export const matchingTranslationKeys = createMatchingTranslationKeys(utils)
2 changes: 1 addition & 1 deletion pdf/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default [
},
],

'local-rules/matching-translation-keys': [
'local-rules/matchingTranslationKeys': [
'error',
{
ignoreKeysRegex:
Expand Down
1 change: 1 addition & 0 deletions pdf/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@ecamp3/client-pdf",
"description": "Create pdfs for eCamp, using Vue components",
"type": "module",
"main": "src/index.js",
"private": true,
"scripts": {
Expand Down
12 changes: 5 additions & 7 deletions print/eslint-local-rules/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const path = require('path')
const fs = require('fs')
const utils = require('eslint-plugin-vue/lib/utils/index.js')
const matchingTranslationKeys = require('../../common/eslint-local-rules/matchingTranslationKeys.js')
import utils from 'eslint-plugin-vue/lib/utils/index.js'
// noinspection ES6UnusedImports
import createMatchingTranslationKeys from '../../common/eslint-local-rules/matchingTranslationKeys.js'

module.exports = {
'matching-translation-keys': matchingTranslationKeys(path, utils, fs),
}
// noinspection JSUnusedGlobalSymbols
export const matchingTranslationKeys = createMatchingTranslationKeys(utils)
2 changes: 1 addition & 1 deletion print/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default [
'prefer-const': 'error',
'vue/multi-word-component-names': 'off',

'local-rules/matching-translation-keys': [
'local-rules/matchingTranslationKeys': [
'error',
{
ignoreKeysRegex:
Expand Down
1 change: 1 addition & 0 deletions print/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@ecamp3/backend-print",
"private": true,
"type": "module",
"scripts": {
"dev": "nuxt dev",
"dev-debug": "node --inspect node_modules/.bin/nuxt",
Expand Down

0 comments on commit da7cc45

Please sign in to comment.