Skip to content

Commit

Permalink
style: update prettier & format code
Browse files Browse the repository at this point in the history
  • Loading branch information
tangjinzhou committed Jun 23, 2021
1 parent fdecafb commit 33c7230
Show file tree
Hide file tree
Showing 113 changed files with 333 additions and 424 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"parser": "babel-eslint"
},
"extends": ["plugin:vue/vue3-recommended", "prettier"],
"plugins": ["markdown"],
"plugins": ["markdown", "jest"],
"overrides": [
{
"files": ["**/demo/*.md"],
Expand Down
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"trailingComma": "all",
"printWidth": 100,
"proseWrap": "never",
"arrowParens": "avoid",
"overrides": [
{
"files": ".prettierrc",
Expand Down
2 changes: 1 addition & 1 deletion antd-tools/getBabelCommonConfig.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { resolve } = require('./utils/projectHelper');

module.exports = function(modules) {
module.exports = function (modules) {
const plugins = [
[
resolve('@babel/plugin-transform-typescript'),
Expand Down
2 changes: 1 addition & 1 deletion antd-tools/getTSCommonConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs');
const assign = require('object-assign');
const { getProjectPath } = require('./utils/projectHelper');

module.exports = function() {
module.exports = function () {
let my = {};
if (fs.existsSync(getProjectPath('tsconfig.json'))) {
my = require(getProjectPath('tsconfig.json'));
Expand Down
4 changes: 2 additions & 2 deletions antd-tools/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function compileTs(stream) {
return stream
.pipe(ts(tsConfig))
.js.pipe(
through2.obj(function(file, encoding, next) {
through2.obj(function (file, encoding, next) {
// console.log(file.path, file.base);
file.path = file.path.replace(/\.[jt]sx$/, '.js');
this.push(file);
Expand Down Expand Up @@ -146,7 +146,7 @@ function compile(modules) {
const less = gulp
.src(['components/**/*.less'])
.pipe(
through2.obj(function(file, encoding, next) {
through2.obj(function (file, encoding, next) {
this.push(file.clone());
if (
file.path.match(/\/style\/index\.less$/) ||
Expand Down
5 changes: 1 addition & 4 deletions antd-tools/utils/getChangelog.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
const fs = require('fs');

module.exports = function getChangelog(file, version) {
const lines = fs
.readFileSync(file)
.toString()
.split('\n');
const lines = fs.readFileSync(file).toString().split('\n');
const changeLog = [];
const startPattern = new RegExp(`^## ${version}`);
const stopPattern = /^## /; // 前一个版本
Expand Down
8 changes: 1 addition & 7 deletions antd-tools/utils/getRunCmdEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ module.exports = function getRunCmdEnv() {
const nodeModulesBinDir = path.join(__dirname, '../../node_modules/.bin');

Object.entries(env)
.filter(
v =>
v
.slice(0, 1)
.pop()
.toLowerCase() === 'path',
)
.filter(v => v.slice(0, 1).pop().toLowerCase() === 'path')
.forEach(v => {
const key = v.slice(0, 1).pop();
env[key] = env[key] ? `${nodeModulesBinDir}:${env[key]}` : nodeModulesBinDir;
Expand Down
2 changes: 1 addition & 1 deletion antd-tools/utils/projectHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function injectRequire() {
const Module = require('module');

const oriRequire = Module.prototype.require;
Module.prototype.require = function(...args) {
Module.prototype.require = function (...args) {
const moduleName = args[0];
try {
return oriRequire.apply(this, args);
Expand Down
2 changes: 1 addition & 1 deletion components/_util/component-classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,6 @@ export class ClassList {
* @return {ClassList}
* @api public
*/
export default function(el: Element): ClassList {
export default function (el: Element): ClassList {
return new ClassList(el);
}
2 changes: 1 addition & 1 deletion components/_util/copy-to-clipboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function copy(text: string, options?: Options): boolean {
mark.style.MozUserSelect = 'text';
mark.style.msUserSelect = 'text';
mark.style.userSelect = 'text';
mark.addEventListener('copy', function(e) {
mark.addEventListener('copy', function (e) {
e.stopPropagation();
if (options.format) {
e.preventDefault();
Expand Down
6 changes: 3 additions & 3 deletions components/_util/copy-to-clipboard/toggle-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const deselectCurrent = (): (() => void) => {
const selection = document.getSelection();
if (!selection.rangeCount) {
return function() {};
return function () {};
}
let active = document.activeElement as any;

Expand All @@ -26,11 +26,11 @@ const deselectCurrent = (): (() => void) => {
}

selection.removeAllRanges();
return function() {
return function () {
selection.type === 'Caret' && selection.removeAllRanges();

if (!selection.rangeCount) {
ranges.forEach(function(range) {
ranges.forEach(function (range) {
selection.addRange(range);
});
}
Expand Down
2 changes: 1 addition & 1 deletion components/_util/dom-closest.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import matches from './dom-matches';
* @param context {Element=}
* @return {Element}
*/
export default function(element, selector, context) {
export default function (element, selector, context) {
context = context || document;
// guard against orphans
element = { parentNode: element };
Expand Down
4 changes: 2 additions & 2 deletions components/_util/getRequestAnimationFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ const availablePrefixs = ['moz', 'ms', 'webkit'];

function requestAnimationFramePolyfill() {
let lastTime = 0;
return function(callback) {
return function (callback) {
const currTime = new Date().getTime();
const timeToCall = Math.max(0, 16 - (currTime - lastTime));
const id = window.setTimeout(function() {
const id = window.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
Expand Down
2 changes: 1 addition & 1 deletion components/_util/hooks/useSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const useInjectSize = <T = SizeType>(props?: Record<any, any>): ComputedRef<T> =
? computed(() => props.size)
: inject(
sizeProvider,
computed(() => ('default' as unknown) as T),
computed(() => 'default' as unknown as T),
);
return size;
};
Expand Down
14 changes: 7 additions & 7 deletions components/_util/json2mq.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
* https://github.com/akiran/json2mq.git
*/

const camel2hyphen = function(str) {
const camel2hyphen = function (str) {
return str
.replace(/[A-Z]/g, function(match) {
.replace(/[A-Z]/g, function (match) {
return '-' + match.toLowerCase();
})
.toLowerCase();
};

const isDimension = function(feature) {
const isDimension = function (feature) {
const re = /[height|width]$/;
return re.test(feature);
};

const obj2mq = function(obj) {
const obj2mq = function (obj) {
let mq = '';
const features = Object.keys(obj);
features.forEach(function(feature, index) {
features.forEach(function (feature, index) {
let value = obj[feature];
feature = camel2hyphen(feature);
// Add px to dimension features
Expand All @@ -40,14 +40,14 @@ const obj2mq = function(obj) {
return mq;
};

export default function(query) {
export default function (query) {
let mq = '';
if (typeof query === 'string') {
return query;
}
// Handling array of media queries
if (query instanceof Array) {
query.forEach(function(q, index) {
query.forEach(function (q, index) {
mq += obj2mq(q);
if (index < query.length - 1) {
mq += ', ';
Expand Down
2 changes: 1 addition & 1 deletion components/_util/props-util/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const parseStyleText = (cssText = '', camel) => {
const res = {};
const listDelimiter = /;(?![^(]*\))/g;
const propertyDelimiter = /:(.+)/;
cssText.split(listDelimiter).forEach(function(item) {
cssText.split(listDelimiter).forEach(function (item) {
if (item) {
const tmp = item.split(propertyDelimiter);
if (tmp.length > 1) {
Expand Down
2 changes: 1 addition & 1 deletion components/_util/shallowequal.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ function shallowEqual(objA, objB, compare, compareContext) {
return true;
}

export default function(value, other, customizer, thisArg) {
export default function (value, other, customizer, thisArg) {
return shallowEqual(toRaw(value), toRaw(other), customizer, thisArg);
}
2 changes: 1 addition & 1 deletion components/_util/throttleByAnimationFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default function throttleByAnimationFrame(fn: (...args: any[]) => void) {

export function throttleByAnimationFrameDecorator() {
// eslint-disable-next-line func-names
return function(target: any, key: string, descriptor: any) {
return function (target: any, key: string, descriptor: any) {
const fn = descriptor.value;
let definingProperty = false;
return {
Expand Down
2 changes: 1 addition & 1 deletion components/_util/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export type VueNode = VNodeChild | JSX.Element;

export const withInstall = <T>(comp: T) => {
const c = comp as any;
c.install = function(app: App) {
c.install = function (app: App) {
app.component(c.displayName || c.name, comp);
};

Expand Down
6 changes: 3 additions & 3 deletions components/anchor/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ export default defineComponent({
`${prefixCls.value}-link-title-active`,
)[0];
if (linkNode) {
(inkNodeRef.value as HTMLElement).style.top = `${linkNode.offsetTop +
linkNode.clientHeight / 2 -
4.5}px`;
(inkNodeRef.value as HTMLElement).style.top = `${
linkNode.offsetTop + linkNode.clientHeight / 2 - 4.5
}px`;
}
};

Expand Down
2 changes: 1 addition & 1 deletion components/anchor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import AnchorLink, { AnchorLinkProps } from './AnchorLink';
Anchor.Link = AnchorLink;

/* istanbul ignore next */
Anchor.install = function(app: App) {
Anchor.install = function (app: App) {
app.component(Anchor.name, Anchor);
app.component(Anchor.Link.name, Anchor.Link);
return app;
Expand Down
2 changes: 1 addition & 1 deletion components/auto-complete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const AutoComplete = defineComponent({
});

/* istanbul ignore next */
AutoComplete.install = function(app: App) {
AutoComplete.install = function (app: App) {
app.component(AutoComplete.name, AutoComplete);
app.component(AutoComplete.Option.displayName, AutoComplete.Option);
app.component(AutoComplete.OptGroup.displayName, AutoComplete.OptGroup);
Expand Down
2 changes: 1 addition & 1 deletion components/avatar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export { AvatarGroupProps } from './Group';
Avatar.Group = Group;

/* istanbul ignore next */
Avatar.install = function(app: App) {
Avatar.install = function (app: App) {
app.component(Avatar.name, Avatar);
app.component(Group.name, Group);
return app;
Expand Down
8 changes: 5 additions & 3 deletions components/badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ export default defineComponent({

// ================================ Misc ================================
const numberedDisplayCount = computed(() => {
return ((props.count as number) > (props.overflowCount as number)
? `${props.overflowCount}+`
: props.count) as string | number | null;
return (
(props.count as number) > (props.overflowCount as number)
? `${props.overflowCount}+`
: props.count
) as string | number | null;
});

const hasStatus = computed(
Expand Down
2 changes: 1 addition & 1 deletion components/badge/ScrollNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default defineComponent({
count,
title,
show,
component: Tag = ('sup' as unknown) as DefineComponent,
component: Tag = 'sup' as unknown as DefineComponent,
class: className,
style,
...restProps
Expand Down
6 changes: 3 additions & 3 deletions components/badge/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { App, Plugin } from 'vue';
import Badge from './Badge';
import Ribbon from './Ribbon';
export type { BadgeProps } from './Badge'
export type { BadgeProps } from './Badge';

Badge.install = function(app: App) {
Badge.install = function (app: App) {
app.component(Badge.name, Badge);
app.component(Ribbon.name, Ribbon);
return app;
};

export {Ribbon as BadgeRibbon}
export { Ribbon as BadgeRibbon };

export default Badge as typeof Badge &
Plugin & {
Expand Down
6 changes: 3 additions & 3 deletions components/breadcrumb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import BreadcrumbItem from './BreadcrumbItem';
import BreadcrumbSeparator from './BreadcrumbSeparator';

export type { BreadcrumbProps } from './Breadcrumb';
export type { BreadcrumbItemProps } from './BreadcrumbItem';
export type { BreadcrumbSeparatorProps } from './BreadcrumbSeparator';
export type { BreadcrumbItemProps } from './BreadcrumbItem';
export type { BreadcrumbSeparatorProps } from './BreadcrumbSeparator';

Breadcrumb.Item = BreadcrumbItem;
Breadcrumb.Separator = BreadcrumbSeparator;

/* istanbul ignore next */
Breadcrumb.install = function(app: App) {
Breadcrumb.install = function (app: App) {
app.component(Breadcrumb.name, Breadcrumb);
app.component(BreadcrumbItem.name, BreadcrumbItem);
app.component(BreadcrumbSeparator.name, BreadcrumbSeparator);
Expand Down
6 changes: 3 additions & 3 deletions components/button/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { App, Plugin } from 'vue';
import Button from './button';
import ButtonGroup from './button-group';
export type {ButtonProps} from './button'
export type { ButtonProps } from './button';

Button.Group = ButtonGroup;

/* istanbul ignore next */
Button.install = function(app: App) {
Button.install = function (app: App) {
app.component(Button.name, Button);
app.component(ButtonGroup.name, ButtonGroup);
return app;
};
export {ButtonGroup}
export { ButtonGroup };
export default Button as typeof Button &
Plugin & {
readonly Group: typeof ButtonGroup;
Expand Down
6 changes: 3 additions & 3 deletions components/card/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import Card from './Card';
import Meta from './Meta';
import Grid from './Grid';

export type {CardProps} from './Card'
export type { CardProps } from './Card';

Card.Meta = Meta;
Card.Grid = Grid;

/* istanbul ignore next */
Card.install = function(app: App) {
Card.install = function (app: App) {
app.component(Card.name, Card);
app.component(Meta.name, Meta);
app.component(Grid.name, Grid);
return app;
};

export {Meta as CardMeta, Grid as CardGrid}
export { Meta as CardMeta, Grid as CardGrid };

export default Card as typeof Card &
Plugin & {
Expand Down
Loading

0 comments on commit 33c7230

Please sign in to comment.