All Projects → ChristianMurphy → selective

ChristianMurphy / selective

Licence: MIT License
Statically find HTML anti patterns using CSS Selectors

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to selective

lint-html-with-css
Lint HTML with CSS. A collection of CSS snippets from the hashtag #lintHTMLwithCSS on twitter. These CSS snippets intend to warn developers about common mistakes made in HTML.
Stars: ✭ 35 (+133.33%)
Mutual labels:  lint, accessibility, linter
AutoBindings
Set of annotations that aims to make your Android development experience easier along with lint checks.
Stars: ✭ 15 (+0%)
Mutual labels:  lint, linter
arduino-lint
Tool to check for problems with Arduino projects
Stars: ✭ 63 (+320%)
Mutual labels:  lint, linter
lint-prepush
Lint committed files on pre-push 🔬
Stars: ✭ 18 (+20%)
Mutual labels:  lint, linter
arcanist-linters
A collection of custom Arcanist linters
Stars: ✭ 64 (+326.67%)
Mutual labels:  lint, linter
extra pedantic
Stricter Dart analyzer linter settings and best practices.
Stars: ✭ 28 (+86.67%)
Mutual labels:  lint, linter
dockerfile-utils
A library and command line interface for formatting and linting Dockerfiles.
Stars: ✭ 17 (+13.33%)
Mutual labels:  lint, linter
KaiZen-OpenApi-Parser
High-performance Parser, Validator, and Java Object Model for OpenAPI 3.x
Stars: ✭ 119 (+693.33%)
Mutual labels:  lint, linter
cpplint
Static code checker for C++
Stars: ✭ 1,014 (+6660%)
Mutual labels:  lint, linter
pahout
A pair programming partner for writing better PHP. Pahout means PHP mahout 🐘
Stars: ✭ 43 (+186.67%)
Mutual labels:  lint, linter
JSONCustomLintr
Library to allow creation, running, and reporting of custom lint rules for JSON files
Stars: ✭ 19 (+26.67%)
Mutual labels:  lint, linter
relint
General purpose RegEx based file linter.
Stars: ✭ 33 (+120%)
Mutual labels:  lint, linter
folderslint
📁 Directory structure linter for JavaScript projects
Stars: ✭ 131 (+773.33%)
Mutual labels:  lint, linter
HTML-Lint
A code quality bookmarklet and command-line tool
Stars: ✭ 20 (+33.33%)
Mutual labels:  lint, accessibility
breakcheck
Backwards compatibility linter for Go.
Stars: ✭ 66 (+340%)
Mutual labels:  lint, linter
openapi-lint-vscode
OpenAPI 2.0/3.0.x intellisense, validator, linter, converter and resolver extension for Visual Studio Code
Stars: ✭ 47 (+213.33%)
Mutual labels:  lint, linter
eslint-config
An ESLint shareable config that I used in my projects
Stars: ✭ 15 (+0%)
Mutual labels:  lint, linter
rubocop-linter-action
Rubocop Linter Action: A GitHub Action to run Rubocop against your code!
Stars: ✭ 86 (+473.33%)
Mutual labels:  lint, linter
litho-lint-rules
Lint rules for Litho by Facebook http://fblitho.com/
Stars: ✭ 14 (-6.67%)
Mutual labels:  lint, linter
flake8-broken-line
🚨 Flake8 plugin to forbid backslashes (\) for line breaks
Stars: ✭ 85 (+466.67%)
Mutual labels:  lint, linter

Selective

NPM Version Linux Build Status Windows Build status

Use CSS selectors to find HTML anti-patterns

Creating Rules

create a configuration in a .selective file.

@selective/rehype will look for a config.selective file in the current folder by default.

The rules language is designed to work similar to CSS. Use a CSS Selector to find HTML elements.

Instead of the usual style rules, linter rules are used.

  • name a unique identifier for easily tracking down the rule
  • description an explanation of the problem.
  • recommended how this will be reported, can be one of:
    • error will stop processing and return an error code
    • warn will continue processing, but highlight as important, no error code.
    • info will continue processing, no error code.
    • off disabled

Example Rules

img:not([alt]) {
  name: "img-alt";
  description: "image tag must contain an alt property";
  recommended: warn;
}

img:not([src]) {
  name: "img-src";
  description: "image tag must contain an src property";
  recommended: warn;
}

ol > :not(li),
ul > :not(li),
:not(ol) > li,
:not(ul) > li {
  name: "list-item";
  description: "unorder lists, ordered lists, and list items must have a direction relationship";
  recommended: warn;
}

Atom Usage

apm install linter-selective

selective lint example

linter-selective

Rehype CLI Usage

in package.json through rehype.

{
  "devDependencies": {
    "rehype": "^5.0.0",
    "@selective/rehype": "0.0.3"
  },
  "rehype": {
    "plugins": ["@selective/rehype"]
  }
}

this can be additionally customized with a custom config file path

{
  "devDependencies": {
    "rehype": "^5.0.0",
    "@selective/rehype": "0.0.3"
  },
  "rehype": {
    "plugins": [["@selective/rehype", { "config": "custom.selective" }]]
  }
}

Programmatic Usage

const rehype = require("rehype");
const selectiveRehype = require("@selective/rehype");
const { readFileSync } = require("fs");

rehype()
  .use(
    selectiveRehype({
      config: "config.selective",
    })
  )
  .process(readFileSync("somefile.html"), (err) => {
    console.error(err);
  });
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].