Giter VIP home page Giter VIP logo

lmc-eu / code-quality-tools Goto Github PK

View Code? Open in Web Editor NEW
16.0 8.0 0.0 1.94 MB

Monorepo with some frequently-used configurations we use on frontend projects ๐ŸŽจ

License: BSD 3-Clause "New" or "Revised" License

Makefile 3.25% JavaScript 90.66% Handlebars 3.36% Shell 2.72%
javascript frontend monorepo stylelint-config prettier-config commitlint-config browserslist-config conventional-changelog eslint graphql renovate-config jest textlint-config

code-quality-tools's Introduction

Code Quality Tools

Built with โค๏ธ at Alma Career

This monorepo contains shareable configurations for various coding-style/best practices/lint tools to make the configurations consistent across projects and provide easy setup mechanism.

Available Configurations

Tool Package Version
Browserslist @lmc-eu/browserslist-config @lmc-eu/browserslist-config
Commitlint @lmc-eu/commitlint-config @lmc-eu/commitlint-config
Conventional Changelog @lmc-eu/conventional-changelog-lmc-bitbucket @lmc-eu/conventional-changelog-lmc-bitbucket
Conventional Changelog @lmc-eu/conventional-changelog-lmc-github @lmc-eu/conventional-changelog-lmc-github
ESLint @lmc-eu/eslint-config-base @lmc-eu/eslint-config-base
ESLint @lmc-eu/eslint-config-graphql @lmc-eu/eslint-config-graphql
ESLint @lmc-eu/eslint-config-react @lmc-eu/eslint-config-react
ESLint @lmc-eu/eslint-config-jest @lmc-eu/eslint-config-jest
ESLint @lmc-eu/eslint-config-typescript @lmc-eu/eslint-config-typescript
Prettier @lmc-eu/prettier-config @lmc-eu/prettier-config
Renovate @lmc-eu/renovate-config @lmc-eu/renovate-config
Stylelint @lmc-eu/stylelint-config @lmc-eu/stylelint-config
Textlint @lmc-eu/textlint-rule-preset-lmc @lmc-eu/textlint-rule-preset-lmc

License

See the LICENSE file for information.

Credit

We got a lot of inspiration from similar project at STRV. Thank you very much โค๏ธ!

code-quality-tools's People

Contributors

adamkudrna avatar janicekt avatar literat avatar ondram avatar renovate-bot avatar renovate[bot] avatar vmilersky avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

code-quality-tools's Issues

Semantic release

Stylelint: Consider switching to a community-maintained config

Maintaining a custom config like this is not easy, especially in the long run.

How about moving to a community-maintained config?

Benefits

  1. Less time spent on dev stack, more time on coding.
  2. A well-tested config means less bugs and pitfalls in the config itself.
  3. Using something close to a community standard improves interoperability and helps new developers read and understand the code more quickly.

Proposal

A quick test in spirit-web resulted in this project-specific .stylelintrc config:

{
  "extends": [
    "stylelint-config-standard-scss",
    "@lmc-eu/stylelint-config/optional"
  ],
  "rules": {
    "indentation": 4,
    "selector-class-pattern": [
      "^lmc-([A-Z][a-zA-Z0-9]*)((--|__)[a-z0-9]+)*$",
      {
        "message": "Expected class selector to be in format `lmc-MyComponent__element`, `lmc-MyComponent--modifier`"
      }
    ]
  }
}

Violated rules were: indentation (we had 4 spaces instead of 2), string-quotes (single quotes were used instead of double quotes), scss/dollar-variable-empty-line-before (blank lines between Sass variable groups needed to be removed), and selector-class-pattern (kebab case against our SUIT CSS naming convention). I kept our indentation, specified custom selector-class-pattern, and gave in to the other rules. But anything may be changed the way we want it.

To be fair, more tests on larger code bases may be necessary to see a bigger picture.

Extending

If we need more strict rules, our config can be extended as we wish in the future. The point is that most of the settings will already be there.

EditorConfig

EditorConfig

We should be able to create a default template but since EditorConfig does not support any kind of module system it will probably be difficult to distribute this as a package and we will likely have to resort to just copying a pre-made file into projects via the aforementioned CLI tool.

Commitlint: unnecessary dependency on @lmc-eu/conventional-changelog-lmc-bitbucket

Commitlint-config has prod-dependency on @lmc-eu/conventional-changelog-lmc-bitbucket - see https://github.com/lmc-eu/code-quality-tools/blob/main/packages/commitlint-config/package.json#L26

Why is this needed? In https://github.com/lmc-eu/cookie-consent-manager we don't use @lmc-eu/conventional-changelog-lmc-bitbucket but @lmc-eu/conventional-changelog-lmc-github instead, but we still gets this (unused?) dependency installed.

Commitlint: Document commit scopes

When using commit lint, scopes on the beginning of each commit message are enforced. However, there is nowhere any documentation which scopes should be used and when.
There is only configuration file, but without further documentation. This is very bad experience for people without previous conventional commits knowledge.

There should be a clear documentation of the scopes, similarly as commitzen provide:
add-commit

(Or - we should preferably just use some common naming scheme, with slightest changes possible, and not invent our own.)

CLI tool

CLI tool

Create a CLI of some sorts to allow generating configuration for all the tools supported through this monorepo into a project. Currently, people have to manually install the packages and create the configs by hand.

Yeoman is a great candidate for this.

Stylelint vs. Prettier compatibility issue

Prettier prefers:

margin-bottom: tools.rem2em(
    tokens.$space-6,
    tools.rem2em(tokens.$heading-small-desktop)
);

Stylelint prefers:

margin-bottom: tools.rem2em(tokens.$space-6, tools.rem2em(tokens.$heading-small-desktop));

This does not work either:

margin-bottom:
    tools.rem2em(
        tokens.$space-6,
        tools.rem2em(tokens.$heading-small-desktop)
    );

Workaround: disable either Stylelint or Prettier for that line / code block.

It seems there might be a conflict of declaration-colon-space-after and declaration-colon-newline-after Stylelint rules.

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.