Giter Site home page Giter Site logo

primer / stylelint-config Goto Github PK

View Code? Open in Web Editor NEW
202.0 13.0 22.0 2.66 MB

Sharable stylelint config used by GitHub's CSS

Home Page: https://primer.style/css/tools/linting

License: MIT License

JavaScript 89.87% SCSS 10.13%
stylelint lint primer css config

stylelint-config's Introduction

Primer Stylelint Config

npm version

A sharable stylelint config object that enforces GitHub's CSS rules

Install

$ npm install --save --dev @primer/stylelint-config

Usage

Within your stylelint config object You can extend this configuration. This will serve as a base for your config, then you can make overrides in your own config object:

{
  "extends": ["@primer/stylelint-config"],
  "rules": { }
}

Documentation

Primer Stylelint Config extends the stylelint-config-standard configuration supplied by Stylelint, and makes modifications in /index.js.

Plugins

License

MIT ยฉ GitHub

stylelint-config's People

Contributors

binarymuse avatar broccolini avatar colebemis avatar dependabot[bot] avatar github-actions[bot] avatar greenkeeperio-bot avatar jonrohan avatar joshblack avatar jsoref avatar keithamus avatar koddsson avatar langermank avatar matissjanis avatar mdo avatar mrchrisw avatar nguyenmanh1507 avatar primer-css avatar shawnbot avatar simurai 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stylelint-config's Issues

Autofix for Node API

Hi.
I use Node Api.
I use the design from the documentation.

stylelint
  .lint({
    code: "a { color: pink; }",
    config: myConfig,
    formatter: "verbose"
  })
  .then(function () {
    /* .. */
  });

Is there a possibility that the corrected version of the file would also be the result of the execution of the verification code. ?

Separate properties groups with empty lines

Hi!

Day after day, after specification, we get new css properties.

Please, consider to add empty lines between groups of related properties on the orders rule to make the file easier to read.

Old css linters had this. We can use one of them as a starting point.

What do you think?

Thank you for your attention.

Break up primer/variables into separate rules

Right now the configuration object for the primer/variables rule is really big and unwieldy. Its monolithic nature also makes refactoring via stylelint --fix tricky, because not only do you have to drill your stylelint config's rules down to only primer/variables, but if you want to focus on one type of rule (margins and padding vs. borders, for instance), you have to disable all the other variable rules with something crazy like this.

So, I think there should be different stylelint-level rules for each "type" of variable or value. For instance:

  • primer/fg-color deals with text color and SVG fill properties
  • primer/bg-color deals with background-color (and the color component of background)
  • primer/borders deals with border-width, border-style, border-color, and maybe outline?
  • primer/whitespace deals with margin, padding, and spacer variables more generally
  • primer/box-shadow deals with (you guessed it) box-shadow
  • primer/typography deals with font-size, font-weight, line-height, and the respective font components

What do you think, @primer/ds-core ?

Require newline after comma

I think this style guide should require a newline after commas in value lists. For example,
This would be flagged:

.dp-4 {
  box-shadow:  0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

But this wouldn't:

.dp-4 {
  box-shadow:
    0 4px 5px 0 rgba(0, 0, 0, 0.14),
    0 1px 10px 0 rgba(0, 0, 0, 0.12),
    0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

This can be done by putting this in your stylelint config:

"rules": {
   "value-list-comma-newline-after": "always"
 },

I figure that if you do this for selectors, you should do this for value lists.

Empty line between blocks

Hi!

May you consider adding empty lines between line blocks? The list of properties is [sooooooooooo] long.

I can update the config and submit a pull request, if you agree.

Thank you!

Don't allow SCSS color variables

Problem

To enable color modes in Primer CSS, we are transitioning from SCSS variables for colors to CSS variables. Our stylelint config, however, still allows people to use SCSS color variables.

Do this

  • Update stylelint-config-primer to flag usages of SCSS color variables as errors and recommend an appropriate CSS variable alternative if one exists

Add primer/deprecations rule

This would use the deprecations data published with @primer/css as of 12.7.0 to determine if anyone is styling deprecated selectors (see primer/css#883 for more info).

I'm honestly not sure how useful this would be, but it might clue us in to major version upgrade issues without having to search bigger codebases for all of the deprecated class names.

@primer/css canary releases don't satisfy peer dependency

We currently have @primer/css listed as a peer dependency with the >=12 version specifier, which causes npm to bail when this package is installed alongside canary releases, which are always 0.0.0-{sha}. The version specifier is too specific because the first release of @primer/css (as opposed to primer) was 12.0.0, so this can be loosened to *.

Stylelint improvements for CSS modules

Just a list of some little improvements

  • Default config to CSS first, treat SCSS as overrides
  • Support for CSS in JS (React)
  • Upgrade stylelint to next major

Rules

  • Better support for CSS variables
  • Triage existing rules
  • Better mapping for color CSS variables to properties

Tasks

  • Rewite primer-borders
  • Rewrite box-shadows
  • Rewrite colors
  • Delete no-deprecated-colors
  • Add no deprecated variables
  • Delete no-experimental variables
  • Delete no-overrides
  • Delete no-scale-colors
  • Rewrite no-undefined-vars (research)
  • Delete no-unused-vars
  • Leave responsive-vars
  • Rewrite primer-spacing
  • Rewrite typography
  • Rewrite utilities

Unable to get variables.json from @primer/css. Replacements will need to be specified manually

for the command npx stylelint "src/**/*.css", over the:

package.json file

{
  "name": "demo",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "eslint": "npx eslint src/**/*.{js,jsx}",
    "eslint:fix": "npx eslint src/**/*.{js,jsx} --fix"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "eslint": "^6.8.0",
    "eslint-config-airbnb": "^18.1.0",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.20.0",
    "eslint-plugin-react-hooks": "^4.0.4",
    "stylelint": "^13.5.0",
    "stylelint-config-primer": "^9.0.0",
    "stylelint-config-standard": "^20.0.0"
  }
}

and the .stylelintrc.yml file

files:
  include:
  - 'src/index.css'
  - 'src/**/*.css'
  - 'public/**/*.css'
  ignore:
  - './src/assets/**'
  - './node_modules/**'
  - './docs/**'
  - './trash/**'

extends:
  - stylelint-config-primer

I get this on my console

Unable to get variables.json from @primer/css. Replacements will need to be specified manually.
Unable to get variables.json from @primer/css. Replacements will need to be specified manually.
Unable to get variables.json from @primer/css. Replacements will need to be specified manually.
Unable to get variables.json from @primer/css. Replacements will need to be specified manually.
Unable to get variables.json from @primer/css. Replacements will need to be specified manually.
Error: Cannot find module '@primer/css/dist/meta.json'
Require stack:

  • /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint-config-primer/plugins/lib/primer.js
  • /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint-config-primer/plugins/no-override.js
  • /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint/lib/augmentConfig.js
  • /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint/lib/createStylelint.js
  • /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint/lib/printConfig.js
  • /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint/lib/cli.js
  • /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint/bin/stylelint.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (/home/davincif/Documentos/projects/lab/react/demo/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at requirePrimerFile (/home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint-config-primer/plugins/lib/primer.js:23:10)
    at /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint-config-primer/plugins/no-override.js:25:22
    at /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint/lib/lintSource.js:209:6
    at Array.map ()
    at /home/davincif/Documentos/projects/lab/react/demo/node_modules/stylelint/lib/lintSource.js:208:18
    at Array.forEach ()

Am I doing something crazy or this is a bug?

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.