graph-paper-org / graph-paper

(extremely alpha) a svelte library for making data visualizations and applications.
https://graph-paper-org.github.io/graph-paper/
Mozilla Public License 2.0
36 stars 3 forks source link

prettier removes eslint disable comments in svelte components #19

Open hamilton opened 4 years ago

hamilton commented 4 years ago

It appears that I cannot make my eslint disable comments survive svelte + prettier. I think this is a new thing, probably from one of the dependabot merges, but this collides with the eslint errors being surfaced in the #18.

openjck commented 4 years ago

I'm looking into this. Can you help me build a reproducible example? The disable lines in the following example aren't removed when I run npm run format:

<script>
  /* eslint-disable no-var, vars-on-top */

  import { writable, derived } from "svelte/store";

  var value = writable(0);

  // eslint-disable-next-line no-unused-vars
  $: $value = 5;

  const double = derived(value, ($value) => value * 2); // eslint-disable-line no-unused-vars, no-shadow
</script>

<p>Double is {$double}</p>
hamilton commented 4 years ago

I believe I encountered this in an arrow function inside the template itself, for instance something like


<button on:click={() => {
   acc = acc - 10; // eslint-disable-line
}}>click</button>
hamilton commented 4 years ago

I recognize this might be a limitation of svelte eslint support at this point.

hamilton commented 4 years ago

(I figured it out since CI passes! I just won't do that sort of thing in the future.)

openjck commented 4 years ago

Ah. Still, that shouldn't happen. Thanks for the help. I opened a bug:

https://github.com/sveltejs/prettier-plugin-svelte/issues/104

hamilton commented 4 years ago

Thanks for filing, appreciate it. I should have just done that myself.

openjck commented 4 years ago

No worries. I'll keep track of the issue and close this once it's fixed.

openjck commented 4 years ago

Note:

We can close this after https://github.com/sveltejs/prettier-plugin-svelte/issues/104 is fixed and we upgrade to a version of prettier-plugin-svelte which includes the fix.