Skip to content
This repository has been archived by the owner on Apr 18, 2021. It is now read-only.

eslint conflicting with prettier rule #13

Open
aubreypwd opened this issue Oct 9, 2020 · 5 comments
Open

eslint conflicting with prettier rule #13

aubreypwd opened this issue Oct 9, 2020 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@aubreypwd
Copy link
Contributor

eslintprettier

			// If we're clicking on this accordion...
			if ( content.previousElementSibling === targetParent ) {
				// If it's already opened, close it. Otherwise, open it!
				if ( 'false' === content.getAttribute( 'aria-hidden' ) ) {
					content.setAttribute( 'aria-hidden', 'true' );
					content.parentElement.classList.remove( 'open' );
				} else {
					content.setAttribute( 'aria-hidden', 'false' );
					content.parentElement.classList.add( 'open' );
				}
			} else {
				content.setAttribute( 'aria-hidden', 'true' );
				content.parentElement.classList.remove( 'open' );
			}
		} );
aubreypwd added a commit to WebDevStudios/eslint-config-js-coding-standards that referenced this issue Oct 9, 2020
See WebDevStudios/js-coding-standards#13

This is a test to ensure that a line is required on comments above.
@aubreypwd
Copy link
Contributor Author

I can confirm that this is not comming from eslint-config and we need to remove the prettier rule this conflicts with.

@aubreypwd
Copy link
Contributor Author

image

I can confirm that prettier is removing this line on format, not sure why it's showing the lint in wd_s though...

@aubreypwd
Copy link
Contributor Author

So after some googling, it turns out Prettier forces you to collapse empty lines, see:

Now, the issue is that an empty line and a comment is seen a double 2 lines, which it collapses.

Prettier collapses multiple blank lines into a single blank line.

So what this means is that Prettier actually breaks one of our JavasScript rules which requires a blank line above comments, e.g.

image

...only when the comment is the first comment of the function, this works:

if ( true ) {
	let a = true;

	// The blank line above will not be collapsed by prettier.
	return true;
}

This does not, however, get fixed.

@aubreypwd
Copy link
Contributor Author

This issue that arises, in how wd_s wants to fix everything on e.g. npm run lint is that Prettier breaks this rule, fixes it then eslint (maybe even via eslint --fix) will fix it back...

@TrejGun
Copy link

TrejGun commented Feb 26, 2021

i have this issue too

@aubreypwd aubreypwd self-assigned this Mar 9, 2021
@aubreypwd aubreypwd added the bug Something isn't working label Mar 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants