From 2ea2815c1159aaa26dc335ac0c57954d582e7fba Mon Sep 17 00:00:00 2001 From: Wisdom Date: Tue, 16 Apr 2024 15:48:11 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8B=20chore:=20eslint=20commonjs=20glo?= =?UTF-8?q?bals=20(#338)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .stylelintrc.cjs | 70 ++++++++++++++++++++++++------------------------ eslint.config.js | 6 ++++- package.json | 1 + pnpm-lock.yaml | 8 ++++++ 4 files changed, 49 insertions(+), 36 deletions(-) diff --git a/.stylelintrc.cjs b/.stylelintrc.cjs index 36b7b18f..4501ba19 100644 --- a/.stylelintrc.cjs +++ b/.stylelintrc.cjs @@ -1,63 +1,63 @@ module.exports = { - "extends": [ - "stylelint-config-standard", - "stylelint-config-standard-scss", - "stylelint-config-recommended-vue", - "stylelint-config-recommended-vue/scss" + 'extends': [ + 'stylelint-config-standard', + 'stylelint-config-standard-scss', + 'stylelint-config-recommended-vue', + 'stylelint-config-recommended-vue/scss' ], - "ignoreFiles": ["**/*.js", "**/*.ts"], - "defaultSeverity": "error", - "rules": { - "unit-disallowed-list": [ - "rem", - "pt" + 'ignoreFiles': ['**/*.js', '**/*.ts'], + 'defaultSeverity': 'error', + 'rules': { + 'unit-disallowed-list': [ + 'rem', + 'pt' ], - "no-empty-source": null, - "block-no-empty": null, + 'no-empty-source': null, + 'block-no-empty': null, 'declaration-block-no-duplicate-custom-properties': null, - "font-family-no-missing-generic-family-keyword": null, + 'font-family-no-missing-generic-family-keyword': null, - "selector-class-pattern": "^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$|^Mui.*$|^([a-z][a-z0-9]*)(_[a-z0-9]+)*$", + 'selector-class-pattern': '^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$|^Mui.*$|^([a-z][a-z0-9]*)(_[a-z0-9]+)*$', - "scss/at-mixin-pattern": "^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$|^Mui.*$|^([a-z][a-z0-9]*)(_[a-z0-9]+)*$", - "scss/double-slash-comment-whitespace-inside": "always", - "scss/dollar-variable-pattern": null, + 'scss/at-mixin-pattern': '^[a-z]([a-z0-9-]+)?(__([a-z0-9]+-?)+)?(__([a-z0-9]+-?)+)?(--([a-z0-9]+-?)+){0,2}$|^Mui.*$|^([a-z][a-z0-9]*)(_[a-z0-9]+)*$', + 'scss/double-slash-comment-whitespace-inside': 'always', + 'scss/dollar-variable-pattern': null, - "selector-pseudo-class-no-unknown": [ + 'selector-pseudo-class-no-unknown': [ true, { - "ignorePseudoClasses": [ - "export", - "deep" + 'ignorePseudoClasses': [ + 'export', + 'deep' ] } ], - "property-no-unknown": null, - "at-rule-empty-line-before": [ - "always", + 'property-no-unknown': null, + 'at-rule-empty-line-before': [ + 'always', { - "except": ["first-nested", "blockless-after-same-name-blockless"] + 'except': ['first-nested', 'blockless-after-same-name-blockless'] } ], - "custom-property-empty-line-before": [ - "always", + 'custom-property-empty-line-before': [ + 'always', { - "except": ["after-custom-property", "first-nested"] + 'except': ['after-custom-property', 'first-nested'] } ], - "declaration-empty-line-before": [ - "always", + 'declaration-empty-line-before': [ + 'always', { - "except": ["after-declaration", "first-nested"] + 'except': ['after-declaration', 'first-nested'] } ], - "rule-empty-line-before": ["always-multi-line"], + 'rule-empty-line-before': ['always-multi-line'], // 忽视 -webkit-xxxx 等兼容写法 - "property-no-vendor-prefix": [ + 'property-no-vendor-prefix': [ true, { - ignoreProperties: ["box-shadow"] + ignoreProperties: ['box-shadow'] } ] } diff --git a/eslint.config.js b/eslint.config.js index 2da1af4f..867f7b71 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,6 +1,7 @@ // import antfu from '@antfu/eslint-config' // export default antfu() +import globals from 'globals' import { defineFlatConfig } from 'eslint-define-config'; import * as parserTypeScript from '@typescript-eslint/parser'; @@ -31,7 +32,10 @@ export default defineFlatConfig([ globals: { document: 'readonly', navigator: 'readonly', - window: 'readonly' + window: 'readonly', + ...globals.node, + ...globals.es2021, + ...globals.browser }, parserOptions: { ecmaFeatures: { diff --git a/package.json b/package.json index 2d3aedcd..bc9d7af6 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "eslint-plugin-html": "8.0.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-vue": "9.24.0", + "globals": "^15.0.0", "jsdom": "^24.0.0", "postcss": "^8.4.38", "postcss-html": "^1.6.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ce93ee3b..c2cd60b1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -103,6 +103,9 @@ devDependencies: eslint-plugin-vue: specifier: 9.24.0 version: 9.24.0(eslint@9.0.0) + globals: + specifier: ^15.0.0 + version: 15.0.0 jsdom: specifier: ^24.0.0 version: 24.0.0 @@ -3978,6 +3981,11 @@ packages: engines: {node: '>=18'} dev: true + /globals@15.0.0: + resolution: {integrity: sha512-m/C/yR4mjO6pXDTm9/R/SpYTAIyaUB4EOzcaaMEl7mds7Mshct9GfejiJNQGjHHbdMPey13Kpu4TMbYi9ex1pw==} + engines: {node: '>=18'} + dev: true + /globalthis@1.0.3: resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} engines: {node: '>= 0.4'}