Skip to content

Commit

Permalink
chore: update eslint rules and fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohe0601 committed Oct 8, 2024
1 parent 72161ea commit 698523f
Show file tree
Hide file tree
Showing 6 changed files with 952 additions and 736 deletions.
54 changes: 1 addition & 53 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,6 @@
import defineConfig from "@antfu/eslint-config";
import defineConfig from "@xiaohe01/eslint-config";

export default defineConfig({
type: "lib",
markdown: false
}, {
rules: {
"style/semi": ["error", "always"],
"style/indent": ["error", 2],
"style/quotes": ["error", "double", {
avoidEscape: true,
allowTemplateLiterals: true
}],
"style/eol-last": ["error", "never"],
"style/brace-style": ["error", "1tbs"],
"style/comma-dangle": ["error", "never"],
"style/arrow-parens": ["error", "always"],
"style/member-delimiter-style": ["error", {
singleline: {
delimiter: "semi",
requireLast: true
},
multiline: {
delimiter: "semi",
requireLast: true
},
multilineDetection: "brackets"
}],
"vue/block-order": ["error", {
order: ["template", "script:not([setup])", "script[setup]", "style:not([scoped])", "style[scoped]"]
}],
"vue/html-self-closing": ["error", {
html: {
void: "any",
normal: "never",
component: "never"
},
svg: "never",
math: "never"
}],
"vue/first-attribute-linebreak": ["error", {
singleline: "beside",
multiline: "beside"
}],
"vue/max-attributes-per-line": ["error", {
singleline: {
max: 3
},
multiline: 1
}],
"vue/html-closing-bracket-newline": ["error", {
singleline: "never",
multiline: "never"
}],
"vue/singleline-html-element-content-newline": ["off"],
"vue/multiline-html-element-content-newline": ["off"]
}
});
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"version": "0.0.7",
"private": true,
"packageManager": "pnpm@9.11.0",
"packageManager": "pnpm@9.12.1",
"description": "💻 a lightweight watermark plugin 一个轻量级水印插件",
"scripts": {
"prepare": "simple-git-hooks",
Expand All @@ -18,20 +18,20 @@
"test:coverage": "vitest run --coverage"
},
"devDependencies": {
"@antfu/eslint-config": "^3.7.2",
"@antfu/ni": "^0.23.0",
"@antfu/utils": "^0.7.10",
"@types/node": "^20.16.9",
"@types/node": "^20.16.11",
"@xiaohe01/eslint-config": "^0.0.5",
"@xiaohe01/tsconfig": "^0.0.2",
"bumpp": "^9.5.2",
"eslint": "^9.11.1",
"esno": "^4.7.0",
"bumpp": "^9.6.1",
"eslint": "^9.12.0",
"esno": "^4.8.0",
"lint-staged": "^15.2.10",
"simple-git-hooks": "^2.11.1",
"typescript": "~5.5.4",
"unbuild": "^2.0.0",
"vite": "^5.4.8",
"vitest": "^2.1.1"
"vitest": "^2.1.2"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NullableValue, OptionalValue, WatermarkOptions } from "./types";
import { defaultSettings } from "./config";
import type { NullableValue, OptionalValue, WatermarkOptions } from "./types";

export function combineOptions(...options: Partial<WatermarkOptions | undefined>[]): WatermarkOptions {
return Object.assign({}, defaultSettings, ...options);
Expand Down
20 changes: 11 additions & 9 deletions packages/core/src/watermark.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { NullableValue, WatermarkOptions } from "./types";
import { combineOptions, getEl } from "./helpers";
import type { NullableValue, WatermarkOptions } from "./types";

export class Watermark {

_options = combineOptions();

_manualUnmount = false;
Expand Down Expand Up @@ -148,20 +149,20 @@ export class Watermark {
/ finalRows
);

const totalWidth
= this._options.x + this._options.itemWidth * finalCols + finalXGap * (finalCols - 1);
const totalHeight
= this._options.y + this._options.itemHeight * finalRows + finalYGap * (finalRows - 1);
const totalWidth =
this._options.x + this._options.itemWidth * finalCols + finalXGap * (finalCols - 1);
const totalHeight =
this._options.y + this._options.itemHeight * finalRows + finalYGap * (finalRows - 1);

for (let i = 0; i < finalRows; i += 1) {
const y
= this._options.y
const y =
this._options.y
+ (parentHeight - totalHeight) / 2
+ (this._options.itemHeight + finalYGap) * i;

for (let j = 0; j < finalCols; j += 1) {
const x
= this._options.x
const x =
this._options.x
+ (parentWidth - totalWidth) / 2
+ (this._options.itemWidth + finalXGap) * j;

Expand Down Expand Up @@ -217,6 +218,7 @@ export class Watermark {

this._remove();
}

}

export const watermark = new Watermark();
Expand Down
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.5.8",
"vue": "^3.5.11",
"watermark-lite": "workspace:^"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 698523f

Please sign in to comment.