Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔋 chore: eslint commonjs globals #42

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

🏄‍♂️ A Starter template built on Vite 5.x + TypeScript + Vue 3.4 + Naive UI + Pinia + UnoCSS + Unplugin Auto Import.

一个简洁的 Vite5 + Vue3.4 + TypeScript 的 B 端后台原型 Naive UI 模板框架,内置 Pinia 模块化管理代码、路由鉴权、UnoCSS 暗黑模式、Unplugin 自动导入等, 开箱即用, 注重快速高效搭建实际业务场景, 持续更新最新技术栈 💪
一个简洁的 Vite5 + Vue3.4 + TypeScript + ESLint(v9) 的 B 端后台原型 Naive UI 模板框架,内置 Pinia 模块化管理代码、路由鉴权、UnoCSS 暗黑模式、Unplugin 自动导入等, 开箱即用, 注重快速高效搭建实际业务场景, 持续更新最新技术栈 🎊

[🔥 Live Demo 在线体验](https://pdsuwwz.github.io/vite-naive-template)

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 @@ -92,6 +92,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",
"postcss": "^8.4.38",
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.

Loading