Skip to content

Commit

Permalink
🔋 chore: eslint commonjs globals (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdsuwwz authored Apr 16, 2024
1 parent 4976375 commit ea02c77
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 49 deletions.
70 changes: 35 additions & 35 deletions .stylelintrc.cjs
Original file line number Diff line number Diff line change
@@ -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']
}
]
}
Expand Down
37 changes: 25 additions & 12 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
// import antfu from '@antfu/eslint-config'
// export default antfu()

import { defineFlatConfig } from 'eslint-define-config';
import globals from 'globals'
import { defineFlatConfig } from 'eslint-define-config'

import * as parserTypeScript from '@typescript-eslint/parser';
import pluginTypeScript from '@typescript-eslint/eslint-plugin';
import * as parserTypeScript from '@typescript-eslint/parser'
import pluginTypeScript from '@typescript-eslint/eslint-plugin'

import * as parserVue from 'vue-eslint-parser'
import pluginVue from 'eslint-plugin-vue'
import js from '@eslint/js'

import * as parserVue from 'vue-eslint-parser';
import pluginVue from 'eslint-plugin-vue';
import js from '@eslint/js';

function renameRules(rules, map) {
return Object.fromEntries(
Object.entries(rules).map(([key, value]) => {
for (const [from, to] of Object.entries(map)) {
if (key.startsWith(`${from}/`))
return [to + key.slice(from.length), value];
return [to + key.slice(from.length), value]
}
return [key, value];
return [key, value]
})
);
)
}

export default defineFlatConfig([
Expand All @@ -31,7 +33,10 @@ export default defineFlatConfig([
globals: {
document: 'readonly',
navigator: 'readonly',
window: 'readonly'
window: 'readonly',
...globals.node,
...globals.es2021,
...globals.browser
},
parserOptions: {
ecmaFeatures: {
Expand All @@ -50,7 +55,7 @@ export default defineFlatConfig([
'constructor-super': 'error',
'default-case-last': 'error',
'dot-notation': ['error', { allowKeywords: true }],
'eqeqeq': ['error', 'smart'],
'eqeqeq': ['error', 'always'],
'new-cap': ['error', { capIsNew: false, newIsCap: true, properties: true }],
'no-alert': 'error',
'no-array-constructor': 'error',
Expand Down Expand Up @@ -160,6 +165,9 @@ export default defineFlatConfig([
'no-useless-return': 'error',
'no-var': 'error',
'no-with': 'error',
'key-spacing': 'error',
'space-infix-ops': 'error',
'object-curly-spacing': ['error', 'always'],
'object-shorthand': [
'error',
'always',
Expand Down Expand Up @@ -235,6 +243,11 @@ export default defineFlatConfig([
}
}
},
settings: {
'import/core-modules': [
'uno.css'
]
},
plugins: {
'@typescript-eslint': pluginTypeScript
},
Expand Down Expand Up @@ -321,4 +334,4 @@ export default defineFlatConfig([
}]
}
}
]);
])
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"eslint-plugin-html": "8.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-vue": "^9.24.0",
"globals": "^15.0.0",
"identity-obj-proxy": "^3.0.0",
"jsdom": "^24.0.0",
"lodash-es": "^4.17.21",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/utils/camelCase.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-unused-vars */
import {
isArray,
isBoolean,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/formRules.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable */


// import {
// regexExtraSpace
Expand Down

0 comments on commit ea02c77

Please sign in to comment.