Refactor tsconfig setup (#1142)

This commit is contained in:
Neeraj Gupta 2023-05-29 11:12:33 +05:30 committed by GitHub
commit 77d7ec12e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 131 additions and 100 deletions

View file

@ -1,4 +1,13 @@
module.exports = {
// When root is set to true, ESLint will stop looking for configuration files in parent directories.
// This is required here to ensure desktop picks the right eslint config, where this app is
// packaged as a submodule.
root: true,
extends: ['@ente/eslint-config'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
ignorePatterns: ['.eslintrc.js'],
};

View file

@ -52,8 +52,6 @@ module.exports = (phase) =>
'@mui/material',
'@mui/system',
'@mui/icons-material',
'@ente/tsconfig',
'@ente/eslint-config',
],
env: {
SENTRY_RELEASE: GIT_SHA,

View file

@ -90,8 +90,8 @@
},
"devDependencies": {
"@ente/eslint-config": "*",
"@ente/tsconfig": "*",
"@next/bundle-analyzer": "^13.1.6",
"@typescript-eslint/parser": "^5.59.2",
"@types/bs58": "^4.0.1",
"@types/debounce-promise": "^3.1.3",
"@types/libsodium-wrappers": "^0.7.8",

View file

@ -1,5 +0,0 @@
import { VerticallyCentered } from 'components/Container';
const FormContainer = VerticallyCentered;
export default FormContainer;

View file

@ -16,7 +16,6 @@ import { isFirstLogin } from 'utils/storage';
import { AppContext } from 'pages/_app';
import { logError } from 'utils/sentry';
import { KeyAttributes, User } from 'types/user';
import FormContainer from 'components/Form/FormContainer';
import FormPaper from 'components/Form/FormPaper';
import FormPaperTitle from 'components/Form/FormPaper/Title';
import FormPaperFooter from 'components/Form/FormPaper/Footer';
@ -109,7 +108,7 @@ export default function Credentials() {
}
return (
<FormContainer>
<VerticallyCentered>
<FormPaper style={{ minWidth: '320px' }}>
<FormPaperTitle>{t('PASSWORD')}</FormPaperTitle>
@ -128,6 +127,6 @@ export default function Credentials() {
</LinkButton>
</FormPaperFooter>
</FormPaper>
</FormContainer>
</VerticallyCentered>
);
}

View file

@ -19,7 +19,6 @@ import EnteSpinner from 'components/EnteSpinner';
import { AppContext } from 'pages/_app';
import { logError } from 'utils/sentry';
import { KeyAttributes, User } from 'types/user';
import FormContainer from 'components/Form/FormContainer';
import FormPaper from 'components/Form/FormPaper';
import FormTitle from 'components/Form/FormPaper/Title';
import { APPS, getAppName } from 'constants/apps';
@ -112,7 +111,7 @@ export default function Generate() {
somethingWentWrong={() => null}
/>
) : (
<FormContainer>
<VerticallyCentered>
<FormPaper>
<FormTitle>{t('SET_PASSPHRASE')}</FormTitle>
<SetPasswordForm
@ -126,7 +125,7 @@ export default function Generate() {
</LinkButton>
</FormPaperFooter>
</FormPaper>
</FormContainer>
</VerticallyCentered>
)}
</>
);

View file

@ -6,7 +6,6 @@ import Login from 'components/Login';
import { VerticallyCentered } from 'components/Container';
import { getData, LS_KEYS } from 'utils/storage/localStorage';
import { PAGES } from 'constants/pages';
import FormContainer from 'components/Form/FormContainer';
import FormPaper from 'components/Form/FormPaper';
export default function Home() {
@ -36,10 +35,10 @@ export default function Home() {
</EnteSpinner>
</VerticallyCentered>
) : (
<FormContainer>
<VerticallyCentered>
<FormPaper>
<Login signUp={register} />
</FormPaper>
</FormContainer>
</VerticallyCentered>
);
}

View file

@ -33,7 +33,6 @@ import SharedAlbumNavbar from 'components/pages/sharedAlbum/Navbar';
import { CollectionInfo } from 'components/Collections/CollectionInfo';
import { CollectionInfoBarWrapper } from 'components/Collections/styledComponents';
import { ITEM_TYPE, TimeStampListItem } from 'components/PhotoList';
import FormContainer from 'components/Form/FormContainer';
import FormPaper from 'components/Form/FormPaper';
import FormPaperTitle from 'components/Form/FormPaper/Title';
import Typography from '@mui/material/Typography';
@ -355,7 +354,7 @@ export default function PublicCollectionGallery() {
}
if (isPasswordProtected && !passwordJWTToken.current) {
return (
<FormContainer>
<VerticallyCentered>
<FormPaper>
<FormPaperTitle>{t('PASSWORD')}</FormPaperTitle>
<Typography color={'text.muted'} mb={2} variant="small">
@ -368,7 +367,7 @@ export default function PublicCollectionGallery() {
fieldType="password"
/>
</FormPaper>
</FormContainer>
</VerticallyCentered>
);
}
if (!publicFiles) {

View file

@ -6,7 +6,7 @@ import { getData, LS_KEYS } from 'utils/storage/localStorage';
import SignUp from 'components/SignUp';
import { PAGES } from 'constants/pages';
import FormPaper from 'components/Form/FormPaper';
import FormContainer from 'components/Form/FormContainer';
import { VerticallyCentered } from 'components/Container';
export default function SignUpPage() {
const router = useRouter();
@ -29,7 +29,7 @@ export default function SignUpPage() {
};
return (
<FormContainer>
<VerticallyCentered>
{loading ? (
<EnteSpinner />
) : (
@ -37,6 +37,6 @@ export default function SignUpPage() {
<SignUp login={login} />
</FormPaper>
)}
</FormContainer>
</VerticallyCentered>
);
}

View file

@ -10,10 +10,10 @@ import { setData, LS_KEYS, getData } from 'utils/storage/localStorage';
import { t } from 'i18next';
import LinkButton from 'components/pages/gallery/LinkButton';
import FormContainer from 'components/Form/FormContainer';
import FormPaper from 'components/Form/FormPaper';
import FormTitle from 'components/Form/FormPaper/Title';
import FormPaperFooter from 'components/Form/FormPaper/Footer';
import { VerticallyCentered } from 'components/Container';
export default function Home() {
const [sessionID, setSessionID] = useState('');
@ -57,7 +57,7 @@ export default function Home() {
}
};
return (
<FormContainer>
<VerticallyCentered>
<FormPaper sx={{ maxWidth: '410px' }}>
<FormTitle>{t('TWO_FACTOR')}</FormTitle>
<VerifyTwoFactor onSubmit={onSubmit} buttonText={t('VERIFY')} />
@ -72,6 +72,6 @@ export default function Home() {
</LinkButton>
</FormPaperFooter>
</FormPaper>
</FormContainer>
</VerticallyCentered>
);
}

View file

@ -21,7 +21,6 @@ import FormPaperTitle from 'components/Form/FormPaper/Title';
import FormPaper from 'components/Form/FormPaper';
import FormPaperFooter from 'components/Form/FormPaper/Footer';
import LinkButton from 'components/pages/gallery/LinkButton';
import FormContainer from 'components/Form/FormContainer';
import SingleInputForm, {
SingleInputFormProps,
} from 'components/SingleInputForm';
@ -132,7 +131,7 @@ export default function Verify() {
}
return (
<FormContainer>
<VerticallyCentered>
<FormPaper>
<FormPaperTitle sx={{ mb: 14, wordBreak: 'break-word' }}>
<Trans
@ -167,6 +166,6 @@ export default function Verify() {
</LinkButton>
</FormPaperFooter>
</FormPaper>
</FormContainer>
</VerticallyCentered>
);
}

View file

@ -1,7 +1,20 @@
{
"extends": "@ente/tsconfig/ente.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "./src"
"baseUrl": "./src",
"downlevelIteration": true,
"jsx": "preserve",
"jsxImportSource": "@emotion/react",
"lib": ["dom", "dom.iterable", "esnext", "webworker"],
"noFallthroughCasesInSwitch": false,
"noImplicitAny": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"strictBindCallApply": false,
"strictNullChecks": false,
"strictPropertyInitialization": false,
"target": "es5",
"useUnknownInCatchVariables": false
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
"exclude": ["node_modules", "out", ".next", "thirdparty"]

View file

@ -2,6 +2,10 @@
"name": "ente-web",
"version": "1.0.0",
"private": true,
"workspaces": [
"packages/*",
"apps/*"
],
"scripts": {
"build": "turbo run build && turbo run export",
"dev": "turbo run dev --parallel",
@ -24,10 +28,6 @@
"standard": {
"parser": "babel-eslint"
},
"workspaces": [
"packages/*",
"apps/*"
],
"lint-staged": {
"apps/**/*.{js,jsx,ts,tsx}": [
"eslint --fix",

View file

@ -0,0 +1,9 @@
module.exports = {
extends: ['@ente/eslint-config'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
ignorePatterns: ['.eslintrc.js'],
};

View file

@ -7,6 +7,7 @@ module.exports = {
'prettier',
],
parserOptions: {
tsconfigRootDir: __dirname,
project: './tsconfig.json',
},
plugins: ['@typescript-eslint'],

View file

@ -7,7 +7,7 @@
"parser": "babel-eslint"
},
"devDependencies": {
"@ente/tsconfig": "*",
"@typescript-eslint/parser": "^5.59.2",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"eslint": "latest",
"eslint-config-next": "latest",

View file

@ -0,0 +1,3 @@
{
"extends": "../../tsconfig.base.json"
}

View file

@ -1,28 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext", "webworker"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"strictBindCallApply": false,
"strictNullChecks": false,
"strictPropertyInitialization": false,
"noImplicitAny": false,
"useUnknownInCatchVariables": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"baseUrl": "./src",
"downlevelIteration": true,
"jsxImportSource": "@emotion/react",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
"exclude": ["node_modules", "out", ".next", "thirdparty"]
}

View file

@ -1,8 +0,0 @@
{
"name": "@ente/tsconfig",
"version": "0.0.0",
"private": true,
"exports": {
"./ente.json": "./ente.json"
}
}

28
tsconfig.base.json Normal file
View file

@ -0,0 +1,28 @@
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"incremental": true,
"isolatedModules": true,
"jsx": "react-jsx",
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"moduleResolution": "node",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es2021",
"paths": {
"@ente/eslint-config/*": ["./packages/eslint-config/*"]
}
},
"exclude": ["**/node_modules", "**/.*/"]
}

View file

@ -1,28 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext", "webworker"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"strictBindCallApply": false,
"strictNullChecks": false,
"strictPropertyInitialization": false,
"noImplicitAny": false,
"useUnknownInCatchVariables": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"baseUrl": "./src",
"downlevelIteration": true,
"jsxImportSource": "@emotion/react",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
"exclude": ["node_modules", "out", ".next", "thirdparty"]
}

View file

@ -1095,6 +1095,16 @@
"@typescript-eslint/typescript-estree" "5.48.1"
debug "^4.3.4"
"@typescript-eslint/parser@^5.59.2":
version "5.59.7"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.59.7.tgz#02682554d7c1028b89aa44a48bf598db33048caa"
integrity sha512-VhpsIEuq/8i5SF+mPg9jSdIwgMBBp0z9XqjiEay+81PYLJuroN+ET1hM5IhkiYMJd9MkTz8iJLt7aaGAgzWUbQ==
dependencies:
"@typescript-eslint/scope-manager" "5.59.7"
"@typescript-eslint/types" "5.59.7"
"@typescript-eslint/typescript-estree" "5.59.7"
debug "^4.3.4"
"@typescript-eslint/scope-manager@5.48.1":
version "5.48.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.48.1.tgz#39c71e4de639f5fe08b988005beaaf6d79f9d64d"
@ -1111,6 +1121,14 @@
"@typescript-eslint/types" "5.59.1"
"@typescript-eslint/visitor-keys" "5.59.1"
"@typescript-eslint/scope-manager@5.59.7":
version "5.59.7"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.59.7.tgz#0243f41f9066f3339d2f06d7f72d6c16a16769e2"
integrity sha512-FL6hkYWK9zBGdxT2wWEd2W8ocXMu3K94i3gvMrjXpx+koFYdYV7KprKfirpgY34vTGzEPPuKoERpP8kD5h7vZQ==
dependencies:
"@typescript-eslint/types" "5.59.7"
"@typescript-eslint/visitor-keys" "5.59.7"
"@typescript-eslint/type-utils@5.59.1":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.59.1.tgz#63981d61684fd24eda2f9f08c0a47ecb000a2111"
@ -1131,6 +1149,11 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.1.tgz#03f3fedd1c044cb336ebc34cc7855f121991f41d"
integrity sha512-dg0ICB+RZwHlysIy/Dh1SP+gnXNzwd/KS0JprD3Lmgmdq+dJAJnUPe1gNG34p0U19HvRlGX733d/KqscrGC1Pg==
"@typescript-eslint/types@5.59.7":
version "5.59.7"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.59.7.tgz#6f4857203fceee91d0034ccc30512d2939000742"
integrity sha512-UnVS2MRRg6p7xOSATscWkKjlf/NDKuqo5TdbWck6rIRZbmKpVNTLALzNvcjIfHBE7736kZOFc/4Z3VcZwuOM/A==
"@typescript-eslint/typescript-estree@5.48.1":
version "5.48.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.48.1.tgz#9efa8ee2aa471c6ab62e649f6e64d8d121bc2056"
@ -1157,6 +1180,19 @@
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/typescript-estree@5.59.7":
version "5.59.7"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.59.7.tgz#b887acbd4b58e654829c94860dbff4ac55c5cff8"
integrity sha512-4A1NtZ1I3wMN2UGDkU9HMBL+TIQfbrh4uS0WDMMpf3xMRursDbqEf1ahh6vAAe3mObt8k3ZATnezwG4pdtWuUQ==
dependencies:
"@typescript-eslint/types" "5.59.7"
"@typescript-eslint/visitor-keys" "5.59.7"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
semver "^7.3.7"
tsutils "^3.21.0"
"@typescript-eslint/utils@5.59.1":
version "5.59.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.59.1.tgz#d89fc758ad23d2157cfae53f0b429bdf15db9473"
@ -1187,6 +1223,14 @@
"@typescript-eslint/types" "5.59.1"
eslint-visitor-keys "^3.3.0"
"@typescript-eslint/visitor-keys@5.59.7":
version "5.59.7"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.59.7.tgz#09c36eaf268086b4fbb5eb9dc5199391b6485fc5"
integrity sha512-tyN+X2jvMslUszIiYbF0ZleP+RqQsFVpGrKI6e0Eet1w8WmhsAtmzaqm8oM8WJQ1ysLwhnsK/4hYHJjOgJVfQQ==
dependencies:
"@typescript-eslint/types" "5.59.7"
eslint-visitor-keys "^3.3.0"
"@zip.js/zip.js@^2.4.2":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@zip.js/zip.js/-/zip.js-2.4.2.tgz#7c2d4b381c0f73dffa1d02ef630c4168ebd5cc4a"