Code Monkey home page Code Monkey logo

stylelint-images's Introduction

stylelint-images

NPM version Build Status

A collection of rules to check images for stylelint (in a form of a plugin).

Table of Contents

Installation

stylelint-images is a plugin for stylelint, so it's meant to be used with it.

Node.js v6 or newer is required. That's because stylelint itself doesn't support Node.js versions below 6.

First, install stylelint-images (and stylelint, if you haven't done so yet) via NPM:

npm install -D stylelint@^9.1.0 stylelint-images

Or if you use Yarn:

yarn add stylelint@^9.1.0 stylelint-images -D

Usage

Create the .stylelintrc.json config file (or open the existing one), add stylelint-images to the plugins array and the rules you need to the rules list. All rules from stylelint-images need to be namespaced with images.

{
  "plugins": [
    "stylelint-images"
  ],
  "rules": {
    "images/broken": true,
    "images/prefer-data-uri": 256,
    ...
  }
}

Please refer to stylelint docs for the detailed info on using this linter.

List of rules

  • broken: Checks if the images are broken.
  • prefer-data-uri: Suggest using data-URIs instead of an external image if its file size (in bytes) is smaller than the limit.

Contribute

Feel free to dive in! Open an issue or submit PRs.

stylelint-images follows the Contributor Covenant Code of Conduct.

License

stylelint-images is MIT licensed.

stylelint-images's People

Contributors

ramasilveyra avatar dependabot[bot] avatar k41n avatar pkuczynski avatar ntwb avatar

Stargazers

Roman avatar Alexandr Naumov avatar Andrew Barrows avatar Alexey Sidorov avatar Nick Tishkevich avatar Yusuke Hayashi avatar Florent avatar Hongbo Miao avatar bethon avatar Olekseii Vakhrushev avatar Daniel Bannert avatar Manu K avatar  avatar Bui Thanh Ba Vuong avatar Jacky Alciné avatar Bruno Gomes avatar Yaroslav Kovalev avatar Dmitri Pyatkov avatar Philipp Andreychev avatar Jitendra Vyas avatar  avatar Ricky Rauch avatar Cristian Douce avatar Alfredo Villagomez avatar Ivan Demidov avatar Michael Danilov avatar Ariel Gerstein avatar Alejo Fernandez avatar Fyodor Ivanischev avatar Ilya Shabanov avatar Marcus Tisäter  avatar Ilya Radchenko avatar  avatar Andrey Sitnik avatar  avatar

Watchers

Jitendra Vyas avatar Matias Woloski avatar James Cloos avatar Chris Keyser avatar Alfredo Villagomez avatar  avatar

stylelint-images's Issues

A new Security vulnerability detected with axios

Hi, it looks like there is a new High severity vulnerability with axios. Is it possible to update the version in this package, because the vulnerability cannot be fixed with npm audit fix?

                       === npm audit security report ===                        
                                                                                
┌──────────────────────────────────────────────────────────────────────────────┐
│                                Manual Review                                 │
│            Some vulnerabilities require your attention to resolve            │
│                                                                              │
│         Visit https://go.npm.me/audit-guide for additional guidance          │
└──────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ High          │ Server-Side Request Forgery                                  │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ axios                                                        │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ >=0.21.1                                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ stylelint-images [dev]                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ stylelint-images > axios                                     │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/1594                            │
└───────────────┴──────────────────────────────────────────────────────────────┘

Support for local images?

Any reason this plugin doesn't support locally hosted images? It seems like it'd be beneficial to be able to test if an image reference exists or not, while developing.

Happy to do the work and create an MR if you'd like.
-E

Security vulnerability detected for axios

There is a Moderate vulnerability warning being caused by an outdated dependency in this project.

This is what I get when I run npm audit on my project that has stylelint-images as a dependency.

Moderate **Denial of Service **
Package axios
Patched in >=0.18.1
Dependency of stylelint-images [dev]
Path stylelint-images > axios
More info https://npmjs.com/advisories/880

This issue cannot be fixed automatically with npm audit fix and has to be fixed here. Is it possible to update this package here?

Add rule to warn with unoptimized files

Name: images/unoptimized

Reference: https://github.com/sindresorhus/gulp-imagemin/

Also add a rule option to pass custom imagemin options, maybe something like pointing to a file with the custom options. E.g.:

    "images/unoptimized": [true, {
      "imagemin-options-file": "./config/imagemin.js"
    }]

./config/imagemin.js:

'use strict';

const { gifsicle, jpegtran, optipng, svgo } = require('stylelint-images');

module.exports = [
  gifsicle(),
  jpegtran(),
  optipng(),
  svgo({ plugins: [{ removeUselessDefs: false }] })
];

Also cache the optimized result.

Similar plugin for fonts

Hi! Awesome plugin.

Is there something similar but for font files? It would be awesome to use these two together.

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.