diff --git a/frontend/config/jest/jest.setup.ts b/frontend/config/jest/jest.setup.ts index 06ebce14..d0b7b454 100644 --- a/frontend/config/jest/jest.setup.ts +++ b/frontend/config/jest/jest.setup.ts @@ -1,5 +1,3 @@ -import "@testing-library/jest-dom"; - import { server } from "../../src/mocks/server"; import { queryClient } from "../../src/utils/test-utils"; import "whatwg-fetch"; diff --git a/frontend/package.json b/frontend/package.json index fab370df..cf5aba96 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -56,7 +56,7 @@ "build": "node scripts/build.js", "test": "node scripts/test.js", "format": "prettier --write **/*.{ja, jsx, ts,tsx,css}", - "eslint-lint": "eslint . --ext .js,.ts,.jsx,.tsx" + "eslint-lint": "node scripts/lint.js" }, "eslintConfig": { "extends": [ diff --git a/frontend/scripts/lint.js b/frontend/scripts/lint.js new file mode 100644 index 00000000..ac3d8e64 --- /dev/null +++ b/frontend/scripts/lint.js @@ -0,0 +1,34 @@ +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'test'; +process.env.NODE_ENV = 'test'; +process.env.PUBLIC_URL = ''; + +// Makes the script crash on unhandled rejections instead of silently +// ignoring them. In the future, promise rejections that are not handled will +// terminate the Node.js process with a non-zero exit code. +process.on('unhandledRejection', err => { + throw err; +}); + +// Ensure environment variables are read. +require('../config/env'); + +const { ESLint } = require("eslint"); + +(async function main() { + // 1. Create an instance. + const eslint = new ESLint(); + + // 2. Lint files. + const results = await eslint.lintFiles(["**/*{.js, .ts, .jsx, .tsx, .css}"]); + + // 3. Format the results. + const formatter = await eslint.loadFormatter("stylish"); + const resultText = formatter.format(results); + + // 4. Output it. + console.log(resultText); +})().catch((error) => { + process.exitCode = 1; + console.error(error); +});