diff --git a/eslint.config.js b/eslint.config.js index c8f6d53d4..b8073b6d6 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,5 +1,35 @@ -export default [ +import { defineConfig, globalIgnores } from 'eslint/config'; +import js from '@eslint/js'; +import globals from 'globals'; + +export default defineConfig([ + globalIgnores(['assets/*', 'node_modules/*', '_site/*']), + js.configs.recommended, { - files: ['_javascript/**/*.js'] + rules: { + semi: ['error', 'always'], + quotes: ['error', 'single'] + }, + languageOptions: { + globals: { + ...globals.browser, + ...globals.node + } + } + }, + { + files: ['_javascript/**/*.js'], + languageOptions: { + globals: { + ClipboardJS: 'readonly', + GLightbox: 'readonly', + Theme: 'readonly', + dayjs: 'readonly', + mermaid: 'readonly', + tocbot: 'readonly', + importScripts: 'readonly', + swconf: 'readonly' + } + } } -]; +]); diff --git a/package.json b/package.json index ceed0287e..bb712a6b4 100644 --- a/package.json +++ b/package.json @@ -13,14 +13,16 @@ "url": "https://github.com/cotes2020/jekyll-theme-chirpy/issues" }, "homepage": "https://github.com/cotes2020/jekyll-theme-chirpy/", + "type": "module", "scripts": { "build": "concurrently npm:build:*", "build:css": "node purgecss.js", "build:js": "rollup -c --bundleConfigAsCjs --environment BUILD:production", "watch:js": "rollup -c --bundleConfigAsCjs -w", + "lint:js": "eslint", "lint:scss": "stylelint _sass/**/*.scss", "lint:fix:scss": "npm run lint:scss -- --fix", - "test": "npm run lint:scss", + "test": "npm run lint:js && npm run lint:scss", "prepare": "husky" }, "dependencies": { @@ -42,6 +44,8 @@ "@semantic-release/git": "^10.0.1", "concurrently": "^9.1.2", "conventional-changelog-conventionalcommits": "^8.0.0", + "eslint": "^9.27.0", + "globals": "^16.1.0", "husky": "^9.1.7", "purgecss": "^7.0.2", "rollup": "^4.41.0", diff --git a/purgecss.js b/purgecss.js index ad42db297..2380f6f77 100644 --- a/purgecss.js +++ b/purgecss.js @@ -1,5 +1,6 @@ -const fs = require('fs').promises; -const { PurgeCSS } = require('purgecss'); +import { promises as fs } from 'fs'; +import { PurgeCSS } from 'purgecss'; + const DIST_PATH = '_sass/vendors'; const output = `${DIST_PATH}/_bootstrap.scss`;