Skip to content

Commit

Permalink
chore(projects): use eslint flat config
Browse files Browse the repository at this point in the history
  • Loading branch information
honghuangdc committed Dec 10, 2023
1 parent 0742326 commit 11adc8c
Show file tree
Hide file tree
Showing 143 changed files with 3,076 additions and 2,357 deletions.
6 changes: 0 additions & 6 deletions .eslintrc

This file was deleted.

1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
registry=https://registry.npmmirror.com/
shamefully-hoist=true
ignore-workspace-root-check=true
64 changes: 6 additions & 58 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,69 +1,17 @@
{
"cSpell.words": [
"Antd",
"antv",
"apifox",
"clsx",
"colord",
"consola",
"Destructurable",
"EDITMSG",
"espree",
"execa",
"gridicons",
"heroicons",
"HEXA",
"hexcode",
"iconify",
"INDEXEDDB",
"jiti",
"kolorist",
"Laba",
"localforage",
"LOCALSTORAGE",
"majesticons",
"MEDZ",
"nocheck",
"nprogress",
"ofetch",
"pickr",
"preflights",
"sider",
"simonwep",
"simplebar",
"tada",
"Uncapitalize",
"unocss",
"unplugin",
"VITE",
"vitepress",
"vueuse",
"WEBSQL",
"wechat"
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit",
"source.organizeImports": "never"
},
"editor.fontLigatures": true,
"eslint.experimental.useFlatConfig": true,
"editor.formatOnSave": false,
"editor.quickSuggestions": {
"strings": true
},
"editor.tabSize": 2,
"files.associations": {
"*.env.*": "dotenv",
"*.svg": "html"
},
"files.eol": "\n",
"eslint.validate": ["html", "css", "scss", "json", "jsonc"],
"i18n-ally.displayLanguage": "zh-cn",
"i18n-ally.enabledParsers": ["ts"],
"i18n-ally.enabledFrameworks": ["vue"],
"i18n-ally.editor.preferEditor": true,
"i18n-ally.keystyle": "nested",
"i18n-ally.localesPaths": ["src/locales/lang"],
"unocss.root": ["./"],
"[html][css][less][scss][sass][markdown][yaml][yml][json][jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
}
"prettier.enable": false,
"unocss.root": ["./"]
}
7 changes: 4 additions & 3 deletions build/config/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ProxyOptions } from 'vite';
import { createServiceConfig, createProxyPattern } from '../../env.config';
import { createProxyPattern, createServiceConfig } from '../../env.config';

