Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
eslint linter added
Browse files Browse the repository at this point in the history
  • Loading branch information
kaimsfd committed Oct 6, 2023
1 parent cf7b9d3 commit 6c16092
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
2 changes: 0 additions & 2 deletions frontend/config/jest/jest.setup.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
34 changes: 34 additions & 0 deletions frontend/scripts/lint.js
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 6c16092

Please sign in to comment.