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

Fix flag overwrites scss file content #102

Open
Shaderpixel opened this issue May 13, 2018 · 3 comments
Open

Fix flag overwrites scss file content #102

Shaderpixel opened this issue May 13, 2018 · 3 comments

Comments

@Shaderpixel
Copy link

In my scss file, I noticed that when I accidentally left some letters after the semicolon like so:
color: red;asdf, gulp-stylelint would replace the entire scss file content with a report string when I set fix: true.
My scss file after running gulp-stylelint, losing all of my scss styles:

[{"source":"assets/src/scss/components/_components.articles.scss","deprecations":[],"invalidOptionWarnings":[],"parseErrors":[],"errored":true,"warnings":[{"line":14,"column":33,"rule":"CssSyntaxError","severity":"error","text":"Unknown word (CssSyntaxError)"}]}]

I am not sure if its just my set up but I have tried postcss stylelint with the fix option set to true and it did not overwrite my entire file like gulp-stylelint did. It would be nice to get this fixed as gulp-stylelint has better reporting capabilities. Any ideas? Here's my gulp-stylelint task :

gulp.task('stylelint:newer', (done) => {
	$.pump([
		gulp.src(distPaths.scssGlob),
		customPlumber('Error Running esLint'),
		$.newer({dest: distPaths.scssDest}),
		$.stylelint({
			fix: true, 
			failAfterError: false,
			reportOutputDir: path.join(commonPaths.logPath, 'stylelint'),
			reporters: [
				{formatter: 'string', console: true},
				{formatter: 'verbose', save: 'report.txt'},
			],
			debug: true
		}),
		gulp.dest(distPaths.scssPath)
	], done);
});
@reinholdk
Copy link

Having the same issue when using the fix option. I'm using gulp 4.0.

@olegskl
Copy link
Owner

olegskl commented Jun 7, 2018

Hello. Sorry for being absent. I'll try to take a look at it when I have some time (hopefully this weekend).

@01taylop
Copy link

Hello, are you using any other plugins? The reason I ask is it could be a specific rule which is causing this issue.

I had the same problem you described so I removed all the rules after which I could no longer replicate the issue. I gradually added the rules back and narrowed my issue down to the stylelint-declaration-strict-value plugin.

I made the subsequent change to the config and no longer have the issue:

const stylelintStrictValueRules = {
  'scale-unlimited/declaration-strict-value': [
    ['/color$/'], {
-      disableFix: false,
+      autoFixFunc: () => null,
    },
  ],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants