From 136d7974f413a3eb80d8f717a3b841a4a029f822 Mon Sep 17 00:00:00 2001 From: Subliminal Guy <subliminal_kid@posteo.de> Date: Wed, 5 Feb 2025 15:43:04 +0100 Subject: [PATCH] Add Gitignore Add JS Module Add ESLint config Add data.js --- .gitignore | 2 ++ eslint.config.mjs | 16 ++++++++++++++++ helper/data.js | 10 ++++++++++ index.html | 27 +++++++++++++++------------ index.js | 9 ++++++++- package.json | 12 ++++++++++-- 6 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 .gitignore create mode 100644 eslint.config.mjs create mode 100644 helper/data.js diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..572406b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/node_modules +package-lock.json \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..069e292 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,16 @@ +import globals from "globals"; +import pluginJs from "@eslint/js"; + + +/** @type {import('eslint').Linter.Config[]} */ +export default [ + { + languageOptions: { globals: globals.browser }, + "rules": { + "max-len": ["error", { "code": 80 }], + "indent": ["error", 2] + } + }, + pluginJs.configs.recommended, + +]; \ No newline at end of file diff --git a/helper/data.js b/helper/data.js new file mode 100644 index 0000000..33be81c --- /dev/null +++ b/helper/data.js @@ -0,0 +1,10 @@ +const data = [ + { + "id": 1, + "name": "Leanne Graham", + "username": "Bret", + "email": "Q7Z2H@example.com", + } +] + +export default data \ No newline at end of file diff --git a/index.html b/index.html index 280a177..2a74331 100644 --- a/index.html +++ b/index.html @@ -1,14 +1,17 @@ <!DOCTYPE html> <html lang="en"> - <head> - <meta charset="UTF-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1.0" /> - <link rel="stylesheet" href="style.css" /> - - <title>rbb Schulung</title> - </head> - <body> - <button class="main-button" type="button">Click</button> - <script type="text/javascript" src="index.js"></script> - </body> -</html> + +<head> + <meta charset="UTF-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> + <link rel="stylesheet" href="style.css" /> + + <title>rbb Schulung</title> +</head> + +<body> + <button class="main-button" type="button">Click</button> + <script type="module" src="index.js"></script> +</body> + +</html> \ No newline at end of file diff --git a/index.js b/index.js index 0cdebe5..a1ef507 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,12 @@ +import data from "./helper/data.js"; + + const button = document.getElementsByClassName("main-button")[0]; button.addEventListener("click", () => { - console.log("clicked"); + console.log(data); }); + + + + diff --git a/package.json b/package.json index 1f55709..3a8bf37 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,16 @@ "description": "A basic vanilla repo for education", "main": "index.html", "scripts": { - "test": "npm run dev" + "test": "npm run dev", + "lint": "eslint", + "lint:fix": "npm run lint -- --fix" }, "author": "subliminalguy", - "license": "ISC" + "license": "ISC", + "devDependencies": { + "@eslint/js": "^9.19.0", + "eslint": "^8.57.1", + "eslint-config-airbnb": "^19.0.4", + "globals": "^15.14.0" + } } -- GitLab