Skip to content

Commit

Permalink
Use a "flat" config for ESLint.
Browse files Browse the repository at this point in the history
ESLint is migrating to a flat config file.

We drop eslint-plugin-import because it does not the flat config file.

We can't upgrade to ESLint v9 because eslint-plugin-react does not support ESLint v9 yet.
  • Loading branch information
fniessink committed Jun 13, 2024
1 parent 48633d3 commit 321f2ef
Show file tree
Hide file tree
Showing 33 changed files with 603 additions and 379 deletions.
54 changes: 0 additions & 54 deletions components/frontend/.eslintrc.json

This file was deleted.

5 changes: 1 addition & 4 deletions components/frontend/ci/quality.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/bin/bash

# Eslint
npx eslint src

# Prettier
npx prettier --check src
npx eslint *.js *.mjs src
63 changes: 63 additions & 0 deletions components/frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { fixupConfigRules } from "@eslint/compat"
import pluginJs from "@eslint/js"
import pluginJest from "eslint-plugin-jest"
import pluginNode from "eslint-plugin-n"
import pluginPrettierConfigRecommended from "eslint-plugin-prettier/recommended"
import pluginPromise from "eslint-plugin-promise"
import pluginReactJSXRuntime from "eslint-plugin-react/configs/jsx-runtime.js"
import pluginReactConfigRecommended from "eslint-plugin-react/configs/recommended.js"
import pluginSimpleImportSort from "eslint-plugin-simple-import-sort"
import globals from "globals"

export default [
pluginJs.configs.recommended,
pluginJest.configs["flat/recommended"],
pluginNode.configs["flat/recommended-module"],
...fixupConfigRules(pluginReactConfigRecommended),
...fixupConfigRules(pluginReactJSXRuntime),
pluginPrettierConfigRecommended,
{
plugins: {
"simple-import-sort": pluginSimpleImportSort,
promise: pluginPromise,
},
languageOptions: {
globals: { ...globals.browser, ...globals.node },
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
rules: {
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"n/no-unsupported-features/node-builtins": "off", // Don't complain about 'fetch', 'URL.createObjectURL', and 'navigator'
"promise/always-return": "error",
"promise/no-return-wrap": "error",
"promise/param-names": "error",
"promise/catch-or-return": ["error", { allowFinally: true }],
"promise/no-native": "off",
"promise/no-nesting": "warn",
"promise/no-promise-in-callback": "warn",
"promise/no-callback-in-promise": "warn",
"promise/avoid-new": "warn",
"promise/no-new-statics": "error",
"promise/no-return-in-finally": "warn",
"promise/valid-params": "warn",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",
},
settings: {
react: {
version: "detect",
},
},
},
{
files: ["**/*.test.js"],
rules: {
"no-import-assign": "off",
"jest/expect-expect": ["error", { assertFunctionNames: ["expect*"] }],
},
},
]
23 changes: 12 additions & 11 deletions components/frontend/healthcheck.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
const http = require('http');
const http = require("http")

const options = {
host: 'localhost',
method: 'GET',
headers: { Connection: "close" },
host: "localhost",
method: "GET",
path: "/favicon.ico",
port: process.env.FRONTEND_PORT || 5000,
path: '/favicon.ico',
};
}

const healthCheck = http.request(options, (response) => {
process.exit(response.statusCode == 200 ? 0 : 1);
});
process.exitCode = response.statusCode == 200 ? 0 : 1
})

healthCheck.on('error', function() {
process.exit(1);
});
healthCheck.on("error", function () {
process.exitCode = 1
})

healthCheck.end();
healthCheck.end()
Loading

0 comments on commit 321f2ef

Please sign in to comment.