diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..bc4953f --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +// .eslintignore +node_modules +db \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..d4b3cb0 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,28 @@ +module.exports = { + parserOptions: { + ecmaVersion: 2020, + sourceType: 'module', + ecmaFeatures: { + jsx: true, + }, + }, + env: { + browser: true, + node: true, + es6: true, + }, + settings: { + react: { + version: 'detect', + }, + }, + extends: ['plugin:react/recommended', 'airbnb', 'prettier'], + plugins: ['react', 'prettier'], + rules: { + 'react/react-in-jsx-scope': 'off', + 'react/prop-types': 'off', + 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx'] }], + 'react/jsx-props-no-spreading': 'off', + 'no-plusplus': 'off', + }, +}; diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..09c508e --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +# Ignore : +build +.next +node_modules \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..907d02e --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,10 @@ +module.exports = { + tabWidth: 2, + printWidth: 80, + endOfLine: 'auto', + arrowParens: 'always', + semi: true, + useTabs: false, + singleQuote: true, + bracketSpacing: true, +}; diff --git a/components/about/Card.js b/components/about/Card.js index c004405..41517c2 100644 --- a/components/about/Card.js +++ b/components/about/Card.js @@ -17,7 +17,7 @@ const Card = ({ title, skills }) => ( {title} {skills.map((skill, index) => ( - {skill} + {skill} ))} ); diff --git a/components/about/Description.js b/components/about/Description.js index 1d5088f..15166e7 100644 --- a/components/about/Description.js +++ b/components/about/Description.js @@ -7,19 +7,13 @@ const Description = () => ( Hello, my name is Hendra Agil Syaputra. Usually called{' '} - Hendra / Agil. I'm currently {getAge()} years old. Born and - live in{' '} - { - - Karanganyar, Central Java, Indonesia - - } + Hendra / Agil. I'm currently {getAge()} years old. Born + and live in{' '} + + Karanganyar, Central Java, Indonesia + . Graduated from{' '} - { - - VHS 2 Karanganyar - - }{' '} + VHS 2 Karanganyar{' '} at 2021 as Software Engineering student. diff --git a/components/about/Skills.js b/components/about/Skills.js index cbbc151..c00cf18 100644 --- a/components/about/Skills.js +++ b/components/about/Skills.js @@ -6,7 +6,7 @@ import Card from './Card'; const Skills = () => ( {about.skills.map((skill, index) => ( - + ))} ); diff --git a/components/about/Socials.js b/components/about/Socials.js index 34c5d36..ba2d1ca 100644 --- a/components/about/Socials.js +++ b/components/about/Socials.js @@ -8,11 +8,9 @@ const Socials = () => ( You can reach me out via email at{' '} - { - - hendraaagil@gmail.com - - } + + hendraaagil@gmail.com + , or via socials below: ( spacing={{ base: 3, lg: 6 }} > {about.socials.map((social, index) => ( - + ))} diff --git a/components/blog/MarkdownComponent.js b/components/blog/MarkdownComponent.js index a2ffca0..5b9de3b 100644 --- a/components/blog/MarkdownComponent.js +++ b/components/blog/MarkdownComponent.js @@ -29,7 +29,6 @@ const MarkdownComponent = ({ markdownContent }) => { return ( ( @@ -64,12 +63,9 @@ const MarkdownComponent = ({ markdownContent }) => { {children} ) : ( - + + {String(children).replace(/\n$/, '')} + ); }, h1: ({ children }) => { @@ -237,7 +233,9 @@ const MarkdownComponent = ({ markdownContent }) => { thead: ({ children }) => {children}, tr: ({ children }) => {children}, }} - /> + > + {markdownContent} + ); }; diff --git a/components/nav/Navbar.js b/components/nav/Navbar.js index 818d255..39cd6bc 100644 --- a/components/nav/Navbar.js +++ b/components/nav/Navbar.js @@ -58,7 +58,11 @@ const Navbar = () => { {larger && ( {links.map((link, index) => ( - + ))} )} diff --git a/components/nav/menu/MenuDrawer.js b/components/nav/menu/MenuDrawer.js index 4c0f3ec..a8be88f 100644 --- a/components/nav/menu/MenuDrawer.js +++ b/components/nav/menu/MenuDrawer.js @@ -16,10 +16,10 @@ const MenuDrawer = ({ isOpen, onClose, links }) => ( {links.map((link, index) => ( ))} diff --git a/package.json b/package.json index 6a8f107..6615f98 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "scripts": { "dev": "next dev", "build": "next build", - "start": "next start" + "start": "next start", + "lint": "eslint ./components/** ./pages/** -c .eslintrc.js --ext js,jsx", + "lint-fix": "eslint ./components/** ./pages/** -c .eslintrc.js --fix --ext js,jsx" }, "dependencies": { "@chakra-ui/react": "^1.6.2", @@ -24,5 +26,15 @@ "react-markdown": "^6.0.2", "react-syntax-highlighter": "^15.4.3", "remark-gfm": "^1.0.0" + }, + "devDependencies": { + "eslint": "^7.28.0", + "eslint-config-airbnb": "^18.2.1", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-import": "^2.23.4", + "eslint-plugin-jsx-a11y": "^6.4.1", + "eslint-plugin-prettier": "^3.4.0", + "eslint-plugin-react": "^7.24.0", + "prettier": "^2.3.1" } } diff --git a/pages/blog/[slug].js b/pages/blog/[slug].js index 0b822b0..42cb57f 100644 --- a/pages/blog/[slug].js +++ b/pages/blog/[slug].js @@ -14,9 +14,9 @@ const client = createClient({ export const getStaticPaths = async () => { const res = await client.getEntries({ content_type: 'blog' }); - const paths = res.items.map((item) => { - return { params: { slug: item.fields.slug } }; - }); + const paths = res.items.map((item) => ({ + params: { slug: item.fields.slug }, + })); return { paths, diff --git a/pages/blog/index.js b/pages/blog/index.js index a3ae413..334abfd 100644 --- a/pages/blog/index.js +++ b/pages/blog/index.js @@ -31,7 +31,7 @@ const Blog = ({ blogs }) => { {blogs.map((blog) => { - const { slug, summary, title } = blog.fields; + const { slug, summary } = blog.fields; const { tags } = blog.metadata; const { createdAt, id } = blog.sys; @@ -40,7 +40,7 @@ const Blog = ({ blogs }) => { key={id} slug={slug} summary={summary} - title={title} + title={blog.fields.title} tags={tags} createdAt={createdAt} /> diff --git a/pages/index.js b/pages/index.js index 5013385..6591775 100644 --- a/pages/index.js +++ b/pages/index.js @@ -7,7 +7,7 @@ export default function Home() { - Hello, I'm Hendra Agil 👋 + Hello, I'm Hendra Agil 👋 Student. {getAge()} years old. diff --git a/pages/projects.js b/pages/projects.js index 33068ed..db6a185 100644 --- a/pages/projects.js +++ b/pages/projects.js @@ -22,7 +22,7 @@ const Projects = () => { {projects.map((project, index) => (