Skip to content

Commit

Permalink
use stringWith method
Browse files Browse the repository at this point in the history
  • Loading branch information
k-rajat19 committed Aug 17, 2024
1 parent e53a49a commit 557e93c
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/data/material/customization/color/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function getColorBlock(theme, colorName, colorValue, colorTitle) {
padding: 15,
};

if (colorValue.toString().indexOf('A1') === 0) {
if (colorValue.toString().startsWith('A1')) {
rowStyle = {
...rowStyle,
marginTop: 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export default function MaterialUIComponents() {
</TableCell>
<TableCell>
{component.materialUI &&
component.materialUI.indexOf('/material-ui') === 0 ? (
component.materialUI.startsWith('/material-ui') ? (
<Link
variant="body2"
data-no-markdown-link="true"
Expand All @@ -245,7 +245,7 @@ export default function MaterialUIComponents() {
Native support
</Link>
) : null}
{component.materialUI && component.materialUI.indexOf('/x') === 0 ? (
{component.materialUI && component.materialUI.startsWith('/x') ? (
<Link
variant="body2"
data-no-markdown-link="true"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function pathnameToLanguage(pathname: string): {

if (
[...LANGUAGES, 'zh'].includes(userLanguageCandidate) &&
pathname.indexOf(`/${userLanguageCandidate}/`) === 0
pathname.startsWith(`/${userLanguageCandidate}/`)
) {
userLanguage = userLanguageCandidate;
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/parseMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ function createRender(context) {

checkUrlHealth(href, linkText, context);

if (userLanguage !== 'en' && href.indexOf('/') === 0 && !options.ignoreLanguagePages(href)) {
if (userLanguage !== 'en' && href.startsWith('/') && !options.ignoreLanguagePages(href)) {
finalHref = `/${userLanguage}${href}`;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useAutocomplete/useAutocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function createFilterOptions(config = {}) {
}

return matchFrom === 'start'
? candidate.indexOf(input) === 0
? candidate.startsWith(input)
: candidate.indexOf(input) > -1;
});

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useList/listReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function textCriteriaMatches<ItemValue>(
return false;
}

return text.indexOf(searchString) === 0;
return text.startsWith(searchString);
}

function handleTextNavigation<ItemValue, State extends ListState<ItemValue>>(
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/useSlider/useSlider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ export function useSlider(parameters: UseSliderParameters): UseSliderReturnValue
const { width, height, bottom, left } = slider!.getBoundingClientRect();
let percent;

if (axis.indexOf('vertical') === 0) {
if (axis.startsWith('vertical')) {
percent = (bottom - finger.y) / height;
} else {
percent = (finger.x - left) / width;
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-codemod/src/v0.15.0/import-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ const pathBaseSource = ['material-ui/src/', 'material-ui/src/'];
const pathBasePackage = ['material-ui/lib/', 'material-ui/'];

function getPathsBase(path) {
if (path.indexOf(pathBaseSource[0]) === 0) {
if (path.startsWith(pathBaseSource[0])) {
return pathBaseSource;
}

if (path.indexOf(pathBasePackage[0]) === 0) {
if (path.startsWith(pathBasePackage[0])) {
return pathBasePackage;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-docs/src/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(function Link
if (
userLanguage !== 'en' &&
pathname &&
pathname.indexOf('/') === 0 &&
pathname.startsWith('/') &&
!LANGUAGES_IGNORE_PAGES(pathname) &&
!pathname.startsWith(`/${userLanguage}/`)
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Grid/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function generateDirection({ theme, ownerState }) {
flexDirection: propValue,
};

if (propValue.indexOf('column') === 0) {
if (propValue.startsWith('column')) {
output[`& > .${gridClasses.item}`] = {
maxWidth: 'none',
};
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/MenuList/MenuList.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function textCriteriaMatches(nextFocus, textCriteria) {
if (textCriteria.repeating) {
return text[0] === textCriteria.keys[0];
}
return text.indexOf(textCriteria.keys.join('')) === 0;
return text.startsWith(textCriteria.keys.join(''));
}

function moveFocus(
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/styles/createTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function createTheme(options = {}, ...args) {
Object.keys(muiTheme.components).forEach((component) => {
const styleOverrides = muiTheme.components[component].styleOverrides;

if (styleOverrides && component.indexOf('Mui') === 0) {
if (styleOverrides && component.startsWith('Mui')) {
traverse(styleOverrides, component);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function createGenerateClassName(options = {}) {
const name = styleSheet.options.name;

// Is a global static MUI style?
if (name && name.indexOf('Mui') === 0 && !styleSheet.options.link && !disableGlobal) {
if (name && name.startsWith('Mui') && !styleSheet.options.link && !disableGlobal) {
// We can use a shorthand class name, we never use the keys to style the components.
if (stateClasses.indexOf(rule.key) !== -1) {
return `Mui-${rule.key}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export function recomposeColor(color) {
*/
export function rgbToHex(color) {
// Idempotent
if (color.indexOf('#') === 0) {
if (color.startsWith('#')) {
return color;
}

Expand Down

0 comments on commit 557e93c

Please sign in to comment.