mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-08 18:39:20 +08:00
chore: turn on unicorn/prefer-includes (#55169)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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} />
|
||||
)}
|
||||
|
||||
@@ -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())
|
||||
}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user