diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 9f089b5..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -dev -dist diff --git a/.eslintignore b/.eslintignore new file mode 120000 index 0000000..6200b3a --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +./.gitignore \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index 1dcf5f8..3fd5a09 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,13 +1,29 @@ { "root": true, "env": { - "browser": true, - "es6": true, - "node": true + "browser": true + }, + "extends": ["eslint:recommended", "plugin:unicorn/recommended", "prettier"], + "rules": { + "unicorn/no-for-loop": 0 }, - "extends": ["airbnb-base", "prettier"], "parserOptions": { - "ecmaVersion": 2020, + "ecmaVersion": "latest", "sourceType": "module" - } + }, + "overrides": [ + { + "files": ["postcss.config.js", "vite.config.js"], + "env": { + "node": true, + "browser": false + } + }, + { + "files": ["postcss.config.js"], + "rules": { + "unicorn/prefer-module": 0 + } + } + ] } diff --git a/package.json b/package.json index 60f021f..6aa828e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "build:js": "vite build", "build:css": "postcss src/shareon.css -o dist/shareon.min.css --map", "dev": "vite", - "lint": "prettier --check . && eslint src/*.js", + "lint": "prettier --check . && eslint .", "size": "size-limit", "test": "pnpm run lint && pnpm run build && pnpm run size", "postversion": "pnpm run build" @@ -49,9 +49,8 @@ "autoprefixer": "^10.4.2", "cssnano": "^5.0.16", "eslint": "^8.8.0", - "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "^2.25.4", + "eslint-plugin-unicorn": "^40.1.0", "postcss": "^8.4.6", "postcss-banner": "^4.0.1", "postcss-calc": "^8.2.3", diff --git a/postcss.config.js b/postcss.config.js index 0b0d275..e53f920 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,5 +1,5 @@ -const pkg = require("./package.json"); -const bannerText = `${pkg.name} v${pkg.version}`; +const package_ = require("./package.json"); +const bannerText = `${package_.name} v${package_.version}`; module.exports = { map: { diff --git a/src/index.js b/src/index.js index 7439056..ef7818d 100644 --- a/src/index.js +++ b/src/index.js @@ -6,4 +6,4 @@ if (s && s.hasAttribute("init")) { initializeShareon(); } -export default initializeShareon; +export { default } from "./shareon"; diff --git a/src/shareon.js b/src/shareon.js index 668b0df..4164053 100644 --- a/src/shareon.js +++ b/src/shareon.js @@ -30,18 +30,30 @@ const urlBuilderMap = { whatsapp: (d) => `https://wa.me/?text=${d.title}%0D%0A${d.url}${d.text ? `%0D%0A%0D%0A${d.text}` : ''}`, }; +const openUrl = (buttonUrl) => () => { + window.open(buttonUrl, "_blank", "noopener,noreferrer"); +}; + const initializeShareon = () => { - const shareonContainers = document.getElementsByClassName("shareon"); + const shareonContainers = document.querySelectorAll(".shareon"); // iterate over