Comments (7)
This is a very good suggestion and I would be in favor of exploiting those new APIs and remove a bit of dirty monkey patching from my plugin ๐ But as you noted, the biggest challenge is to mark variables as defined and used accross script tags (for non-module scripts). The processor API also lacks the ability to access the configuration settings
part, which is used when parsing to know if it is XML or HTML, or which type=
arguments should be considered as JS scripts, among other things.
I will keep this in mind and may find a way to use the new APIs while keeping a bit of monkeypatching for the blocking points.
from eslint-plugin-html.
Are you working on this? It should not be difficult based on my experience by fixing eslint-plugin-markdown
's issues and developing eslint-plugin-mdx
, and fixing other tools' issues due to processor
API.
If you haven't started, I can help to start the job when I'm free.
from eslint-plugin-html.
I want to send a PR to https://github.com/BenoitZugmeyer/eslint-plugin-html, but it's difficult for me. let's see if anyone can help?
I try to read the code of eslint-plugin-html
, it's really complex, I didn't understand every part yet. And I think htmlparser2
APIs are not friendly enough.
But I will try to solute the no-unused-vars
problem someday.
from eslint-plugin-html.
I create https://github.com/nice-move/eslint-plugin-html to do this, not been published yet.
I'm a rookie at making Eslint plugins
, please send me feedback and code reviews.
from eslint-plugin-html.
@Airkro : Ni hao and congratulations on getting a plugin working! It's great to see some movement on this, and it look like you took a sound approach.
However, besides benefiting the other users of this plugin, a PR might ensure that all of the logic with markVariableAsUsed
is not lost. That code is needed because the scripts in HTML are not completely independent of each other, and one doesn't want the no-unused-vars
rule reporting a variable used in a later block which was defined in an earlier one.
from eslint-plugin-html.
@Airkro I think you'd need to fork this repository, then copy your changes across from your repo into the fork on a new branch. You could then push your changes to your fork and request a PR from there.
from eslint-plugin-html.
The processor API also lacks the ability to access the configuration
settings
part, which is used when parsing to know if it is XML or HTML,
One option here would be to provide to different processors in the plugin - one for xml and one for html. The configuration can then specify which processor to use for which file extension.
or which
type=
arguments should be considered as JS scripts, among other things.
I think it might be reasonable to ask core ESLint for an extension of the API to allow specifying the module/script type in the return
options of preprocess
.
from eslint-plugin-html.
Related Issues (20)
- Error when used with "plugin:@typescript-eslint/recommended-requiring-type-checking" HOT 2
- eslint-plugin-html and prettier have autofix issues with indent changes
- Can use it in the browser? HOT 2
- Failed to load plugin 'html' declared in '.eslintrc.json': createRequire is not a function HOT 1
- Problem with version HOT 1
- Linting non-inline scripts HOT 2
- Failed to load plugin 'html' declared in '.eslintrc ยป eslint-config-wesbos': eslint-plugin-html error: It seems that eslint is not loaded. HOT 2
- Parsing error: Unterminated string constant when string includes "<body> HOT 2
- type="module", Error: The keyword 'import' is reserved HOT 1
- Eslint-plugin-html installation failed HOT 1
- EOL tests fail on Windows HOT 1
- When `eslint-plugin-html` is extended, rules from other plugins don't work. HOT 4
- Is it possbile to eslint-disable a script(type=module)? HOT 6
- Twig handlebars result in parsing errors HOT 1
- You must therefore provide a value for the "parserOptions.project" ...
- `<script type="module">` should support top-level-await HOT 1
- How to ignore `<script>` without specified type? HOT 2
- Flat config support HOT 4
- Including `eslint-plugin-html` in a config for eslint 9 prevents non-html files from being processed HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint-plugin-html.