diff --git a/frontend/.eslintrc b/frontend/.eslintrc deleted file mode 100644 index c1c49c3..0000000 --- a/frontend/.eslintrc +++ /dev/null @@ -1,17 +0,0 @@ -{ - "env": { - "browser": true, - "node": true - }, - "extends": [ - "eslint:recommended" - ], - "parserOptions": { - "ecmaVersion": 8, - "sourceType": "module", - "requireConfigFile": false - }, - "rules": { - "semi": 2 - } -} diff --git a/frontend/README.md b/frontend/README.md index 0b0d8e0..8f728c2 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -10,7 +10,7 @@ In the project directory, you can run: `npm run start` will launch a server process, which makes `live reloading` possible. -If you change JS or SCSS files, the web page would auto refresh after the change. Now the server is working on port 9091 by default, but you can change it in `webpack/webpack.config.dev.js` +If you change JS or SCSS files, the web page would auto refresh after the change. Now the server is working on port 9091 by default, but you can change it in `webpack/webpack.config.dev.cjs` ### `npm run watch` diff --git a/frontend/eslint.config.mjs b/frontend/eslint.config.mjs new file mode 100644 index 0000000..a7f6599 --- /dev/null +++ b/frontend/eslint.config.mjs @@ -0,0 +1,39 @@ +import { defineConfig } from "eslint/config"; +import globals from "globals"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import js from "@eslint/js"; +import { FlatCompat } from "@eslint/eslintrc"; +import babelParser from "@babel/eslint-parser"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); +const compat = new FlatCompat({ + baseDirectory: __dirname, + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all +}); + +export default defineConfig([{ + extends: compat.extends("eslint:recommended"), + + languageOptions: { + globals: { + ...globals.browser, + ...globals.node, + }, + + ecmaVersion: 8, + sourceType: "module", + parser: babelParser, + + parserOptions: { + requireConfigFile: false, + }, + }, + + rules: { + semi: 2, + "no-unused-vars": "warn", + }, +}]); diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 73f0145..d2822dd 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -33,6 +33,7 @@ "css-loader": "^7.1.2", "eslint": "^9.30.0", "eslint-webpack-plugin": "^5.0.2", + "globals": "^16.2.0", "htmx.org": "^2.0.6", "hyperscript.org": "^0.9.14", "jquery": "^3.7.1", @@ -48,7 +49,7 @@ "stylelint": "^16.21.0", "stylelint-config-standard-scss": "^15.0.1", "stylelint-webpack-plugin": "^5.0.1", - "sweetalert2": "^11.22.1", + "sweetalert2": "^11.22.2", "tailwindcss": "^4.1.11", "terser-webpack-plugin": "^5.3.14", "tom-select": "^2.4.3", @@ -737,6 +738,15 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/plugin-transform-classes/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/plugin-transform-computed-properties": { "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.27.1.tgz", @@ -1531,6 +1541,15 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.27.7", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.27.7.tgz", @@ -6407,12 +6426,15 @@ } }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-16.2.0.tgz", + "integrity": "sha512-O+7l9tPdHCU320IigZZPj5zmRCFG9xHmx9cU8FqU2Rp+JN714seHV+2S9+JslCpY4gJwU2vOGox0wzgae/MCEg==", "license": "MIT", "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/globjoin": { @@ -10466,9 +10488,9 @@ "integrity": "sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==" }, "node_modules/sweetalert2": { - "version": "11.22.1", - "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.22.1.tgz", - "integrity": "sha512-3dGb50jlfcJ0OHZ5D4hJWK/cIYAfCnxK5QQVndOJqhyiCYJozINEfHG7wvRbkACj60hDnPWu+t9EFcbYWaSEuQ==", + "version": "11.22.2", + "resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.22.2.tgz", + "integrity": "sha512-GFQGzw8ZXF23PO79WMAYXLl4zYmLiaKqYJwcp5eBF07wiI5BYPbZtKi2pcvVmfUQK+FqL1risJAMxugcPbGIyg==", "license": "MIT", "funding": { "type": "individual", diff --git a/frontend/package.json b/frontend/package.json index d78320f..5e703be 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -3,9 +3,9 @@ "version": "1.0.1", "description": "Webpack boilerplate for Django & Flask", "scripts": { - "build": "cross-env NODE_ENV=production webpack --config webpack/webpack.config.prod.js", - "start": "webpack serve --config webpack/webpack.config.dev.js", - "watch": "webpack --watch --config webpack/webpack.config.watch.js" + "build": "cross-env NODE_ENV=production webpack --config webpack/webpack.config.prod.cjs", + "start": "webpack serve --config webpack/webpack.config.dev.cjs", + "watch": "webpack --watch --config webpack/webpack.config.watch.cjs" }, "repository": { "type": "git", @@ -46,6 +46,7 @@ "css-loader": "^7.1.2", "eslint": "^9.30.0", "eslint-webpack-plugin": "^5.0.2", + "globals": "^16.2.0", "htmx.org": "^2.0.6", "hyperscript.org": "^0.9.14", "jquery": "^3.7.1", @@ -61,7 +62,7 @@ "stylelint": "^16.21.0", "stylelint-config-standard-scss": "^15.0.1", "stylelint-webpack-plugin": "^5.0.1", - "sweetalert2": "^11.22.1", + "sweetalert2": "^11.22.2", "tailwindcss": "^4.1.11", "terser-webpack-plugin": "^5.3.14", "tom-select": "^2.4.3", diff --git a/frontend/src/application/datepicker.js b/frontend/src/application/datepicker.js index 0788bd8..933be58 100644 --- a/frontend/src/application/datepicker.js +++ b/frontend/src/application/datepicker.js @@ -33,7 +33,7 @@ window.DatePicker = function createDynamicDatePicker(element) { dp.selectDate(date, {updateTime: true}); dp.setViewDate(date); } - } + }; let isOnMobile = isMobile(); @@ -107,7 +107,7 @@ window.MonthYearPicker = function createDynamicDatePicker(element) { dp.selectDate(date, {updateTime: true}); dp.setViewDate(date); } - } + }; let isOnMobile = isMobile(); @@ -180,7 +180,7 @@ window.YearPicker = function createDynamicDatePicker(element) { dp.selectDate(date, {updateTime: true}); dp.setViewDate(date); } - } + }; let isOnMobile = isMobile(); diff --git a/frontend/webpack/webpack.common.js b/frontend/webpack/webpack.common.cjs similarity index 96% rename from frontend/webpack/webpack.common.js rename to frontend/webpack/webpack.common.cjs index 8dafd9e..d20c21c 100644 --- a/frontend/webpack/webpack.common.js +++ b/frontend/webpack/webpack.common.cjs @@ -1,8 +1,8 @@ const glob = require("glob"); const Path = require("path"); -const {CleanWebpackPlugin} = require("clean-webpack-plugin"); +const { CleanWebpackPlugin } = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); -const WebpackAssetsManifest = require("webpack-assets-manifest"); +const WebpackAssetsManifest = require("webpack-assets-manifest").WebpackAssetsManifest; // eslint-disable-next-line no-unused-vars const webpack = require("webpack"); diff --git a/frontend/webpack/webpack.config.dev.js b/frontend/webpack/webpack.config.dev.cjs similarity index 97% rename from frontend/webpack/webpack.config.dev.js rename to frontend/webpack/webpack.config.dev.cjs index d02292a..25ba57d 100644 --- a/frontend/webpack/webpack.config.dev.js +++ b/frontend/webpack/webpack.config.dev.cjs @@ -5,7 +5,7 @@ const StylelintPlugin = require("stylelint-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const ESLintPlugin = require("eslint-webpack-plugin"); -const common = require("./webpack.common.js"); +const common = require("./webpack.common.cjs"); module.exports = merge(common, { target: "web", diff --git a/frontend/webpack/webpack.config.prod.js b/frontend/webpack/webpack.config.prod.cjs similarity index 95% rename from frontend/webpack/webpack.config.prod.js rename to frontend/webpack/webpack.config.prod.cjs index b905260..b47e061 100644 --- a/frontend/webpack/webpack.config.prod.js +++ b/frontend/webpack/webpack.config.prod.cjs @@ -2,7 +2,7 @@ const Webpack = require("webpack"); const { merge } = require("webpack-merge"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const TerserPlugin = require("terser-webpack-plugin"); -const common = require("./webpack.common.js"); +const common = require("./webpack.common.cjs"); module.exports = merge(common, { mode: "production", diff --git a/frontend/webpack/webpack.config.watch.js b/frontend/webpack/webpack.config.watch.cjs similarity index 96% rename from frontend/webpack/webpack.config.watch.js rename to frontend/webpack/webpack.config.watch.cjs index e8796cb..48a9dab 100644 --- a/frontend/webpack/webpack.config.watch.js +++ b/frontend/webpack/webpack.config.watch.cjs @@ -5,7 +5,7 @@ const StylelintPlugin = require("stylelint-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const ESLintPlugin = require("eslint-webpack-plugin"); -const common = require("./webpack.common.js"); +const common = require("./webpack.common.cjs"); module.exports = merge(common, { target: "web",