diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..0c88170 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +*.config* +node_modules +.rts2_cache_cjs +.rts2_cache_es +.rts2_cache_umd +dist diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..8c1fd53 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,36 @@ +module.exports = { + "env": { + "browser": true, + "es2021": true, + node: true, + }, + "extends": [ + "eslint:recommended", + "plugin:react/recommended", + 'prettier' + ], + "parserOptions": { + "ecmaFeatures": { + "jsx": true + }, + "ecmaVersion": 12, + "sourceType": "module", + "parser": '@typescript-eslint/parser' + }, + "plugins": [ + "react" + ], + rules: { + 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', + 'no-tabs': 'off', + "react/react-in-jsx-scope": "off", + "react/prop-types": "off", + "no-undef": "off" + }, + settings: { + react: { + version: 'detect' + } + } +}; diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..0c88170 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +*.config* +node_modules +.rts2_cache_cjs +.rts2_cache_es +.rts2_cache_umd +dist diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000..5b0e1c4 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,7 @@ +module.exports = { + bracketSpacing: true, + printWidth: 120, + singleQuote: true, + semi: false, + trailingComma: 'es5', +}; \ No newline at end of file diff --git a/package.json b/package.json index 583b539..432f509 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "build": "next build", "export": "yarn build && next export", "start": "next start", + "lint": "eslint . --fix", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { @@ -33,7 +34,22 @@ }, "devDependencies": { "autoprefixer": "9.8.6", + "eslint": "^7.10.0", + "eslint-config-prettier": "^6.12.0", + "eslint-plugin-prettier": "^3.1.4", + "eslint-plugin-react": "^7.21.3", + "husky": "^4.3.0", + "lint-staged": "^10.4.0", + "prettier": "^2.1.2", "rustywind": "0.6.6", "tailwindcss": "1.7.2" + }, + "lint-staged": { + "*.{js,ts,vue}": "yarn lint" + }, + "husky": { + "hooks": { + "pre-commit": "lint-staged" + } } -} +} \ No newline at end of file diff --git a/pages/index.js b/pages/index.js index 9f2db84..d8446aa 100644 --- a/pages/index.js +++ b/pages/index.js @@ -26,8 +26,8 @@ function DaftarIsiPage() { {babChild.children && babChild.children.length > 0 && (
    - {babChild.children.map((li) => ( -
  1. + {babChild.children.map((li, index) => ( +
  2. {li.text} diff --git a/pages/pancasila.js b/pages/pancasila.js index aeeb5d8..7ed2c41 100644 --- a/pages/pancasila.js +++ b/pages/pancasila.js @@ -43,7 +43,7 @@ function PancasilaPage() {

    {PancasilaData.meaning.preface}

    - {PancasilaData.meaning.data.map((section, index) => ( + {PancasilaData.meaning.data.map((section) => (