Skip to content

Commit

Permalink
frontend/pdf/print: set type to module in package.json
Browse files Browse the repository at this point in the history
And switch to esm syntax for the matchingTranslationKeys eslint plugin.

Because there cannot be dashes in an identifier, the rule is now called
'matchingTranslationKeys'.

This might enable us to update vite-plugin-comlink
- #6220
And might help with
- #6038
  • Loading branch information
BacLuc committed Dec 21, 2024
1 parent e5d850d commit e7b9659
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import rule from '../matchingTranslationKeys.js'
import { matchingTranslationKeys } 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 = matchingTranslationKeys(utils)

const options = [
{
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'],
},
}
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 @@ -77,7 +77,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
2 changes: 1 addition & 1 deletion frontend/vue.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
devServer: {
useLocalIp: false,
allowedHosts: ['ecamp3', 'localhost', '127.0.0.1'],
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'],
},
}
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 @@ -73,7 +73,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 e7b9659

Please sign in to comment.