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

fix: update ts config #376

Merged
merged 5 commits into from
Oct 16, 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
19 changes: 8 additions & 11 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": [
"./tsconfig.app.json",
"./tsconfig.node.json",
"./cypress/tsconfig.json"
],
"ecmaFeatures": {
"jsx": true
},
Expand Down Expand Up @@ -60,6 +65,7 @@
}
],
"import/no-named-as-default": "off",
"import/extensions": "off",
"react/static-property-placement": [
"error",
"property assignment",
Expand All @@ -79,16 +85,6 @@
"allow": ["error"]
}
],
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"react/prop-types": "off",
"react/require-default-props": "off",
// eslint rule reports false error
Expand All @@ -109,7 +105,8 @@
"devDependencies": true
}
],
"import/prefer-default-export": "off"
"import/prefer-default-export": "off",
"import/no-unresolved": "off"
},
"overrides": [
{
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"files.trimTrailingWhitespace": true
"files.trimTrailingWhitespace": true,
"eslint.useFlatConfig": false
}
8 changes: 3 additions & 5 deletions cypress/e2e/homePage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HttpMethod, formatDate } from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';

import i18n from '@/config/i18n';
import i18n from '../../src/config/i18n';
import {
AVATAR_UPLOAD_ICON_ID,
AVATAR_UPLOAD_INPUT_ID,
Expand All @@ -14,8 +14,7 @@ import {
MEMBER_AVATAR_IMAGE_ID,
MEMBER_CREATED_AT_ID,
MEMBER_USERNAME_DISPLAY_ID,
} from '@/config/selectors';

} from '../../src/config/selectors';
import { BOB, MEMBER_WITH_AVATAR } from '../fixtures/members';
import {
AVATAR_LINK,
Expand All @@ -33,7 +32,6 @@ class TestHelper {

constructor(args: TestHelperInput) {
this.currentMember = JSON.parse(JSON.stringify(args.currentMember));
this.setupServer();
}

setupServer() {
Expand Down Expand Up @@ -76,10 +74,10 @@ class TestHelper {
}

describe('Upload Avatar', () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let helpers: TestHelper;
beforeEach(() => {
helpers = new TestHelper({ currentMember: BOB });
helpers.setupServer();
cy.visit('/');
});

Expand Down
3 changes: 1 addition & 2 deletions cypress/e2e/notFoundPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import {
GO_TO_HOME_LINK_ID,
NOT_FOUND_MESSAGE_ID,
NOT_FOUND_TEXT_ID,
} from '@/config/selectors';

} from '../../src/config/selectors';
import { BOB } from '../fixtures/members';

describe('404 Page Test', () => {
Expand Down
7 changes: 3 additions & 4 deletions cypress/e2e/profile/password.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FAILURE_MESSAGES, namespaces } from '@graasp/translations';

import i18n, { ACCOUNT_NAMESPACE } from '@/config/i18n';
import { PROFILE_PATH } from '@/config/paths';
import i18n, { ACCOUNT_NAMESPACE } from '../../../src/config/i18n';
import { PROFILE_PATH } from '../../../src/config/paths';
import {
PASSWORD_CREATE_CONTAINER_ID,
PASSWORD_DISPLAY_CONTAINER_ID,
Expand All @@ -11,8 +11,7 @@ import {
PASSWORD_INPUT_CURRENT_PASSWORD_ID,
PASSWORD_INPUT_NEW_PASSWORD_ID,
PASSWORD_SAVE_BUTTON_ID,
} from '@/config/selectors';

} from '../../../src/config/selectors';
import { ACCOUNT } from '../../../src/langs/constants';
import { BOB } from '../../fixtures/members';

Expand Down
6 changes: 2 additions & 4 deletions cypress/e2e/profile/personalInformation.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PROFILE_PATH } from 'config/paths';

import { PROFILE_PATH } from '../../../src/config/paths';
import {
PERSONAL_INFO_CANCEL_BUTTON_ID,
PERSONAL_INFO_DISPLAY_CONTAINER_ID,
Expand All @@ -9,8 +8,7 @@ import {
PERSONAL_INFO_INPUT_EMAIL_ID,
PERSONAL_INFO_SAVE_BUTTON_ID,
PERSONAL_INFO_USERNAME_DISPLAY_ID,
} from '@/config/selectors';

} from '../../../src/config/selectors';
import { BOB, MEMBERS } from '../../fixtures/members';

const changeUsername = (newUserName: string) => {
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/profile/publicProfile.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PROFILE_PATH } from '@/config/paths';
import { PROFILE_PATH } from '../../../src/config/paths';
import {
PUBLIC_PROFILE_BIO_ID,
PUBLIC_PROFILE_EDIT_BUTTON_ID,
Expand All @@ -9,8 +9,7 @@ import {
PUBLIC_PROFILE_SAVE_BUTTON_ID,
PUBLIC_PROFILE_TWITTER_HREF_ID,
PUBLIC_PROFILE_TWITTER_ID,
} from '@/config/selectors';

} from '../../../src/config/selectors';
import {
BOB,
MEMBER_EMPTY_PUBLIC_PROFILE,
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/settings/deleteMember.cy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { SETTINGS_PATH } from '@/config/paths';
import { SETTINGS_PATH } from '../../../src/config/paths';
import {
DELETE_MEMBER_BUTTON_ID,
DELETE_MEMBER_DIALOG_CONFIRMATION_BUTTON_ID,
DELETE_MEMBER_DIALOG_CONFIRMATION_FIELD_ID,
DELETE_MEMBER_DIALOG_TITLE_ID,
DELETE_MEMBER_SECTION_ID,
LOGIN_REQUIRED_TEXT_ID,
} from '@/config/selectors';

} from '../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../fixtures/members';

describe('Current Member', () => {
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/settings/exportData.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { SETTINGS_PATH } from '@/config/paths';
import { EXPORT_DATA_BUTTON_ID } from '@/config/selectors';

import { SETTINGS_PATH } from '../../../src/config/paths';
import { EXPORT_DATA_BUTTON_ID } from '../../../src/config/selectors';
import { CURRENT_MEMBER } from '../../fixtures/members';

describe('Check exporting data', () => {
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/settings/preferences.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EmailFrequency } from '@graasp/sdk';
import { langs } from '@graasp/translations';

import { SETTINGS_PATH } from '@/config/paths';
import { SETTINGS_PATH } from '../../../src/config/paths';
import {
PREFERENCES_ANALYTICS_SWITCH_ID,
PREFERENCES_CANCEL_BUTTON_ID,
Expand All @@ -11,8 +11,7 @@ import {
PREFERENCES_LANGUAGE_DISPLAY_ID,
PREFERENCES_LANGUAGE_SWITCH_ID,
PREFERENCES_SAVE_BUTTON_ID,
} from '@/config/selectors';

} from '../../../src/config/selectors';
import { BOB, CURRENT_MEMBER } from '../../fixtures/members';

describe('Display preferences', () => {
Expand Down
7 changes: 3 additions & 4 deletions cypress/e2e/storage.cy.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { formatDate, formatFileSize } from '@graasp/sdk';

import i18n from '@/config/i18n';
import { STORAGE_PATH } from '@/config/paths';
import i18n from '../../src/config/i18n';
import { STORAGE_PATH } from '../../src/config/paths';
import {
MEMBER_STORAGE_FILE_NAME_ID,
MEMBER_STORAGE_FILE_SIZE_ID,
MEMBER_STORAGE_FILE_UPDATED_AT_ID,
MEMBER_STORAGE_PARENT_FOLDER_ID,
STORAGE_BAR_LABEL_ID,
getCellId,
} from '@/config/selectors';

} from '../../src/config/selectors';
import {
CURRENT_MEMBER,
MEMBER_STORAGE_ITEM_RESPONSE,
Expand Down
5 changes: 2 additions & 3 deletions cypress/e2e/validateEmailPage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { HttpMethod } from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';

import { EMAIL_CHANGE_VALIDATION_PATH } from '@/config/paths';
import { EMAIL_CHANGE_VALIDATION_PATH } from '../../src/config/paths';
import {
EMAIL_VALIDATION_BUTTON_ID,
EMAIL_VALIDATION_CONFLICT_MESSAGE_ID,
EMAIL_VALIDATION_SUCCESS_MESSAGE_ID,
EMAIL_VALIDATION_UNAUTHORIZED_MESSAGE_ID,
} from '@/config/selectors';

} from '../../src/config/selectors';
import { CURRENT_MEMBER } from '../fixtures/members';

const API_HOST = Cypress.env('VITE_GRAASP_API_HOST');
Expand Down
4 changes: 2 additions & 2 deletions cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.app.json",
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom", "ES2021.String"],
Expand All @@ -8,6 +8,6 @@
"strict": true,
"sourceMap": false
},
"include": ["**/*.ts"],
"include": ["**/*.ts", "../cypress.config.ts"],
"exclude": ["coverage", ".nyc_output"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"pre-commit": "pnpm prettier:check && pnpm lint && pnpm type-check",
"prettier:check": "prettier --check src/**/*.{ts,tsx}",
"prettier:write": "prettier --write src/**/*.{ts,tsx}",
"type-check": "tsc --noEmit",
"type-check": "tsc --noEmit -p tsconfig.app.json",
"check": "pnpm prettier:check && pnpm lint && pnpm type-check",
"hooks:install": "husky",
"preinstall": "npx only-allow pnpm",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/settings/ExportData.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';

import { Button, Stack, Typography } from '@mui/material';

Expand Down
25 changes: 25 additions & 0 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src"]
}
39 changes: 9 additions & 30 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext", "ES2021.String"],
"allowJs": true, // todo: change to false once Uppy is moved to ts
"module": "ESNext",
"skipLibCheck": true,

"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,

"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,

"types": ["vite/client", "cypress"],
"baseUrl": "./src",
"paths": {
"@/*": ["./*"]
}
},
"include": ["src"],
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.node.json"
}
]
],
"compilerOptions": {
// this is needed for cypress to compile to ESM ... Should be removed when not using cypress anymore
"module": "ESNext"
}
}
20 changes: 15 additions & 5 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
{
"compilerOptions": {
"composite": true,
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"jsx": "react-jsx",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
"include": ["vite-env.d.ts", "vite.config.ts"]
}
Loading