Skip to content

Commit 56ef60d

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'. This might enable us to update vite-plugin-comlink - #6220 And might help with - #6038
1 parent e5d850d commit 56ef60d

File tree

15 files changed

+44
-48
lines changed

15 files changed

+44
-48
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 { matchingTranslationKeys } 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 = matchingTranslationKeys(utils)
3230

3331
const options = [
3432
{

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
}
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/vue.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = {
1+
export default {
22
devServer: {
33
useLocalIp: false,
44
allowedHosts: ['ecamp3', 'localhost', '127.0.0.1'],

pdf/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
}

pdf/eslint-local-rules/index.js

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('../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)

0 commit comments

Comments
 (0)