Skip to content

Commit 725f5b2

Browse files
refactor: add typescript [ECO-960]
1 parent 0ddf211 commit 725f5b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2423
-2118
lines changed

.eslintrc.json

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
{
2-
"extends": ["next/babel","next/core-web-vitals"],
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:react/recommended",
9+
"extends: next/core-web-vitals"
10+
],
11+
"parserOptions": {
12+
"ecmaFeatures": {
13+
"jsx": true
14+
},
15+
"ecmaVersion": 12,
16+
"sourceType": "module"
17+
},
18+
"plugins": [
19+
"react"
20+
],
321
"rules": {
4-
"@next/next/no-page-custom-font":"off",
5-
"@next/next/no-sync-scripts":"off",
6-
"@next/next/no-img-element":"off",
7-
"react-hooks/exhaustive-deps":"off",
8-
"import/no-anonymous-default-export":"off"
22+
"react/prop-types":0,
23+
"no-undef":"off",
24+
"no-unused-vars": "off"
925
}
1026
}

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
npm-debug.log*
2424
yarn-debug.log*
2525
yarn-error.log*
26+
.pnpm-debug.log*
2627

2728
# local env files
28-
.env
29-
.env.local
30-
.env.development.local
31-
.env.test.local
32-
.env.production.local
29+
.env*.local
3330

3431
# vercel
3532
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo

README.md

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,4 @@ We have created an in-depth tutorial on how you can create a Next.js starter web
2727

2828
Read Contentstack [docs](https://www.contentstack.com/docs/)
2929

30-
Learn about [Next.js](https://learnnextjs.com/)
31-
32-
33-
34-
35-
36-
37-
38-
39-
30+
Learn about [Next.js](https://learnnextjs.com/)
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react';
22
import parse from 'html-react-parser';
3+
import { BucketProps, Bucket } from "../typescript/about-section-bucket";
34

4-
export default function AboutSectionBucket({ sectionWithBuckets }) {
5-
function bucketContent(bucket, index) {
5+
export default function AboutSectionBucket({ sectionWithBuckets }: {sectionWithBuckets:BucketProps}) {
6+
function bucketContent(bucket: Bucket, index: number) {
67
return (
78
<div className='mission-content-section' key={index}>
89
{bucket.icon && (
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React from 'react';
22
import Link from 'next/link';
33
import parse from 'html-react-parser';
4+
import {BlogListProps} from '../typescript/archive-relative';
45

5-
export default function ArchiveRelative({ blogs }) {
6+
export default function ArchiveRelative({ blogs }: BlogListProps) {
67
return (
78
<>
89
{blogs?.map((blog, idx) => (
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
2+
import {BannerProps} from '../typescript/blog';
23

3-
export default function BlogBanner({ blogBanner }) {
4+
export default function BlogBanner({ blogBanner }: {blogBanner : BannerProps}) {
45
return (
56
<div
67
className='blog-page-banner'
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import React from 'react';
22
import moment from 'moment';
33
import parse from 'html-react-parser';
44
import Link from 'next/link';
5+
import { BloglistProps } from "../typescript/blog";
56

6-
function BlogList({ bloglist }) {
7+
function BlogList({ bloglist }: { bloglist: BloglistProps }) {
78
let body = typeof bloglist.body === 'string' && bloglist.body.substr(0, 300);
8-
const stringLength = body.lastIndexOf(' ');
9-
body = `${body.substr(0, Math.min(body.length, stringLength))}...`;
9+
const stringLength = (body as string).lastIndexOf(' ');
10+
body = `${(body as string).substr(0, Math.min((body as string).length, stringLength))}...`;
1011
return (
1112
<div className='blog-list'>
1213
{bloglist.featured_image && (
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import React from 'react';
22
import Link from 'next/link';
33
import parse from 'html-react-parser';
4+
import { FeaturedBlogProps } from "../typescript/blog";
5+
6+
export default function BlogSection(props: FeaturedBlogProps) {
7+
8+
const fromBlog = props.fromBlog;
49

5-
export default function BlogSection({ fromBlog }) {
610
return (
711
<div className='community-section'>
812
<div className='community-head'>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import Link from 'next/link';
3+
import { CardProps } from "../typescript/card";
34

4-
export default function CardSection({ cards }) {
5+
export default function CardSection({ cards }: CardProps) {
56
return (
67
<div className='demo-section'>
78
{cards?.map((card, index) => (
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Tooltip from './tool-tip';
44

55
const DynamicReactJson = dynamic(import('react-json-view'), { ssr: false });
66

7-
function filterObject(inputObject) {
7+
function filterObject(inputObject: any) {
88
const unWantedProps = [
99
'_version',
1010
'ACL',
@@ -26,11 +26,11 @@ function filterObject(inputObject) {
2626
return inputObject;
2727
}
2828

29-
const DevTools = ({ response }) => {
29+
const DevTools = ({ response }: any) => {
3030
const filteredJson = filterObject(response);
3131
const [forceUpdate, setForceUpdate] = useState(0);
3232

33-
function copyObject(object) {
33+
function copyObject(object: any) {
3434
navigator.clipboard.writeText(object);
3535
setForceUpdate(1);
3636
}
@@ -47,7 +47,7 @@ const DevTools = ({ response }) => {
4747
id="staticBackdrop"
4848
data-bs-backdrop="static"
4949
data-bs-keyboard="false"
50-
tabIndex="-1"
50+
tabIndex={-1}
5151
aria-labelledby="staticBackdropLabel"
5252
aria-hidden="true"
5353
role="dialog"

0 commit comments

Comments
 (0)