Skip to content

Commit 672c46d

Browse files
committed
chore: replace some .indexOf() === -1 with .includes()
1 parent 2f1c5f7 commit 672c46d

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

lib/EncoreProxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = {
4040
'isRuntimeEnvironmentConfigured',
4141
];
4242

43-
if (!Encore.isRuntimeEnvironmentConfigured() && (safeMethods.indexOf(prop) === -1)) {
43+
if (!Encore.isRuntimeEnvironmentConfigured() && !safeMethods.includes(prop)) {
4444
throw new Error(`Encore.${prop}() cannot be called yet because the runtime environment doesn't appear to be configured. Make sure you're using the encore executable or call Encore.configureRuntimeEnvironment() first if you're purposely not calling Encore directly.`);
4545
}
4646

lib/WebpackConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ class WebpackConfig {
727727
// Check allowed keys
728728
const validKeys = ['js', 'css', 'images', 'fonts'];
729729
for (const key of Object.keys(configuredFilenames)) {
730-
if (validKeys.indexOf(key) === -1) {
730+
if (!validKeys.includes(key)) {
731731
throw new Error(`"${key}" is not a valid key for configureFilenames(). Valid keys: ${validKeys.join(', ')}.`);
732732
}
733733
}
@@ -747,7 +747,7 @@ class WebpackConfig {
747747
// Check allowed keys
748748
const validKeys = ['images', 'fonts'];
749749
for (const key of Object.keys(urlLoaderOptions)) {
750-
if (validKeys.indexOf(key) === -1) {
750+
if (!validKeys.includes(key)) {
751751
throw new Error(`"${key}" is not a valid key for configureUrlLoader(). Valid keys: ${validKeys.join(', ')}.`);
752752
}
753753
}

lib/config/path-util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = {
109109
*
110110
* For that reason, we force you to choose your manifestKeyPrefix().
111111
*/
112-
if (outputPath.indexOf(publicPath) === -1) {
112+
if (!outputPath.includes(publicPath)) {
113113
const suggestion = publicPath.substr(publicPath.lastIndexOf('/') + 1) + '/';
114114

115115
throw new Error(`Cannot determine how to prefix the keys in manifest.json. Call Encore.setManifestKeyPrefix() to choose what path (e.g. ${suggestion}) to use when building your manifest keys. This is caused by setOutputPath() (${outputPath}) and setPublicPath() (${publicPath}) containing paths that don't seem compatible.`);

lib/friendly-errors/transformers/missing-css-file.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function isMissingConfigError(e) {
1616
return false;
1717
}
1818

19-
if (e.message.indexOf('Module not found: Error: Can\'t resolve') === -1) {
19+
if (!e.message.includes('Module not found: Error: Can\'t resolve')) {
2020
return false;
2121
}
2222

lib/friendly-errors/transformers/missing-loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function isMissingLoaderError(e) {
1616
return false;
1717
}
1818

19-
if (e.message.indexOf('You may need an appropriate loader') === -1) {
19+
if (!e.message.includes('You may need an appropriate loader')) {
2020
return false;
2121
}
2222

lib/friendly-errors/transformers/missing-postcss-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function isMissingConfigError(e) {
1616
return false;
1717
}
1818

19-
if (e.message.indexOf('No PostCSS Config found') === -1) {
19+
if (!e.message.includes('No PostCSS Config found')) {
2020
return false;
2121
}
2222

lib/package-helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function getInstallCommand(packageConfigs) {
4343

4444
// e.g. ^4.0||^5.0: use the latest version
4545
let recommendedVersion = firstPackage.version;
46-
if (recommendedVersion.indexOf('||') !== -1) {
46+
if (recommendedVersion.includes('||')) {
4747
recommendedVersion = recommendedVersion.split('|').pop().trim();
4848
}
4949

0 commit comments

Comments
 (0)