Skip to content

Commit

Permalink
Migrate all remaining JS files to TS, tweak ESLint and Typescript con…
Browse files Browse the repository at this point in the history
…figuration (#3141)

* Migrate test files to typescript

* Delete .babelrc file

* Use simpler command to run eslint

* Reconfigure tsconfig

Use esnext consistently in tsconfig.json

Add vitest globals to tsconfig types

Include src and test directories in tsconfig

Split tsconfig into separate files

* Comment out test with no assertion

* Reconfigure eslint
  • Loading branch information
grahamalama authored Jan 25, 2024
1 parent 09076ff commit 539072b
Show file tree
Hide file tree
Showing 57 changed files with 81 additions and 104 deletions.
10 changes: 0 additions & 10 deletions .babelrc

This file was deleted.

31 changes: 0 additions & 31 deletions .eslintrc

This file was deleted.

36 changes: 36 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = {
"root": true,
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["dist", ".eslintrc.cjs"],
"env": { "browser": true, "es2020": true },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier"
],
"plugins": ["@typescript-eslint/eslint-plugin"],
"rules": {
// ***
// TODO: turn these rules on progressively
"prefer-const": "off",
"no-var": "off",
"react-hooks/exhaustive-deps": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
// ***
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{ "vars": "all", "args": "none", "varsIgnorePattern": "^_" }
],
"no-console": "off"
},
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": ["./tsconfig.json", "./tsconfig.node.json"],
"tsconfigRootDir": __dirname,
}
}
File renamed without changes.
45 changes: 20 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:kinto-single": "ASSET_PATH=/v1/admin KINTO_ADMIN_SINGLE_SERVER=1 vite build",
"cs-check": "prettier -l \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
"cs-format": "prettier \"{src,test}/**/*.{js,jsx,ts,tsx}\" --write",
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\" \"test/**/*.{js,jsx,ts,tsx}\"",
"lint": "eslint . --ext ts,tsx",
"preview": "vite preview",
"publish-to-gh-pages": "ASSET_PATH=/kinto-admin/ npm run build && gh-pages --add --dist build/",
"start": "vite",
Expand Down Expand Up @@ -61,8 +61,9 @@
"@typescript-eslint/parser": "^6.19.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"gh-pages": "^6.0.0",
"prettier": "^3.0.2",
"toctoc": "^0.4.0",
Expand Down
16 changes: 0 additions & 16 deletions test/.eslintrc

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ describe("SimpleReviewHeader component", () => {
expect(await screen.findByTestId("spinner")).toBeDefined();
});

it("should open CommentDialog when request review is clicked and call requestReview from modal", async () => {
const {} = renderButtons({ status: "work-in-progress" });
it.skip("should open CommentDialog when request review is clicked and call requestReview from modal", async () => {
// TODO: What should this test do?
// const { } = renderButtons({ status: "work-in-progress" });
});

it("should display rollback button when status is wip and call rollbackChanges from modal", async () => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 7 additions & 17 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable", "esnext"],
"module": "esnext",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"types": ["vitest/globals"],
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
Expand All @@ -16,19 +17,8 @@
"forceConsistentCasingInFileNames": true,
"experimentalDecorators": true,
"declaration": true,
"allowJs": false,

"allowJs": false,
},
"ts-node": {
"compilerOptions": {
"sourceMap": true,
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
},
"include": ["./src/"]
"include": ["src", "test", "__mocks__"],
"references": [{ "path": "./tsconfig.node.json" }]
}
11 changes: 11 additions & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"sourceMap": true,
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export default defineConfig({
globals: true,
environment: "jsdom",
include: ["**/*_{test,spec}.?(c|m)[jt]s?(x)"],
setupFiles: ["test/setupTests.js"]
setupFiles: ["test/setupTests.ts"]
}
})

0 comments on commit 539072b

Please sign in to comment.