Skip to content

Commit

Permalink
fix: prettier quit unexpectedly and lint code (#1676)
Browse files Browse the repository at this point in the history
* fix: `prettier` quit unexpectedly and lint code

chore: suppress deprecation notice of tsconfig `suppressImplicitAnyIndexErrors`

* chore: 忽略 `helper/**` 文件
  • Loading branch information
RSS1102 authored Dec 11, 2024
1 parent eaaef59 commit 8375507
Show file tree
Hide file tree
Showing 28 changed files with 252 additions and 217 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ yarn-error.log
vitest.config.js

test

helper/**
2 changes: 1 addition & 1 deletion .github/workflows/issue-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: ${{ steps.template.outputs.result }}
update-mode: 'append'
update-mode: 'append'
2 changes: 1 addition & 1 deletion .github/workflows/pr-comment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ jobs:
git commit -m "chore: update snapshot"
fi
git status
- name: git push
run: |
git status
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
helper/**
2 changes: 1 addition & 1 deletion helper/attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3894,4 +3894,4 @@
"type": "Number",
"description": "水印元素的 `z-index`,默认值写在 CSS 中\n\n[docs](https://tdesign.tencent.com/mobile-vue/components/watermark?tab=api#watermark-props)"
}
}
}
2 changes: 1 addition & 1 deletion helper/tags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1307,4 +1307,4 @@
],
"description": "Watermark\n\n水印\n\n[docs](https://tdesign.tencent.com/mobile-vue/components/watermark)"
}
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"lint:tsc": "vue-tsc --emitDeclarationOnly",
"lint:fix": "npm run lint:fix-prettier && npm run lint:fix-eslint",
"lint:fix-eslint": "eslint --ext .vue,.ts,.tsx ./ --max-warnings 0 --ignore-path .gitignore --ignore-path .eslintignore --fix",
"lint:fix-prettier": "prettier ./ --ignore-path .gitignore --ignore-path .eslintignore --write './*.{vue,ts,tsx}' --ignore-unknown",
"lint:fix-prettier": "prettier ./ --ignore-path .gitignore --ignore-path .eslintignore --ignore-path .prettierignore --write './*.{vue,ts,tsx}' --ignore-unknown",
"lint:vue": "vue-tsc --noEmit -p tsconfig.build.json",
"generate:coverage-badge": "npm run test:unit-coverage && node scripts/test/generate-coverage.js",
"update:css": "node scripts/generate-css-vars.js",
Expand Down Expand Up @@ -142,9 +142,9 @@
"esbuild": "^0.14.3",
"eslint": "^8.4.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vue": "^8.2.0",
"gray-matter": "^4.0.3",
"husky": "^6.0.0",
Expand All @@ -153,7 +153,7 @@
"lint-staged": "^10.5.4",
"mockdate": "^3.0.5",
"postcss": "^8.2.1",
"prettier": "^2.5.1",
"prettier": "^3.4.2",
"prismjs": "^1.23.0",
"qrcode.vue": "^3.2.2",
"regenerator-runtime": "^0.13.9",
Expand Down
16 changes: 8 additions & 8 deletions src/date-time-picker/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe('DateTimePicker', () => {
defaultValue: defaultDateTime,
title: 'mode 测试',
mode: ['date', 'second'],
onPick
onPick,
},
});
// mode = ['date', 'second'], 渲染年月日时分秒,6列
Expand All @@ -136,11 +136,11 @@ describe('DateTimePicker', () => {
value: '10:00:00',
mode: [null, 'second'],
format: 'HH:mm:ss',
start: '2023-06-13'
start: '2023-06-13',
},
});
expect(wrapper.vm.value).toStrictEqual('10:00:00')
})
expect(wrapper.vm.value).toStrictEqual('10:00:00');
});

it(': start && end ', async () => {
const start = '2020-6-30 10:00:00';
Expand All @@ -153,7 +153,7 @@ describe('DateTimePicker', () => {
value: start,
start,
end,
mode: 'second'
mode: 'second',
},
});
const $pickerItems = wrapper.findAllComponents(PickerItem);
Expand All @@ -164,12 +164,12 @@ describe('DateTimePicker', () => {
expect(res[precisionRankRecord[0]].length).toEqual(endYear - startYear + 1);

// 设置到最后一天
await wrapper.setProps({ value: end })
await wrapper.setProps({ value: end });

$pickerItems.forEach((item, index) => {
const { length } = item.findAll(`.${prefix}-picker-item__item`);
const counter = [6, 10, 10, 11, 11, 11]
expect(length).toBe(counter[index])
const counter = [6, 10, 10, 11, 11, 11];
expect(length).toBe(counter[index]);
});
});

Expand Down
10 changes: 2 additions & 8 deletions src/dropdown-menu/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ options.push({

describe('dropdown-menu', () => {
describe('props', () => {

it(': button', async () => {
// 底部 button 仅在 multiple/optionsLayout === 'tree'时,有效
const value1 = ref(['option_1']);
Expand Down Expand Up @@ -143,7 +142,6 @@ describe('dropdown-menu', () => {
const value1 = ref('option_2');
const value2 = ref('option_2');


const options2 = emptyArr.map((_, i) => ({
name: `选项${chineseMap[i]}`,
val: `option_${i}`,
Expand Down Expand Up @@ -236,11 +234,7 @@ describe('dropdown-menu', () => {
item.trigger('click', { item, index });
});
await sleep(200);
expect(
wrapper
.find(`.${prefix}-dropdown-item__content`)
.attributes('class')
).toBeTruthy();
expect(wrapper.find(`.${prefix}-dropdown-item__content`).attributes('class')).toBeTruthy();
});

it(': onChange', async () => {
Expand Down Expand Up @@ -347,4 +341,4 @@ describe('dropdown-menu', () => {
expect(onConfirm).toHaveBeenCalledTimes(1);
});
});
});
});
2 changes: 1 addition & 1 deletion src/fab/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ export default {
draggable: {
type: Boolean,
default: false,
}
},
};
4 changes: 2 additions & 2 deletions src/grid/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ describe('grid-item', () => {
</Grid>
);
});
if (l) {
expect(wrapper.find('.t-grid-item').classes()).toContain(`t-grid-item--${l}`);
if (l) {
expect(wrapper.find('.t-grid-item').classes()).toContain(`t-grid-item--${l}`);
}
});
});
Expand Down
33 changes: 21 additions & 12 deletions src/input/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('Input.vue', async () => {
});

it(': type=password and disabled', async () => {
const wrapper = mount(<Input label="标题" type="password" disabled/>);
const wrapper = mount(<Input label="标题" type="password" disabled />);
expect(wrapper.find('.t-icon-browse-off').exists()).toBeTruthy();
wrapper.find('.t-icon-browse-off').trigger('click');
await wrapper.vm.$nextTick();
Expand All @@ -163,7 +163,7 @@ describe('Input.vue', async () => {

it(': autofocus', async () => {
const value = ref('123');
const wrapper = mount(<Input label="标题" v-model={value.value} clearable clearTrigger="focus" autofocus/>);
const wrapper = mount(<Input label="标题" v-model={value.value} clearable clearTrigger="focus" autofocus />);
await wrapper.vm.$nextTick();
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeTruthy();
wrapper.vm.blur();
Expand All @@ -172,13 +172,14 @@ describe('Input.vue', async () => {
wrapper.vm.focus();
await wrapper.vm.$nextTick();
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeTruthy();

});

it(': clearTrigger=always', async () => {
const value = ref('123');
const handleClear = vi.fn();
const wrapper = mount(<Input label="标题" v-model={value.value} clearable clearTrigger="always" onClear={handleClear} />);
const wrapper = mount(
<Input label="标题" v-model={value.value} clearable clearTrigger="always" onClear={handleClear} />,
);
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeTruthy();
await wrapper.find('.t-icon-close-circle-filled').trigger('touchend');
expect(value.value).toBe('');
Expand All @@ -188,7 +189,9 @@ describe('Input.vue', async () => {
it(': clearTrigger=always and disabled', async () => {
const value = ref('123');
const handleClear = vi.fn();
const wrapper = mount(<Input label="标题" v-model={value.value} disabled clearable clearTrigger="always" onClear={handleClear} />);
const wrapper = mount(
<Input label="标题" v-model={value.value} disabled clearable clearTrigger="always" onClear={handleClear} />,
);
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeFalsy();
await wrapper.setProps({
disabled: false,
Expand All @@ -199,7 +202,9 @@ describe('Input.vue', async () => {
it(': clearTrigger=always and readonly', async () => {
const value = ref('123');
const handleClear = vi.fn();
const wrapper = mount(<Input label="标题" v-model={value.value} readonly clearable clearTrigger="always" onClear={handleClear} />);
const wrapper = mount(
<Input label="标题" v-model={value.value} readonly clearable clearTrigger="always" onClear={handleClear} />,
);
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeFalsy();
await wrapper.setProps({
readonly: false,
Expand All @@ -210,12 +215,14 @@ describe('Input.vue', async () => {
it(': clearTrigger=focus', async () => {
const value = ref('123');
const handleClear = vi.fn();
const wrapper = mount(<Input label="标题" v-model={value.value} clearable clearTrigger="focus" onClear={handleClear} />);
const wrapper = mount(
<Input label="标题" v-model={value.value} clearable clearTrigger="focus" onClear={handleClear} />,
);
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeFalsy();
wrapper.vm.focus();
await wrapper.vm.$nextTick();
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeTruthy();

await wrapper.find('.t-icon-close-circle-filled').trigger('touchend');
expect(value.value).toBe('');
expect(handleClear).toBeCalled();
Expand All @@ -224,7 +231,9 @@ describe('Input.vue', async () => {
it(': clearTrigger=focus and disabled', async () => {
const value = ref('123');
const handleClear = vi.fn();
const wrapper = mount(<Input label="标题" v-model={value.value} disabled clearable clearTrigger="focus" onClear={handleClear} />);
const wrapper = mount(
<Input label="标题" v-model={value.value} disabled clearable clearTrigger="focus" onClear={handleClear} />,
);
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeFalsy();
wrapper.vm.focus();
await wrapper.vm.$nextTick();
Expand All @@ -240,7 +249,9 @@ describe('Input.vue', async () => {
it(': clearTrigger=focus and readonly', async () => {
const value = ref('123');
const handleClear = vi.fn();
const wrapper = mount(<Input label="标题" v-model={value.value} readonly clearable clearTrigger="focus" onClear={handleClear} />);
const wrapper = mount(
<Input label="标题" v-model={value.value} readonly clearable clearTrigger="focus" onClear={handleClear} />,
);
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeFalsy();
wrapper.vm.focus();
await wrapper.vm.$nextTick();
Expand All @@ -252,8 +263,6 @@ describe('Input.vue', async () => {
await wrapper.vm.$nextTick();
expect(wrapper.find('.t-icon-close-circle-filled').exists()).toBeTruthy();
});


});
describe('event', async () => {
it(': focus && blur', async () => {
Expand Down
1 change: 0 additions & 1 deletion src/layout/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ describe('col', () => {
});
});
});

4 changes: 2 additions & 2 deletions src/link/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ describe('Link', () => {
expect(wrapper.find('.t-link--content')).toBeTruthy();
});
it('prefixIcon', () => {
const wrapper = mount(() => <Link prefixIcon={<Icon />}>text</Link>)
expect(wrapper.findComponent(Icon)).toBeTruthy()
const wrapper = mount(() => <Link prefixIcon={<Icon />}>text</Link>);
expect(wrapper.findComponent(Icon)).toBeTruthy();
});
});

Expand Down
1 change: 0 additions & 1 deletion src/loading/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const sleep = (duration) =>
}, duration),
);


describe('Loading.vue', () => {
describe('props', () => {
it(':delay', () => {
Expand Down
18 changes: 9 additions & 9 deletions src/navbar/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ describe('navbar', () => {
describe('props', () => {
it('fixed', async () => {
const navbar = mount(<NavBar title="标题" />);
expect(navbar.element.style.position).toBe('fixed')
expect(navbar.element.style.position).toBe('fixed');

await navbar.setProps({ fixed: false });
expect(navbar.element.style.position).toBe('relative')
expect(navbar.element.style.position).toBe('relative');
});

it('leftArrow', () => {
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('navbar', () => {
const wrapper = mount(<NavBar title="标题" onLeftClick={fn} />, {
// 插槽名称必须要和组件内部保持一致'left'
slots: {
'left': iconFunc,
left: iconFunc,
},
});
expect(wrapper.element).toMatchSnapshot();
Expand All @@ -69,7 +69,7 @@ describe('navbar', () => {
const wrapper = mount(<NavBar title="标题" onRightClick={fn} />, {
// 插槽名称必须要和组件内部保持一致'right'
slots: {
'right': iconFunc,
right: iconFunc,
},
});
expect(wrapper.element).toMatchSnapshot();
Expand Down Expand Up @@ -107,10 +107,10 @@ describe('navbar', () => {

describe('slots', () => {
it('left', () => {
const slot = <div className='left-content'>左侧内容</div>;
const slot = <div className="left-content">左侧内容</div>;
const navbar = mount(<NavBar title="标题" />, {
slots: {
'left': slot,
left: slot,
},
});
expect(navbar.find('.t-navbar__left').find('.left-content').exists()).toBeTruthy();
Expand All @@ -119,17 +119,17 @@ describe('navbar', () => {
it('capsule', () => {
const navbar = mount(<NavBar title="标题" />, {
slots: {
'capsule': iconFunc,
capsule: iconFunc,
},
});
expect(navbar.find('.t-navbar__capsule').exists()).toBeTruthy();
});

it('right', () => {
const slot = <div className='right-content'>右侧内容</div>;
const slot = <div className="right-content">右侧内容</div>;
const navbar = mount(<NavBar title="标题" />, {
slots: {
'right': slot,
right: slot,
},
});
expect(navbar.find('.t-navbar__right').find('.right-content').exists()).toBeTruthy();
Expand Down
13 changes: 10 additions & 3 deletions src/notice-bar/__test__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('NoticeBar', async () => {
await nextTick();
// expect(wrapper3.vm.scroll.marquee).toBe(false);


params.loop = 3;
const wrapper4 = mount(<NoticeBar visible marquee={params} />);
await nextTick();
Expand Down Expand Up @@ -97,7 +96,7 @@ describe('NoticeBar', async () => {

it('direction', async () => {
const content = ['君不见', '高堂明镜悲白发', '朝如青丝暮成雪', '人生得意须尽欢', '莫使金樽空对月'];
const wrapper = mount(<NoticeBar visible marquee direction='vertical' content={content} />);
const wrapper = mount(<NoticeBar visible marquee direction="vertical" content={content} />);
await nextTick();
expect(wrapper.find('.t-notice-bar__content--vertical').exists()).toBe(true);
});
Expand Down Expand Up @@ -156,7 +155,15 @@ describe('NoticeBar', async () => {
triggerName = name;
});
const wrapper = mount(
<NoticeBar visible prefix-icon="pre" content="test" extra="extra" suffix-icon="suffix" operation="operation" onClick={fn} />,
<NoticeBar
visible
prefix-icon="pre"
content="test"
extra="extra"
suffix-icon="suffix"
operation="operation"
onClick={fn}
/>,
);
await wrapper.find('.t-notice-bar__prefix-icon').trigger('click');
expect(triggerName).toBe('prefix-icon');
Expand Down
Loading

0 comments on commit 8375507

Please sign in to comment.