Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate all remaining JS files to TS, tweak ESLint and Typescript configuration #3141

Merged
merged 6 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.
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"]
}
})