Prefer Array#includes() over Array#indexOf() (#1013)
This commit is contained in:
parent
2f6e0064c1
commit
18e0a930be
6 changed files with 11 additions and 6 deletions
|
@ -1,6 +1,9 @@
|
||||||
/** @type {import("eslint").Linter.Config } */
|
/** @type {import("eslint").Linter.Config } */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
root: true,
|
root: true,
|
||||||
|
parserOptions: {
|
||||||
|
project: './tsconfig.json',
|
||||||
|
},
|
||||||
env: {
|
env: {
|
||||||
node: true,
|
node: true,
|
||||||
},
|
},
|
||||||
|
@ -17,7 +20,9 @@ module.exports = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
// Always prefer using an optional chain expression, as it's more concise and easier to read.
|
// Prefer using `includes()` to check if values exist over `indexOf() === -1`, as it's a more appropriate API for this.
|
||||||
|
"@typescript-eslint/prefer-includes": "error",
|
||||||
|
// Prefer using an optional chain expression, as it's more concise and easier to read.
|
||||||
"@typescript-eslint/prefer-optional-chain": "error",
|
"@typescript-eslint/prefer-optional-chain": "error",
|
||||||
"no-unused-vars": "off",
|
"no-unused-vars": "off",
|
||||||
"@typescript-eslint/no-unused-vars": "error",
|
"@typescript-eslint/no-unused-vars": "error",
|
||||||
|
|
|
@ -171,7 +171,7 @@ export const ClientsSection = () => {
|
||||||
if (client.rootUrl) {
|
if (client.rootUrl) {
|
||||||
if (
|
if (
|
||||||
!client.rootUrl.startsWith("http") ||
|
!client.rootUrl.startsWith("http") ||
|
||||||
client.rootUrl.indexOf("$") !== -1
|
client.rootUrl.includes("$")
|
||||||
) {
|
) {
|
||||||
client.rootUrl =
|
client.rootUrl =
|
||||||
client.rootUrl
|
client.rootUrl
|
||||||
|
|
|
@ -16,7 +16,7 @@ export const GroupBreadCrumbs = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return history.listen(({ pathname }) => {
|
return history.listen(({ pathname }) => {
|
||||||
if (pathname.indexOf("/groups") === -1 || pathname.endsWith("/groups")) {
|
if (!pathname.includes("/groups") || pathname.endsWith("/groups")) {
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,7 +15,7 @@ const createUrl = (
|
||||||
let url = path;
|
let url = path;
|
||||||
for (const key in params) {
|
for (const key in params) {
|
||||||
const value = params[key];
|
const value = params[key];
|
||||||
if (url.indexOf(key) !== -1) {
|
if (url.includes(key)) {
|
||||||
url = url.replace(new RegExp(`:${key}\\??`), value || "");
|
url = url.replace(new RegExp(`:${key}\\??`), value || "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ export const DetailSettings = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const sections = [t("generalSettings"), t("advancedSettings")];
|
const sections = [t("generalSettings"), t("advancedSettings")];
|
||||||
const isOIDC = id.indexOf("oidc") !== -1;
|
const isOIDC = id.includes("oidc");
|
||||||
|
|
||||||
if (isOIDC) {
|
if (isOIDC) {
|
||||||
sections.splice(1, 0, t("oidcSettings"));
|
sections.splice(1, 0, t("oidcSettings"));
|
||||||
|
|
|
@ -69,7 +69,7 @@ export const LdapMapperList = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const getUrl = (url: string) => {
|
const getUrl = (url: string) => {
|
||||||
if (url.indexOf("/mappers") === -1) {
|
if (!url.includes("/mappers")) {
|
||||||
return `${url}/mappers`;
|
return `${url}/mappers`;
|
||||||
}
|
}
|
||||||
return `${url}`;
|
return `${url}`;
|
||||||
|
|
Loading…
Reference in a new issue