From 93a77bb56e9b64c9354d5bfca8d2138e3ba95bd0 Mon Sep 17 00:00:00 2001 From: Daniel <50356015+danny007in@users.noreply.github.com> Date: Mon, 3 Apr 2023 18:10:02 +0530 Subject: [PATCH] added eslint for astro --- .eslintrc.json | 14 ++++ package-lock.json | 103 +++++++++++++++++++++++++++++ package.json | 2 +- src/config/.eslintrc.json | 14 ---- src/config/rollup.config.js | 5 +- src/html/.eslintrc.json | 24 +++++++ src/html/.tsconfig.json | 1 + src/html/components/_scripts.astro | 3 +- 8 files changed, 146 insertions(+), 20 deletions(-) delete mode 100644 src/config/.eslintrc.json create mode 100644 src/html/.eslintrc.json diff --git a/.eslintrc.json b/.eslintrc.json index b69e66fee..50415e9ab 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -100,6 +100,20 @@ "never" ] } + }, + { + "files": ["src/config/**"], + "env": { + "browser": false, + "node": true + }, + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "no-console": "off", + "unicorn/prefer-top-level-await": "off" + } } ] } diff --git a/package-lock.json b/package-lock.json index 6a8c307f3..d0e4e801f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "eslint": "^8.36.0", "eslint-config-xo": "^0.43.1", "eslint-config-xo-typescript": "^0.56.0", + "eslint-plugin-astro": "^0.26.1", "eslint-plugin-import": "^2.27.5", "eslint-plugin-unicorn": "^46.0.0", "fs-extra": "^11.1.1", @@ -2043,6 +2044,28 @@ } } }, + "node_modules/astro-eslint-parser": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/astro-eslint-parser/-/astro-eslint-parser-0.13.2.tgz", + "integrity": "sha512-hLCfc4IfeR550tCxEQDOnoDbf+B7CtU3he0foNQ+XxfYyx+8qKwcEIvigrU1PzfwAfAvT83RFA1Q6TWHDj82GA==", + "dev": true, + "dependencies": { + "@astrojs/compiler": "^1.0.0", + "@typescript-eslint/scope-manager": "^5.48.2", + "@typescript-eslint/types": "^5.25.0", + "astrojs-compiler-sync": "^0.3.0", + "debug": "^4.3.4", + "eslint-visitor-keys": "^3.0.0", + "espree": "^9.0.0", + "semver": "^7.3.8" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + } + }, "node_modules/astro/node_modules/ansi-regex": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", @@ -2144,6 +2167,24 @@ "node": ">=12" } }, + "node_modules/astrojs-compiler-sync": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/astrojs-compiler-sync/-/astrojs-compiler-sync-0.3.2.tgz", + "integrity": "sha512-q/8Z30WNpsktLKS5NdT/6QAF9Q/C4ucLldqUpHgvRhuj/6jkJyOQfapQxkTKp8MK4RjH9sSsClfrTIdk8JZlKw==", + "dev": true, + "dependencies": { + "synckit": "^0.8.0" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "@astrojs/compiler": ">=0.27.0" + } + }, "node_modules/autoprefixer": { "version": "10.4.14", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.14.tgz", @@ -3570,6 +3611,29 @@ "ms": "^2.1.1" } }, + "node_modules/eslint-plugin-astro": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-astro/-/eslint-plugin-astro-0.26.1.tgz", + "integrity": "sha512-FEZOrOQ5ahenbwjKz5LYJpeOZUggDM54idrq5bTJdL4GsXy1xx2eyKy5UjGhh8NwddowCCPqfDHFfDz9oNj/ew==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@jridgewell/sourcemap-codec": "^1.4.14", + "@typescript-eslint/types": "^5.25.0", + "astro-eslint-parser": "^0.13.1", + "postcss": "^8.4.14", + "postcss-selector-parser": "^6.0.10" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ota-meshi" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-plugin-import": { "version": "2.27.5", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz", @@ -11661,6 +11725,31 @@ } } }, + "astro-eslint-parser": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/astro-eslint-parser/-/astro-eslint-parser-0.13.2.tgz", + "integrity": "sha512-hLCfc4IfeR550tCxEQDOnoDbf+B7CtU3he0foNQ+XxfYyx+8qKwcEIvigrU1PzfwAfAvT83RFA1Q6TWHDj82GA==", + "dev": true, + "requires": { + "@astrojs/compiler": "^1.0.0", + "@typescript-eslint/scope-manager": "^5.48.2", + "@typescript-eslint/types": "^5.25.0", + "astrojs-compiler-sync": "^0.3.0", + "debug": "^4.3.4", + "eslint-visitor-keys": "^3.0.0", + "espree": "^9.0.0", + "semver": "^7.3.8" + } + }, + "astrojs-compiler-sync": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/astrojs-compiler-sync/-/astrojs-compiler-sync-0.3.2.tgz", + "integrity": "sha512-q/8Z30WNpsktLKS5NdT/6QAF9Q/C4ucLldqUpHgvRhuj/6jkJyOQfapQxkTKp8MK4RjH9sSsClfrTIdk8JZlKw==", + "dev": true, + "requires": { + "synckit": "^0.8.0" + } + }, "autoprefixer": { "version": "10.4.14", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.14.tgz", @@ -12683,6 +12772,20 @@ } } }, + "eslint-plugin-astro": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-astro/-/eslint-plugin-astro-0.26.1.tgz", + "integrity": "sha512-FEZOrOQ5ahenbwjKz5LYJpeOZUggDM54idrq5bTJdL4GsXy1xx2eyKy5UjGhh8NwddowCCPqfDHFfDz9oNj/ew==", + "dev": true, + "requires": { + "@eslint-community/eslint-utils": "^4.2.0", + "@jridgewell/sourcemap-codec": "^1.4.14", + "@typescript-eslint/types": "^5.25.0", + "astro-eslint-parser": "^0.13.1", + "postcss": "^8.4.14", + "postcss-selector-parser": "^6.0.10" + } + }, "eslint-plugin-import": { "version": "2.27.5", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz", diff --git a/package.json b/package.json index 8085c504a..ae399d18d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "license": "MIT", "author": "Colorlib ", "main": "dist/js/adminlte.min.js", - "types": "dist/js/types/adminlte.d.ts", "scripts": { "dev": "npm-run-all --parallel watch docs-serve", "css": "npm-run-all css-compile css-prefix css-rtl css-minify", @@ -70,6 +69,7 @@ "eslint": "^8.36.0", "eslint-config-xo": "^0.43.1", "eslint-config-xo-typescript": "^0.56.0", + "eslint-plugin-astro": "^0.26.1", "eslint-plugin-import": "^2.27.5", "eslint-plugin-unicorn": "^46.0.0", "fs-extra": "^11.1.1", diff --git a/src/config/.eslintrc.json b/src/config/.eslintrc.json deleted file mode 100644 index 85dfa7a18..000000000 --- a/src/config/.eslintrc.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "env": { - "browser": false, - "node": true - }, - "parserOptions": { - "sourceType": "module" - }, - "extends": "../../.eslintrc.json", - "rules": { - "no-console": "off", - "unicorn/prefer-top-level-await": "off" - } -} \ No newline at end of file diff --git a/src/config/rollup.config.js b/src/config/rollup.config.js index ae10cef08..8e989d30d 100644 --- a/src/config/rollup.config.js +++ b/src/config/rollup.config.js @@ -16,8 +16,5 @@ module.exports = { banner, name: 'adminlte' }, - plugins: [typescript({ - declaration: true, - declarationDir: 'types' - })] + plugins: [typescript()] } diff --git a/src/html/.eslintrc.json b/src/html/.eslintrc.json new file mode 100644 index 000000000..59b930700 --- /dev/null +++ b/src/html/.eslintrc.json @@ -0,0 +1,24 @@ +{ + "root": true, + "extends": [ + "plugin:astro/recommended" + ], + "overrides": [ + { + // Define the configuration for `.astro` file. + "files": ["*.astro"], + // Allows Astro components to be parsed. + "parser": "astro-eslint-parser", + // Parse the script in `.astro` as TypeScript by adding the following configuration. + // It's the setting you need when using TypeScript. + "parserOptions": { + "parser": "@typescript-eslint/parser", + "extraFileExtensions": [".astro"] + }, + "rules": { + // override/add rules settings here, such as: + // "astro/no-set-html-directive": "error" + } + } + ] +} \ No newline at end of file diff --git a/src/html/.tsconfig.json b/src/html/.tsconfig.json index d78f81ec4..b80cd3f3e 100644 --- a/src/html/.tsconfig.json +++ b/src/html/.tsconfig.json @@ -1,3 +1,4 @@ { + "root": true, "extends": "astro/tsconfigs/base" } diff --git a/src/html/components/_scripts.astro b/src/html/components/_scripts.astro index 2273f0b5a..c768c03b0 100644 --- a/src/html/components/_scripts.astro +++ b/src/html/components/_scripts.astro @@ -1,6 +1,7 @@ --- const { path } = Astro.props const distPath = (path != undefined) ? path : '../../../dist' +const adminlteJsUrl = distPath + '/js/adminlte.js' --- @@ -14,7 +15,7 @@ const distPath = (path != undefined) ? path : '../../../dist' - +