Not planned
Description
Using web components, and HTML Imports it's common to put JavaScript directly into HTML like so:
<template> ... </template>
<script>
(function(){
// define a custom element here
})();
</script>
You can put these scripts into external files but it's often nicer not to. Would be nice if these <script>
s could be flow checked.
Activity
danmindru commentedon Oct 19, 2016
Same case for .vue (Vue.js) components. There's a nasty workaround in Vue that'll make it work atm (using comments):
It's nasty to say the least & it might break in a future release of Vue. If Flow could parse the
<script>
tag all of this will go away.mickdekkers commentedon Nov 7, 2016
+💯
For reference, there is a plugin for ESLint called eslint-plugin-html that enables it to lint HTML files.
Perhaps something similar could be developed for Flow.
cr0cK commentedon Dec 24, 2016
Any progress on it? Vue is more and more popular, it should be nice if a solution à la eslint-plugin-html could be added to Flow... Perhaps like an option?
scottbedard commentedon Jan 26, 2017
Has any progress been made on this, or is anyone working on it? This feature is the only thing preventing me from using Flow.
therealmarv commentedon Feb 4, 2017
Is this a possible workaround for vue components?
Seperate .vue files at the beginning and let them act as kind of "loader" for .js and .html files like in this vue 2.0 boilerplate. It's this way not ugly looking comments.
Example .vue file:
and place your index.html and index.js (with your vue code) file in the same directory (let flow ignore .vue).
danmindru commentedon Feb 4, 2017
That should be fine for standalone, but it won't work for the runtime-only build.
therealmarv commentedon Feb 4, 2017
a workaround for runtime is babel-plugin-tcomb. Explanation here http://stackoverflow.com/a/40130503/756056
sobolevn commentedon Feb 22, 2018
You actually can use
flow
withvue
.Here's the full example: https://github.com/wemake-services/wemake-vue-template
mrkev commentedon May 24, 2018
JS in HTML is a complicated issue. It potentially necessitates a whole new way of building dependency graphs and also introduces the concept of a cross-file global environment.
goodmind commentedon Jun 9, 2019
@mrkev what you mean by cross-file global environment, isn't this already exists with
declare var
?mrkev commentedon Jun 24, 2019
@goodmind I mean the implicit
window
. I guess it's not necessary per-se, but I was just wondering how we could build a dependency graph with a different way of handling imports/exports.goodmind commentedon Jul 28, 2019
@mrkev would this require some OCaml HTML parser? jsx parser is not good for html files
mrkev commentedon Aug 8, 2019
@goodmind probably that too for inline JS, yeah.