Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor lint tweaks #820

Merged
merged 1 commit into from Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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('_')) {
Copy link
Contributor Author

@XhmikosR XhmikosR Oct 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.basename(file.path) cannot be null/undefined here AFAICT so this should be fine.

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