Code Monkey home page Code Monkey logo

markuplint / markuplint Goto Github PK

View Code? Open in Web Editor NEW
529.0 3.0 46.0 27.58 MB

An HTML linter for all markup developers.

Home Page: https://markuplint.dev

License: MIT License

TypeScript 95.02% HTML 1.85% JavaScript 1.49% Vue 0.09% Pug 0.07% Svelte 0.04% CSS 0.70% Dockerfile 0.01% Liquid 0.01% Handlebars 0.01% PHP 0.01% EJS 0.02% Mustache 0.02% Nunjucks 0.01% Shell 0.01% Astro 0.13% MDX 0.51%
linter html webcomponents custom-elements html-linter vue svelte pug markup-languages php

markuplint's Introduction

markuplint

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Gitter FOSSA Status

Peace of mind in your markup - An HTML linter for all markup developers.

Website

Packages

Package Name NPM Platform
CLI markuplint npm version Node.js
Core @markuplint/ml-core npm version Universal
Rules @markuplint/rules npm version Universal
HTML Parser @markuplint/html-parser npm version Universal
Specs and Schemas @markuplint/html-spec npm version Universal

More Packages...

Template Parser Plugins

Package Name NPM Platform
JSX @markuplint/jsx-parser npm version Universal
Vue @markuplint/vue-parser npm version Universal
Svelte @markuplint/svelte-parser npm version Universal
Astro @markuplint/astro-parser npm version Universal
Pug @markuplint/pug-parser npm version Universal
PHP @markuplint/php-parser npm version Universal

More Template Parser Plugins...

Editor Extensions

License

FOSSA Status

Sponsors

Corporate Sponsors

Velc

Personal Supporters

Tokitake Okuto Oyama miita Yasuo Fukuda Hideyuki Saito shamokit

Need Sponsors❤️‍🔥

Thanks

This linter is inspired by:

markuplint's People

Contributors

bugfire avatar coliff avatar conao3 avatar daku10 avatar dependabot[bot] avatar dqn avatar exoego avatar fossabot avatar gyugyu avatar jounqin avatar kagankan avatar konojunya avatar konomae avatar mojahige avatar munierujp avatar n0h0 avatar nagashimam avatar okathira avatar petamoriken avatar puku0x avatar renovate[bot] avatar risu729 avatar saekitominaga avatar saphryn avatar shippokun avatar takenspc avatar tyankatsu0105 avatar undsoft avatar yamanoku avatar yusukehirao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

markuplint's Issues

Warning obsolete DOCTYPE declaration

DOCTYPE declarations other than <!doctype html> are almost old, so need to warn them all.

Following items are example of the old DOCTYPE declarations:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

WAI-ARIA rule

I designed a rule for WAI-ARIA is:


Warn if the role attribute and/or aria-* attributes don't set in accordance with specs that are WAI-ARIA and/or "ARIA in HTML".

Warn if:

  • Use the role that doesn't exist in the spec.
  • Use the abstract role.
  • Use the aria-* attribute that doesn't belong to a set role (or an implicit role).
  • [Optional] Use a bad value of the aria-* attribute.
  • [Optional] Use the not permitted role according to ARIA in HTML.
  • [Optional] Set the implicit role explicitly.

Rule Details

👎 Examples of incorrect code for this rule

<div role="landmark" aria-busy="busy">
	<ul>
		<li role="button">an item</li>
	</ul>
	<button aria-checked="true">Click me!</button>
</div>

👍 Examples of correct code for this rule

<div role="banner" aria-busy="true">
	<ul>
		<li role="menuitemcheckbox">an item</li>
	</ul>
	<button aria-pressed="true">Click me!</button>
</div>

Setting value

Type: boolean

Options

checkingValue

Warn if use a bad value of the aria-* attribute. This is optional but you should not disable it if you need to follow the spec. But you can disable it temporarily if you need when it happened to a problem on the spec was updated (ex: If a value was added to an allowed list on the spec, etc).

  • Type: boolean
  • Optional
  • Default: true
permittedAriaRoles

Warn if use the not permitted role according to ARIA in HTML. This is optional because it is for the HTML as the host language and it is not the spec of WAI-ARIA.

  • Type: boolean
  • Optional
  • Default: true
disallowSetImplicitRole

Disallow set the implicit role explicitly. This is optional because it is for the HTML as the host language and it is not the spec of WAI-ARIA.

  • Type: boolean
  • Optional
  • Default: true

Default notification severity

error

issues

  • attr-value-quotes: misjudgment void attributes
  • attr-value-quotes: mis parse <hx> tag name
  • character-reference: misjudgment in <script></script>

Required specs

The new logo

markuplint logo

The current logo was made just quick by me.
I want a designer to improve it properly.

Want:

  • Accessible.
  • Compatible with dark mode.
  • Usable for a small area.
  • Monochromatic variation.

