Skip to content

Commit

Permalink
Minor lint tweaks (#820)
Browse files Browse the repository at this point in the history
* use `String.startsWith`
* use `String.includes`
  • Loading branch information
XhmikosR committed Oct 6, 2021
1 parent dd3481b commit bf2fe9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions index.js
@@ -1,10 +1,10 @@
const path = require('path');
const chalk = require('chalk');
const PluginError = require('plugin-error');
const replaceExtension = require('replace-ext');
const stripAnsi = require('strip-ansi');
const transfob = require('transfob');
const clonedeep = require('lodash.clonedeep');
const path = require('path');
const applySourceMap = require('vinyl-sourcemaps-apply');

const PLUGIN_NAME = 'gulp-sass';
Expand All @@ -21,7 +21,7 @@ const gulpSass = (options, sync) => transfob((file, enc, cb) => { // eslint-disa
return cb(new PluginError(PLUGIN_NAME, 'Streaming not supported'));
}

if (path.basename(file.path).indexOf('_') === 0) {
if (path.basename(file.path).startsWith('_')) {
return cb();
}

Expand Down
22 changes: 11 additions & 11 deletions test/main.js
@@ -1,7 +1,7 @@
const fs = require('fs');
const path = require('path');
const should = require('should');
const Vinyl = require('vinyl');
const path = require('path');
const fs = require('fs');
const rimraf = require('rimraf');
const gulp = require('gulp');
const sourcemaps = require('gulp-sourcemaps');
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('gulp-sass -- async compile', () => {
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
if (cssFile.path.indexOf('variables') !== -1) {
if (cssFile.path.includes('variables')) {
expectedPath = path.join('expected', 'variables.css');
}

Expand Down Expand Up @@ -156,11 +156,11 @@ describe('gulp-sass -- async compile', () => {

stream.on('error', (err) => {
// Error must include message body
err.message.indexOf('property "font" must be followed by a \':\'').should.not.equal(-1);
err.message.includes('property "font" must be followed by a \':\'').should.equal(true);
// Error must include file error occurs in
err.message.indexOf('test', 'scss', 'error.scss').should.not.equal(-1);
err.message.includes('test', 'scss', 'error.scss').should.equal(true);
// Error must include line and column error occurs on
err.message.indexOf('on line 2').should.not.equal(-1);
err.message.includes('on line 2').should.equal(true);
// Error must include relativePath property
err.relativePath.should.equal(path.join('test', 'scss', 'error.scss'));
done();
Expand All @@ -174,9 +174,9 @@ describe('gulp-sass -- async compile', () => {

stream.on('error', (err) => {
// Error must include original error message
err.messageOriginal.indexOf('property "font" must be followed by a \':\'').should.not.equal(-1);
err.messageOriginal.includes('property "font" must be followed by a \':\'').should.equal(true);
// Error must not format or change the original error message
err.messageOriginal.indexOf('on line 2').should.equal(-1);
err.messageOriginal.includes('on line 2').should.equal(false);
done();
});
stream.write(errorFile);
Expand Down Expand Up @@ -280,7 +280,7 @@ describe('gulp-sass -- async compile', () => {
should.exist(cssFile.path);
should.exist(cssFile.relative);
should.exist(cssFile.contents);
if (cssFile.path.indexOf('indent') !== -1) {
if (cssFile.path.includes('indent')) {
expectedPath = path.join('expected', 'indent.css');
}

Expand Down Expand Up @@ -360,7 +360,7 @@ describe('gulp-sass -- sync compile', () => {
should.exist(cssFile.relative);
should.exist(cssFile.contents);

if (cssFile.path.indexOf('variables') !== -1) {
if (cssFile.path.includes('variables')) {
expectedPath = path.join('expected', 'variables.css');
}

Expand Down Expand Up @@ -400,7 +400,7 @@ describe('gulp-sass -- sync compile', () => {
const stream = sass.sync();

stream.on('error', (err) => {
err.message.indexOf('property "font" must be followed by a \':\'').should.not.equal(-1);
err.message.includes('property "font" must be followed by a \':\'').should.equal(true);
err.relativePath.should.equal(path.join('test', 'scss', 'error.scss'));
done();
});
Expand Down

0 comments on commit bf2fe9e

Please sign in to comment.