diff --git a/.github/workflows/gh-pages-deploy.yml b/.github/workflows/gh-pages-deploy.yml index f689d4f..3424e6e 100644 --- a/.github/workflows/gh-pages-deploy.yml +++ b/.github/workflows/gh-pages-deploy.yml @@ -6,7 +6,7 @@ on: push: branches: main # Allows you to run this workflow manually from the Actions tab on GitHub. - # eslint-disable-next-line yml/no-empty-mapping-value + # eslint-disable-next-line yml/no-empty-mapping-value -- does not accept any value workflow_dispatch: # Allow this job to clone the repo and create a page deployment diff --git a/.remarkrc.js b/.remarkrc.cjs similarity index 100% rename from .remarkrc.js rename to .remarkrc.cjs diff --git a/eslint.config.mjs b/eslint.config.mjs index d0ec744..43196fd 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -1,141 +1,151 @@ -import html from 'eslint-plugin-html'; import globals from 'globals'; -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { FlatCompat } from '@eslint/eslintrc'; -import mdxeslint from 'eslint-plugin-mdx'; -import jseslint from '@eslint/js'; -import tseslint from 'typescript-eslint'; -import eslintPluginAstro from 'eslint-plugin-astro'; -import eslintConfigPrettier from 'eslint-config-prettier'; +import pluginJs from '@eslint/js'; +import pluginTypeScript from 'typescript-eslint'; import eslintPluginYml from 'eslint-plugin-yml'; +import eslintPluginAstro from 'eslint-plugin-astro'; import eslintPluginJsonc from 'eslint-plugin-jsonc'; +import eslintPluginHtmlInlineScripts from 'eslint-plugin-html'; +import eslintConfigPrettier from 'eslint-config-prettier'; +import eslintPluginHtml from '@html-eslint/eslint-plugin'; +import eslintPluginHtmlParser from '@html-eslint/parser'; +import eslintPluginMdx from 'eslint-plugin-mdx'; +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { FlatCompat } from '@eslint/eslintrc'; + +// TODO: Change to import.meta.dirname once Node 18 is no longer supported (Node >= >=20.11.0) +const __dirname = dirname(fileURLToPath(import.meta.url)); -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); const compat = new FlatCompat({ baseDirectory: __dirname }); +/** @type {import('eslint').Linter.Config[]} */ export default [ - { - files: [ - '**/*.js', - '**/*.jsx', - '**/*.cjs', - '**/*.mjs', - '**/*.html', - '**/*.yml', - '**/*.yaml', - '**/*.md', - '**/*.mdx', - '**/*.json', - '**/*.jsonc', - '**/*.ts', - '**/*.tsx', - '**/*.astro' - ] - }, + ...[ + ...compat.extends('jquery'), + { + languageOptions: { + sourceType: 'script', + ecmaVersion: 5, + globals: { ...globals.browser, ...globals.jquery } + }, + rules: { + 'one-var': ['error', { var: 'consecutive' }], + strict: ['error', 'function'], + 'no-nested-ternary': 0, + camelcase: 0, + 'no-console': ['error', { allow: ['warn', 'error'] }] + } + } + ].map((cfg) => ({ + ignores: [ + 'site/**', + '!site/src/components/demos/**/map.{js,html}', + '**/*.{mjs,cjs}' + ], + ...cfg + })), { ignores: [ - 'tests/redist/', - 'examples/redist/', - '**/build/', - '**/dist/', - '**/node_modules/', - '!.github', - '!.vscode', - '**/package-lock.json', - '!**/.*.json', - '!**/.*.jsonc', - 'docs/', - '**/*.d.ts', - '**/.astro/' + '**/redist/**', + '**/build/**', + '**/dist/**', + '**/.astro/**', + 'docs/**' ] }, - jseslint.configs.recommended, - ...compat.extends('jquery'), - eslintConfigPrettier, - ...eslintPluginYml.configs['flat/standard'], - ...eslintPluginYml.configs['flat/prettier'], - ...eslintPluginJsonc.configs['flat/recommended-with-jsonc'], - ...eslintPluginAstro.configs.recommended, { - plugins: { - html - }, - linterOptions: { - reportUnusedDisableDirectives: true - }, + files: ['site/src/components/demos/**/map.js'], languageOptions: { - globals: { - ...globals.browser, - ...globals.jquery - }, - ecmaVersion: 5, - sourceType: 'script' - }, - settings: { - 'html/indent': '+2', - 'html/report-bad-indent': 'error' - }, - rules: { - 'one-var': ['error', { var: 'consecutive' }], - strict: ['error', 'function'], - 'no-nested-ternary': 0, - camelcase: 0, - 'no-console': ['error', { allow: ['warn', 'error'] }] + parserOptions: { + ecmaFeatures: { + // these files are directly displayed in `Scripts` tab in website so avoid having to include use strict + impliedStrict: true + } + } } }, { - ...mdxeslint.flat, - processor: mdxeslint.createRemarkProcessor({ + files: ['.remarkrc.cjs'], + languageOptions: { globals: { ...globals.node } } + }, + pluginJs.configs.recommended, + ...pluginTypeScript.config({ + files: ['site/**/*.{js,mjs,cjs,ts}'], + ignores: ['site/src/components/demos/**/map.js'], + extends: [ + pluginTypeScript.configs.strictTypeChecked, + pluginTypeScript.configs.stylisticTypeChecked + ], + languageOptions: { + parserOptions: { + project: true, + tsconfigRootDir: `${__dirname}/site` + } + } + }), + ...eslintPluginAstro.configs.recommended, + { + ...eslintPluginMdx.flat, + processor: eslintPluginMdx.createRemarkProcessor({ lintCodeBlocks: true }), rules: { - ...mdxeslint.flat.rules, + ...eslintPluginMdx.flat.rules, 'no-unused-vars': 'off' } }, - mdxeslint.flatCodeBlocks, { - files: ['**/*.mjs'], - languageOptions: { - ecmaVersion: 'latest', - sourceType: 'module' + ...eslintPluginMdx.flatCodeBlocks, + rules: { + ...eslintPluginMdx.flatCodeBlocks.rules, + 'no-var': 'off', + '@typescript-eslint/no-unused-vars': 'off', + '@typescript-eslint/no-require-imports': 'off' } }, { - files: ['.remarkrc.js'], + // Configuration for `