Ignore blocks

Is there possibility of adding option to ignore certain parts of the markup? For example, common use case when using PHP templates is to use <?php … ?> blocks which can create confusion for markuplint parser. Is it possible to create some option (or rule) to ignore those blocks (via regex, …)?

Features for Accessibility

  • Require the title attribute for the abbr element
  • Require the alt attribute for the img element
  • Accname checking
  • No autofocus
  • No aria-hidden
  • the label element and a form control element
  • the track element and the audio/video element
  • No positive tab-index
  • No inexistent hash link
  • Accessible emoji
  • aria-activedescendant has tab-index
  • Require the lang attribute for the html element
  • Require the title attribute for the iframe element
  • No accesskey
  • No hgroup (Ref)

`*.erb` support

I'm running a monolithic Rails application at work. I'm trying to have the front end responsibilities on the front side, but I don't think I can do that yet and I think some of it will remain.

I think many people would be happy if erb files were also subject to markuplint 🙏

https://markuplint.dev/setting-for-other-languages

Show help message when invoke command without argument

In general, when the user directly invokes a command that requires an argument, it will often output a simple help along with an indication that an argument is required.

I discovered the --help option on a hunch, but it's not friendly.
Please show a help message with a warning that an argument is required when the user invokes markuplint it without any argument?

npm without argument

dbbf47d7060b% npm

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    clean-install, clean-install-test, completion, config,
    create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
    edit, explore, fund, get, help, help-search, hook, i, init,
    install, install-ci-test, install-test, it, link, list, ln,
    login, logout, ls, org, outdated, owner, pack, ping, prefix,
    profile, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    /home/conao/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

[email protected] /home/conao/.anyenv/envs/nodenv/versions/14.13.0/lib/node_modules/npm

markuplint without argument

(nothing output)

dbbf47d7060b% npx markuplint       
dbbf47d7060b% 

Rule `case-sensitive-attr-name` doesn't work correctly

Version

v1.6.1

Steps to reproduce

{
  "rules": {
    "case-sensitive-attr-name": {
      "value": "lower",
      "severity": "warning"
    }
  }
}

What is expected?

passed

What is actually happening?

warning: Attribute name of HTML elements should be uppercase (case-sensitive-attr-name)

Enable to use default rules and config detection feature via Node.js API

Hello!

I encounters a problem which I cannot utilize default rules and default config detection on easy way during I'm writing a gulp plugin to use markuplint in gulp task.

The Node.js APIs (verify and verifyFile) looks to assume the users to specify ruleset and rules by themselves. It would be a bit hard for a plugin devs to use the APIs.

I'm executing markuplint command via CLI to use such features. However, it decreases the flexibility of the tool.

Can we includes the features in the Node.js APIs like eslint's CLIEngine or expose them as a separated APIs so that plugin devs easily write full-featured markuplint plugins?

SyntaxError uE000

I came across a really weird error while trying to lint simple liquid files.

SyntaxError: Invalid tag syntax: <div class="ImageHero__Image" style="background-image: url()"

No tool finds this, not perl, sed, grep ...

.markuplintrc

{
    "extends": "@markuplint/html-spec",
    "parser": {
        "^((?!(js|css)).)*\\.liquid$": "@markuplint/liquid-parser"
    }
}

Add CONTRIBUTING.md

Hi, I want to contribute to this project, but I don't familier with Node.

Could you add CONTRIBUTING.md for me and other new contributors to get running local tests or something internal information or something prerequirements before send PRs.

Features for Security

  • rel="noreferrer noopener" on the a and area element with target="_blank"
  • download attribute on the a and area element that its href value is not same origin
  • charset attribute on the meta element that value has XSS incident

Thrown an exception if use the header element.

<header>
    ...
</header>
UnhandledPromiseRejectionWarning: Error: Unsupport "descendants" pseudo selector in ":descendants(article, aside, main, nav, section, [role=article], [role=complementary], [role=main], [role=navigation], [role=region])"

PostHTML?

Have you considered using PostHTML as HTML parser? It is well-tested and has existed for sometime, and maybe Markuplint can use it’s parser and just focus on creating linting capabilities?

Or is Markuplint’s parser more powerful and flexible that PostHTML’s one?

[feat] Can you please provide sync API with async together?

I'm trying to integrate this package with ESLint together, and found that I have to resolve `config`, `rules` and `locale` manually to use `verify` API. I know I can follow https://github.com/markuplint/markuplint/blob/master/packages/markuplint/src/lint.ts#L64-L66 as example to get the necessary parameters quickly, but it would be better to provide a simpler API to do this job.

Maybe I should exec API instead.

const resultInfos = await exec({
  sourceCodes: sourceCode,
  names: filename,
  fix: true,
})

And there is no synchronized API provided, which is incompatible with ESLint currently.

So, I hope a synchronized API.

Thanks for your great work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.