Git Product home page Git Product logo

stylelint-browser-compat's Introduction

stylelint-browser-compat

stylelint-browser-compat

github sponsors npm license standard-readme compliant

Yet another linter rule to detect compatibility of CSS features.

This plugin checks if the CSS you're using is supported by the browsers you're targeting. It uses @mdn/browser-compat-data to detect browser support.

⚠️ This plugin is beta. USE AT YOUR OWN RISK.

Table of Contents

Background

stylelint-no-unsupported-browser-features (using doiuse) is available to detect compatibility of CSS features.

However, doiuse have not been maintained for a long time.

This library provides another alternative to detect compatibility of CSS features.

Although doiuse detects compatibility from caniuse data, this library uses @mdn/browser-compat-data to do so.

Install

$ npm install --dev browserslist stylelint stylelint-browser-compat
$ yarn add --dev browserslist stylelint stylelint-browser-compat

Usage

module.exports = {
  plugins: ['stylelint-browser-compat'],
  rules: {
    'plugin/browser-compat': [
      true,
      {
        allow: {
          features: ['at-rules.supports'],
          flagged: false,
          partialImplementation: false,
          prefix: true,
        },
        browserslist: ['last 2 versions'],
      },
    ],
  },
};

Options

  • browserslist (string or array, optional)
    • Accepts browserslist queries for target browsers.
    • By default, browserslist automatically loads the configuration file (e.g. package.json, .browserslistrc).
  • allow.features (array, optional)
    • Accepts an array of features to allow.
    • Feature names are from @mdn/browser-compat-data.
      • For example, if you want to use @supports at-rules, pass at-rules.supports.
  • allow.flagged (boolean, optional)
    • Allows features that are available when the browser's feature flags is enabled.
    • false by default
  • allow.partialImplementation (boolean, optional)
    • Allows features that are partial implementations.
    • false by default
  • allow.prefix (boolean, optional)
    • Allows features with vendor prefix.
    • true by default

Contributing

PRs accepted.

License

MIT (c) 3846masa

stylelint-browser-compat's People

Contributors

3846masa avatar renovate[bot] avatar semantic-release-bot 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

Watchers

 avatar  avatar

stylelint-browser-compat's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Status Checks

These updates await pending status checks. To force their creation now, click the checkbox below.

  • chore(npm): update dependency stylelint to v16.9.0
  • chore(npm): update pnpm to v9.9.0

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/default.yml
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • pnpm/action-setup v4.0.0@fe02b34f77f8bc703788d5817da081398fad5dd2
  • actions/setup-node v4.0.3@1e60f620b9541d16bece96c5465dc8ee9832be0b
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • pnpm/action-setup v4.0.0@fe02b34f77f8bc703788d5817da081398fad5dd2
  • actions/setup-node v4.0.3@1e60f620b9541d16bece96c5465dc8ee9832be0b
  • actions/github-script v7.0.1@60a0d83039c74a4aee543508d2ffcb1c3799cdea
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • pnpm/action-setup v4.0.0@fe02b34f77f8bc703788d5817da081398fad5dd2
  • actions/setup-node v4.0.3@1e60f620b9541d16bece96c5465dc8ee9832be0b
.github/workflows/stale.yml
  • actions/stale v9.0.0@28ca1036281a5e5922ead5184a1bbf96e5fc984e
nodenv
.node-version
  • node 18.20.4
npm
package.json
  • @mdn/browser-compat-data 5.5.31
  • array.prototype.at 1.1.3
  • lodash.get 4.4.2
  • postcss-media-query-parser 0.2.3
  • postcss-selector-parser 6.1.2
  • postcss-value-parser 4.2.0
  • semver 7.6.3
  • string.prototype.at 1.0.6
  • ts-results 3.3.0
  • zod 3.23.8
  • @3846masa/configs 1680811faae257796efe99b055aee5072cac6577
  • @babel/cli 7.24.8
  • @babel/core 7.25.2
  • @babel/preset-env 7.25.4
  • @babel/preset-typescript 7.24.7
  • @semantic-release/changelog 6.0.3
  • @semantic-release/commit-analyzer 9.0.2
  • @semantic-release/exec 6.0.3
  • @semantic-release/git 10.0.1
  • @semantic-release/npm 9.0.2
  • @semantic-release/release-notes-generator 10.0.3
  • @types/common-tags 1.8.4
  • @types/eslint 9.6.1
  • @types/fs-extra 11.0.4
  • @types/lodash.get 4.4.9
  • @types/semver 7.5.8
  • babel-jest 29.7.0
  • babel-plugin-module-resolver 5.0.2
  • babel-plugin-polyfill-es-shims 0.10.5
  • browserslist 4.23.3
  • common-tags 1.8.2
  • fs-extra 11.2.0
  • jest 29.7.0
  • jest-light-runner 0.6.0
  • jest-preset-stylelint 7.1.0
  • postcss 8.4.41
  • rimraf 5.0.10
  • semantic-release 19.0.5
  • stylelint 16.8.2
  • typescript 5.5.4
  • pnpm 9.8.0

  • Check this box to trigger a request for Renovate to run again on this repository

Add `repository` field to `package.json`

Hello @3846masa, πŸ‘‹πŸΌ

Thank you for creating the excellent package!

In this issue, I recommend adding the repository field to package.json. If added, npm view or npm repo will be much more helpful. For example:

$ npm view 'stylelint-browser-compat' repository

$ npm view 'stylelint' repository
{ type: 'git', url: 'git+https://github.com/stylelint/stylelint.git' }

$ npm repo --browser=false 'stylelint-browser-compat'
npm error no repository
npm error A complete log of this run can be found in: /Users/masafumi.koba/.npm/_logs/2024-07-12T02_52_40_138Z-debug-0.log

$ npm repo --browser=false 'stylelint'
stylelint repo available at the following URL:
https://github.com/stylelint/stylelint

It would be great if you could consider it. Thank you. πŸ˜ƒ

The automated release is failing 🚨

🚨 The automated release from the develop branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the develop branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two Factor Authentication for your account, set its level to "Authorization only" in your account settings. semantic-release cannot publish with the default "
Authorization and writes" level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

TypeError after v1.0.0-beta.122

After v1.0.0-beta.122, we encounter the error below on running stylelint.

TypeError: Cannot read properties of undefined (reading '__compat')
    at /home/runner/work/web/web/node_modules/.pnpm/[email protected][email protected][email protected][email protected]_/node_modules/stylelint-browser-compat/lib/rule.js:56:19
    at async Promise.all (index 0)

I think this change may affects.
820c73f#diff-0ceba63778a81ad3c2b980db18fb8c18cb54fb02b1f892290608b7eaa5fbb177

Environment

  • Node.js 20.12.2
  • pnpm 9.1.3
  • stylelint 16.6.1

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.