chore: turn on unicorn/prefer-includes (#55169)

This commit is contained in:
thinkasany
2025-09-28 11:55:43 +08:00
committed by GitHub
parent 5db1e6f449
commit 87601689fa
11 changed files with 10 additions and 16 deletions

View File

@@ -41,7 +41,7 @@ const remarkAnchor = (opt: Options = {}): UnifiedTransformer<any> => {
const ids = new Set();
unistUtilVisit.visit(tree, 'heading', (node) => {
if (toArr(realOpt.level).indexOf(node.depth) === -1) {
if (!toArr(realOpt.level).includes(node.depth)) {
return unistUtilVisit.CONTINUE;
}

View File

@@ -73,10 +73,7 @@ const DocLayout: React.FC = () => {
}, [location]);
const content = React.useMemo<React.ReactNode>(() => {
if (
['', '/'].some((path) => path === pathname) ||
['/index'].some((path) => pathname.startsWith(path))
) {
if (['', '/'].includes(pathname) || ['/index'].some((path) => pathname.startsWith(path))) {
return (
<IndexLayout title={locale.title} desc={locale.description}>
{outlet}

View File

@@ -58,7 +58,7 @@ const Contributors: React.FC<ContributorsProps> = ({ filename }) => {
owner="ant-design"
fileName={filename}
className={styles.list}
filter={(item) => !blockList.some((name) => name === item?.username?.toLowerCase())}
filter={(item) => !blockList.includes(item?.username?.toLowerCase() ?? '')}
renderItem={(item, loading) => (
<ContributorAvatar item={item} loading={loading} key={item?.url} />
)}

View File

@@ -13,7 +13,7 @@ const App: React.FC = () => (
options={options}
placeholder="try to type `b`"
filterOption={(inputValue, option) =>
option!.value.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1
option!.value.toUpperCase().includes(inputValue.toUpperCase())
}
/>
);

View File

@@ -56,9 +56,7 @@ const onChange: CascaderProps<Option>['onChange'] = (value, selectedOptions) =>
};
const filter = (inputValue: string, path: DefaultOptionType[]) =>
path.some(
(option) => (option.label as string).toLowerCase().indexOf(inputValue.toLowerCase()) > -1,
);
path.some((option) => (option.label as string).toLowerCase().includes(inputValue.toLowerCase()));
const App: React.FC = () => (
<Cascader

View File

@@ -84,7 +84,7 @@ const App: React.FC = () => {
const [stateOpenKeys, setStateOpenKeys] = useState(['2', '23']);
const onOpenChange: MenuProps['onOpenChange'] = (openKeys) => {
const currentOpenKey = openKeys.find((key) => stateOpenKeys.indexOf(key) === -1);
const currentOpenKey = openKeys.find((key) => !stateOpenKeys.includes(key));
// open
if (currentOpenKey !== undefined) {
const repeatIndex = openKeys

View File

@@ -32,7 +32,7 @@ const App: React.FC = () => {
};
const handleInputConfirm = () => {
if (inputValue && tags.indexOf(inputValue) === -1) {
if (inputValue && !tags.includes(inputValue)) {
setTags([...tags, inputValue]);
}
setInputVisible(false);

View File

@@ -189,7 +189,7 @@ const App: React.FC = () => {
showSearch={showSearch}
onChange={secondOnChange}
filterOption={(inputValue, item) =>
item.title!.indexOf(inputValue) !== -1 || item.tag.indexOf(inputValue) !== -1
item.title!.includes(inputValue) || item.tag.includes(inputValue)
}
leftColumns={leftTableColumns}
rightColumns={rightTableColumns}

View File

@@ -37,7 +37,7 @@ const App: React.FC = () => {
}, []);
const filterOption = (inputValue: string, option: RecordType) =>
option.description.indexOf(inputValue) > -1;
option.description.includes(inputValue);
const handleChange: TransferProps['onChange'] = (newTargetKeys) => {
setTargetKeys(newTargetKeys);

View File

@@ -74,7 +74,7 @@ const App: React.FC = () => {
const { value } = e.target;
const newExpandedKeys = dataList
.map((item) => {
if (item.title.indexOf(value) > -1) {
if (item.title.includes(value)) {
return getParentKey(item.key, defaultData);
}
return null;

View File

@@ -35,7 +35,6 @@ export default antfu(
'ts/consistent-type-definitions': 'off',
'ts/no-non-null-asserted-optional-chain': 'off',
'unicorn/prefer-node-protocol': 'off',
'unicorn/prefer-includes': 'off', // TODO: remove this
'unicorn/prefer-string-starts-ends-with': 'off', // TODO: remove this
'regexp/no-unused-capturing-group': 'off',
'regexp/no-misleading-capturing-group': 'off',