Use ESLint
This commit is contained in:
4
.eslintignore
Normal file
4
.eslintignore
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
dist
|
||||||
|
node_modules
|
||||||
|
.github
|
||||||
|
.vscode
|
39
.eslintrc.js
Normal file
39
.eslintrc.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
module.exports = {
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
es2022: true,
|
||||||
|
browser: true,
|
||||||
|
},
|
||||||
|
extends: ['eslint:recommended', 'plugin:astro/recommended'],
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 'latest',
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
rules: {},
|
||||||
|
overrides: [
|
||||||
|
{
|
||||||
|
files: ['*.astro'],
|
||||||
|
parser: 'astro-eslint-parser',
|
||||||
|
parserOptions: {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
extraFileExtensions: ['.astro'],
|
||||||
|
},
|
||||||
|
rules: {},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ['*.ts'],
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
extends: ['plugin:@typescript-eslint/recommended'],
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_' }],
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Define the configuration for `<script>` tag.
|
||||||
|
// Script in `<script>` is assigned a virtual file name with the `.js` extension.
|
||||||
|
files: ['**/*.astro/*.js', '*.astro/*.js'],
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
2
.vscode/extensions.json
vendored
2
.vscode/extensions.json
vendored
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"recommendations": ["astro-build.astro-vscode", "bradlc.vscode-tailwindcss"],
|
"recommendations": ["astro-build.astro-vscode", "bradlc.vscode-tailwindcss", "dbaeumer.vscode-eslint"],
|
||||||
"unwantedRecommendations": []
|
"unwantedRecommendations": []
|
||||||
}
|
}
|
||||||
|
9
.vscode/settings.json
vendored
Normal file
9
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"eslint.validate": [
|
||||||
|
"javascript",
|
||||||
|
"javascriptreact",
|
||||||
|
"astro", // Enable .astro
|
||||||
|
"typescript", // Enable .ts
|
||||||
|
"typescriptreact" // Enable .tsx
|
||||||
|
]
|
||||||
|
}
|
@ -7,6 +7,7 @@
|
|||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
"start": "astro dev",
|
"start": "astro dev",
|
||||||
"build": "astro build",
|
"build": "astro build",
|
||||||
|
"lint:eslint": "eslint . --ext .js,.ts,.astro",
|
||||||
"subfont": "subfont -ir --no-fallbacks --silent --root dist",
|
"subfont": "subfont -ir --no-fallbacks --silent --root dist",
|
||||||
"preview": "astro preview"
|
"preview": "astro preview"
|
||||||
},
|
},
|
||||||
@ -18,8 +19,13 @@
|
|||||||
"@astrojs/tailwind": "^1.0.0",
|
"@astrojs/tailwind": "^1.0.0",
|
||||||
"@fontsource/inter": "^4.5.12",
|
"@fontsource/inter": "^4.5.12",
|
||||||
"@tailwindcss/typography": "^0.5.4",
|
"@tailwindcss/typography": "^0.5.4",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.36.2",
|
||||||
|
"@typescript-eslint/parser": "^5.36.2",
|
||||||
"astro": "^1.2.1",
|
"astro": "^1.2.1",
|
||||||
"astro-icon": "^0.7.3",
|
"astro-icon": "^0.7.3",
|
||||||
|
"eslint": "^8.23.0",
|
||||||
|
"eslint-plugin-astro": "^0.19.0",
|
||||||
|
"eslint-plugin-jsx-a11y": "^6.6.1",
|
||||||
"limax": "^v2.1.0",
|
"limax": "^v2.1.0",
|
||||||
"reading-time": "^1.5.0",
|
"reading-time": "^1.5.0",
|
||||||
"subfont": "^6.9.0"
|
"subfont": "^6.9.0"
|
||||||
|
@ -5,8 +5,6 @@ import { findPostsByIds } from "~/utils/posts";
|
|||||||
import { findImage } from "~/utils/images";
|
import { findImage } from "~/utils/images";
|
||||||
import { getPermalink } from "~/utils/permalinks";
|
import { getPermalink } from "~/utils/permalinks";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
|
|
||||||
const ids = [
|
const ids = [
|
||||||
"get-started-website-with-astro-tailwind-css",
|
"get-started-website-with-astro-tailwind-css",
|
||||||
"how-to-customize-astrowind-to-your-brand",
|
"how-to-customize-astrowind-to-your-brand",
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<script is:inline>
|
<script is:inline>
|
||||||
@ -33,7 +32,7 @@ const {} = Astro.props;
|
|||||||
document.getElementById("menu")?.classList.toggle("hidden");
|
document.getElementById("menu")?.classList.toggle("hidden");
|
||||||
});
|
});
|
||||||
|
|
||||||
attachEvent("[data-aw-toggle-color-scheme]", "click", function (elem) {
|
attachEvent("[data-aw-toggle-color-scheme]", "click", function () {
|
||||||
document.documentElement.classList.toggle("dark");
|
document.documentElement.classList.toggle("dark");
|
||||||
localStorage.theme = document.documentElement.classList.contains("dark") ? "dark" : "light";
|
localStorage.theme = document.documentElement.classList.contains("dark") ? "dark" : "light";
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@ const attrs = partytown ? { type: "text/partytown" } : {};
|
|||||||
<script is:inline define:vars={{ id }} {...attrs}>
|
<script is:inline define:vars={{ id }} {...attrs}>
|
||||||
window.dataLayer = window.dataLayer || [];
|
window.dataLayer = window.dataLayer || [];
|
||||||
function gtag() {
|
function gtag() {
|
||||||
dataLayer.push(arguments);
|
window.dataLayer.push(arguments);
|
||||||
}
|
}
|
||||||
gtag("js", new Date());
|
gtag("js", new Date());
|
||||||
gtag("config", id);
|
gtag("config", id);
|
||||||
|
@ -24,6 +24,7 @@ try {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
// continue regardless of error
|
||||||
}
|
}
|
||||||
|
|
||||||
const { image = {}, sources = [] } = picture || {}
|
const { image = {}, sources = [] } = picture || {}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from "astro-icon";
|
import { Icon } from "astro-icon";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<section class="relative">
|
<section class="relative">
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
import { getHomePermalink } from "~/utils/permalinks";
|
import { getHomePermalink } from "~/utils/permalinks";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<section class="flex items-center h-full p-16">
|
<section class="flex items-center h-full p-16">
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from "astro-icon";
|
import { Icon } from "astro-icon";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from "astro-icon";
|
import { Icon } from "astro-icon";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
title: "Headers",
|
title: "Headers",
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
---
|
---
|
||||||
const {} = Astro.props;
|
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from "astro-icon";
|
import { Icon } from "astro-icon";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from "astro-icon";
|
import { Icon } from "astro-icon";
|
||||||
|
|
||||||
import { getHomePermalink } from "~/utils/permalinks";
|
import { getHomePermalink } from "~/utils/permalinks";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
|
@ -5,8 +5,6 @@ import ToggleTheme from "~/components/core/ToggleTheme.astro";
|
|||||||
import ToggleMenu from "~/components/core/ToggleMenu.astro";
|
import ToggleMenu from "~/components/core/ToggleMenu.astro";
|
||||||
|
|
||||||
import { getPermalink, getBlogPermalink, getHomePermalink } from "~/utils/permalinks";
|
import { getPermalink, getBlogPermalink, getHomePermalink } from "~/utils/permalinks";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<header
|
<header
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from "astro-icon";
|
import { Icon } from "astro-icon";
|
||||||
import Picture from "~/components/core/Picture.astro";
|
import Picture from "~/components/core/Picture.astro";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<div class="px-4 py-8 md:py-16 sm:px-6 mx-auto md:px-24 lg:px-8 lg:py-20 max-w-6xl">
|
<div class="px-4 py-8 md:py-16 sm:px-6 mx-auto md:px-24 lg:px-8 lg:py-20 max-w-6xl">
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from "astro-icon";
|
import { Icon } from "astro-icon";
|
||||||
import Picture from "~/components/core/Picture.astro";
|
import Picture from "~/components/core/Picture.astro";
|
||||||
|
|
||||||
const {} = Astro.props;
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<section class="px-4 py-16 sm:px-6 mx-auto lg:px-8 lg:py-20 max-w-6xl">
|
<section class="px-4 py-16 sm:px-6 mx-auto lg:px-8 lg:py-20 max-w-6xl">
|
||||||
|
@ -2,7 +2,9 @@ const load = async function () {
|
|||||||
let images = [];
|
let images = [];
|
||||||
try {
|
try {
|
||||||
images = import.meta.glob("~/assets/images/**");
|
images = import.meta.glob("~/assets/images/**");
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
// continue regardless of error
|
||||||
|
}
|
||||||
return images;
|
return images;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user