/**
* set http proxy
* @param env - the current env
* Set http proxy
*
* @param env - The current env
*/
export function createViteProxy(env: Env.ImportMeta) {
const isEnableHttpProxy = env.VITE_HTTP_PROXY === 'Y';
Expand Down
5 changes: 2 additions & 3 deletions build/plugins/unocss.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process';
import path from 'node:path';
import unocss from '@unocss/vite';
import presetIcons from '@unocss/preset-icons';
Expand All @@ -8,9 +9,7 @@ export function setupUnocss(viteEnv: Env.ImportMeta) {

const localIconPath = path.join(process.cwd(), 'src/assets/svg-icon');

/**
* the name of the local icon collection
*/
/** The name of the local icon collection */
const collectionName = VITE_ICON_LOCAL_PREFIX.replace(`${VITE_ICON_PREFIX}-`, '');

return unocss({
Expand Down
5 changes: 2 additions & 3 deletions build/plugins/unplugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process';
import path from 'node:path';
import type { PluginOption } from 'vite';
import Icons from 'unplugin-icons/vite';
Expand All @@ -12,9 +13,7 @@ export function setupUnplugin(viteEnv: Env.ImportMeta) {

const localIconPath = path.join(process.cwd(), 'src/assets/svg-icon');

/**
* the name of the local icon collection
*/
/** The name of the local icon collection */
const collectionName = VITE_ICON_LOCAL_PREFIX.replace(`${VITE_ICON_PREFIX}-`, '');

const plugins: PluginOption[] = [
Expand Down
10 changes: 6 additions & 4 deletions env.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* create service config by current env
* @param env the current env
* Create service config by current env
*
* @param env The current env
*/
export function createServiceConfig(env: Env.ImportMeta) {
const mockURL = 'https://mock.apifox.com/m1/3109515-0-default';
Expand Down Expand Up @@ -32,8 +33,9 @@ export function createServiceConfig(env: Env.ImportMeta) {
}

/**
* get proxy pattern of service url
* @param key if not set, will use the default key
* Get proxy pattern of service url
*
* @param key If not set, will use the default key
*/
export function createProxyPattern(key?: App.Service.OtherBaseURLKey) {
if (!key) {
Expand Down
15 changes: 15 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from '@soybeanjs/eslint-config';

export default defineConfig(
{ vue: true },
{
rules: {
'vue/multi-word-component-names': [
'warn',
{
ignores: ['index', 'App', '[id]']
}
]
}
}
);
31 changes: 19 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"name": "@sa/antd",
"type": "module",
"version": "1.0.0",
"packageManager": "pnpm@8.10.5",
"description": "A fresh and elegant admin template, based on Vue3,Vite3,TypeScript,AntDesign and UnoCSS.",
"author": {
"name": "Soybean",
"email": "soybeanjs@outlook.com",
"url": "https://github.com/soybeanjs"
},
"type": "module",
"packageManager": "pnpm@8.10.5",
"scripts": {
"build": "typecheck build-only",
"build-only": "vite build",
"cleanup": "sa cleanup",
"commit": "sa git-commit",
"dev": "vite",
"build": "run-s typecheck build-only",
"lint": "eslint . --fix",
"prepare": "simple-git-hooks",
"preview": "vite preview",
"build-only": "vite build",
"release": "sa release",
"typecheck": "vue-tsc --noEmit --skipLibCheck",
"lint": "eslint . --fix",
"format": "sa prettier-write",
"commit": "sa git-commit",
"cleanup": "sa cleanup",
"update-pkg": "sa update-pkg",
"prepare": "simple-git-hooks"
"update-pkg": "sou ncu"
},
"dependencies": {
"@better-scroll/core": "2.5.1",
Expand All @@ -46,6 +46,7 @@
"@iconify/json": "2.2.143",
"@sa/scripts": "workspace:*",
"@sa/uno-preset": "workspace:*",
"@soybeanjs/eslint-config": "1.0.11",
"@types/lodash-es": "4.17.11",
"@types/node": "20.9.1",
"@types/nprogress": "0.2.3",
Expand All @@ -57,7 +58,9 @@
"@vitejs/plugin-vue": "4.5.0",
"@vitejs/plugin-vue-jsx": "3.1.0",
"cross-env": "7.0.3",
"eslint-config-sa": "workspace:*",
"eslint": "8.53.0",
"eslint-plugin-vue": "9.19.2",
"lint-staged": "15.1.0",
"npm-run-all": "4.1.5",
"sass": "1.69.5",
"simple-git-hooks": "2.9.0",
Expand All @@ -68,10 +71,14 @@
"vite-plugin-progress": "0.0.7",
"vite-plugin-svg-icons": "2.0.1",
"vite-plugin-vue-devtools": "1.0.0-rc.5",
"vue-eslint-parser": "9.3.2",
"vue-tsc": "1.8.22"
},
"simple-git-hooks": {
"commit-msg": "pnpm sa git-commit-verify",
"pre-commit": "pnpm typecheck && pnpm sa lint-staged"
"pre-commit": "pnpm typecheck && pnpm lint-staged"
},
"lint-staged": {
"*": "eslint --fix"
}
}
4 changes: 1 addition & 3 deletions packages/color-palette/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
},
"typesVersions": {
"*": {
"*": [
"./src/*"
]
"*": ["./src/*"]
}
},
"dependencies": {
Expand Down
13 changes: 6 additions & 7 deletions packages/color-palette/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { getColorPaletteFamily } from './palette';
import { getColorName } from './name';
import type { ColorPalette, ColorPaletteNumber, ColorPaletteItem, ColorPaletteFamily } from './type';
import type { ColorPalette, ColorPaletteFamily, ColorPaletteItem, ColorPaletteNumber } from './type';
import defaultPalettes from './json/palette.json';

/**
* get color palette by provided color and color name
* @param color the provided color
* @param colorName color name
* Get color palette by provided color and color name
*
* @param color The provided color
* @param colorName Color name
*/
export function getColorPalette(color: string, colorName: string) {
const colorPaletteFamily = getColorPaletteFamily(color, colorName);
Expand All @@ -32,9 +33,7 @@ export function getColorPalette(color: string, colorName: string) {

export default getColorPalette;

/**
* the builtin color palettes
*/
/** The builtin color palettes */
const colorPalettes = defaultPalettes as ColorPaletteFamily[];

export { getColorName, colorPalettes };
Expand Down
2 changes: 1 addition & 1 deletion packages/color-palette/src/name.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getHex, getRgb, getHsl } from './color';
import { getHex, getHsl, getRgb } from './color';
import colorNames from './json/color-name.json';

export function getColorName(color: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/color-palette/src/palette.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isValidColor, getHsl, getDeltaE, transformHslToHex } from './color';
import { getDeltaE, getHsl, isValidColor, transformHslToHex } from './color';
import { getColorName } from './name';
import type { ColorPaletteFamily, ColorPaletteFamilyWithNearestPalette } from './type';
import defaultPalettes from './json/palette.json';
Expand Down
40 changes: 13 additions & 27 deletions packages/color-palette/src/type.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
/**
* the color palette number
*/
/** The color palette number */
export type ColorPaletteNumber = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;

/**
* the color palette item
*/
/** The color palette item */
export type ColorPaletteItem = {
/**
* the color hexcode
*/
/** The color hexcode */
hexcode: string;
/**
* the color number
* The color number
*
* @link {@link ColorPaletteNumber}
*/
number: ColorPaletteNumber;
/**
* the color name
*/
/** The color name */
name: string;
};

export type ColorPaletteFamily = {
/**
* the color palette family key
*/
/** The color palette family key */
key: string;
/**
* the color palette family's palettes
*/
/** The color palette family's palettes */
palettes: ColorPaletteItem[];
};

Expand All @@ -47,17 +36,14 @@ export type ColorPaletteFamilyWithNearestPalette = ColorPaletteFamily & {
};

export type ColorPalette = ColorPaletteFamily & {
/**
* the color map of the palette
*/
/** The color map of the palette */
colorMap: Map<ColorPaletteNumber, ColorPaletteItem>;
/**
* the main color of the palette
* @description which number is 500
* The main color of the palette
*
* Which number is 500
*/
main: ColorPaletteItemWithName;
/**
* the match color of the palette
*/
/** The match color of the palette */
match: ColorPaletteItemWithName;
};
1 change: 1 addition & 0 deletions packages/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process';
import path from 'node:path';
import { defineConfig } from 'vitepress';

Expand Down
6 changes: 1 addition & 5 deletions packages/docs/.vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@
var(--vp-c-brand-darker)
);

--vp-home-hero-image-background-image: linear-gradient(
-45deg,
var(--vp-c-brand-lightest) 30%,
var(--vp-c-brand) 50%
);
--vp-home-hero-image-background-image: linear-gradient(-45deg, var(--vp-c-brand-lightest) 30%, var(--vp-c-brand) 50%);
--vp-home-hero-image-filter: blur(40px);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "@sa/docs",
"version": "1.0.0",
"scripts": {
"dev": "vitepress dev",
"build": "vitepress build",
"dev": "vitepress dev",
"serve": "vitepress serve"
},
"devDependencies": {
Expand Down
4 changes: 1 addition & 3 deletions packages/eslint-config/configs/base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* @type {import('eslint').ESLint.ConfigData}
*/
/** @type {import('eslint').ESLint.ConfigData} */
module.exports = {
extends: [require.resolve('./ts.js'), require.resolve('./prettier.js')]
};
Loading

0 comments on commit 11adc8c

Please sign in to comment.