1.9.98 • Published 2 years ago

@scaleleap/utils v1.9.98

Weekly downloads
1,139
License
MIT
Repository
github
Last release
2 years ago

Scale Leap Utils

Glossary

  • Product: the project that consumes or uses various tools and utilities described below. In other words, it is the final consumer of these utilities.
  • SL Utils: this document describes the utils project that we are developing. It contains various tools and utilities for listing and formalizing Product Projects.
    • Example: a project containing shared ESLint configuration, a project containing commitlint reusable configuration.
  • Utility Package: An NPM package that provides functionality that we want to tap into.
    • Example: ESLint, stylelint
  • Monorepo: A single CVS repository containing multiple projects.
  • IDE: Code editor, in this case it is always VS Code.

Motivation

Initializing (starting) new JavaScript projects is tiring and time consuming. A lot of boilerplate needs to be created before a codebase can be ready for productive work.

Keeping existing projects updated is also challenging as dependencies get stale and they need to be maintained.

Goals

To create a single project (might be a monorepo) that contains useful tooling that helps with project initialization and upkeep.

This project (package(s)) would help to minimize boilerplate in the Product project.

Ideally, it should be as simple as:

$> npx some-tool-name project-name
$> code project-name

Where some-tool-name is an initializer tool that:

  • Creates a new project directory
  • Calls git setup (from git-extras) inside it
  • Scaffolds a project from a template

Non Goals

We do not want to create any new major tools from scratch, but rather rely on existing tooling from the NodeJS ecosystem. Creation of small helper scripts is ok.

Requirements

Most of the work that we do at Scale Leap is TypeScript based. Only some legacy projects rely on JavaScript (NodeJS). The focus of tooling should be primarily to support TypeScript workflows.

Configuration files should use .js extension (syntax), where possible. E.g. .eslint.js is preferred over .eslint.json, where it is possible. It is understood that not all Utility Packages will offer this option.

The Product should not depend directly on Utility Packages. Utility Packages should be self contained in the SL Utils package where possible. This might be also be achieved via shims in the Product project that links to, or otherwise calls the binary from the Utils package.

  • Good: "lint:js": "node_modules/@scaleleap/utils/.bin/eslint --ext .js ."
  • Bad: "lint:js": "eslint --ext .js ."

We don't want to create copies of configurations or setting files, if we can avoid it. It is better to just reference the config in SL Utils package insteaf, where possible.

  • Good: (config loaded from Utils package): commitlint --config node_modules/@scaleleap/utils/commitlint.config.js
  • Bad: (config loaded from Product project): commitlint --config ./commitlint.config.js

If it is not possible to not copy a config file, then the next best thing is to make a copy and require the contents of the file from the Utils package. E.g.

module.export = require('@scaleleap/utils/eslint-js')

Linters

All linters should be setup to run, where possible, for these use cases:

  • on git commits (via lint-staged and husky)
  • manually
    • npm run lint -- runs all linters in parallel via npm-run-all
    • or npm run lint:js or npm run lint:style -- for specific linters
  • IDE via extensions, either native support for the relevant linter, or via generic extension(s) that can run commands on-save automatically.

ESLint

Need to make sure that all plugins are compatible with each other and imported in the right order. This is pretty tricky and needs a good amount of attention.

Configs

  • TypeScript
    • typescript-eslint is expecting a 2.0 release which should be really good, so we should probably start with that right away. Can use GitHub repo as a dependency for now until the final NPM package gets released.
  • JavaScript
  • Vue
  • Nuxt
    • This project has their own eslint config bundled already, which we probably should use and extend as it might have some nuances. But if you think it is not needed, then we don't have to.

Plugins

  • eslint-config-airbnb (some rules will be overridden TBD)
  • eslint-plugin-prettier
    • printWidth: 120
    • semi: false
    • singleQuote: true
    • trailingComma: all
    • arrowParens: always
  • eslint-plugin-eslint-comments
  • eslint-plugin-import
  • eslint-plugin-jest
  • eslint-plugin-sonarjs
  • eslint-plugin-unicorn
  • eslint-plugin-vue-a11y (only for vue & nuxt configs)
  • eslint-plugin-sql (only for TypeScript and JavaScript configs)
  • eslint-plugin-graphql

Formatter

  • eslint-formatter-github (don't think this needs any implicit setup, just included as a dependency)

Rules

Exact rules are TBD.

stylelint

  • For now recommended styles are acceptable for now

markdownlint

  • Any default/recommended styles are acceptable for now

imagemin-lint-staged

  • Compress staged images before commit
  • Replaced with GitHub Actions.

commitlint

  • Setup to use Conventional Commit
    • Ideally without "scope" option
      • Good: feat: implements foo
      • Bad: feat(some-scope): implements foo

prettier-package-json

  • Standardizes package.json

lockfile-lint

  • Validates lockfiles to make sure they are not tampered with.

Utilities

Commitizen

  • Uses cz-customizable to customize the commit message prompts
    • Should set askForBreakingChangeFirst to true

husky

Set up Git hooks for various uses, such as commit message validation and npm install like in the example of ghooks.

IDE

Our primary editor is VS Code.

Extensions

Should provide a file with Workspace recommended extensions for all extensions that are required for the Utils to work with IDE.

Settings

Should provide VS Code settings with all of the required settings to make Utils work with the IDE.

Inspiration / Prior Art

The goal is to get to somethign similar to the following repos:

Idea Dump

  • Self contain all npm run scripts in the Utils package too
    • Just - MS package
1.9.98

2 years ago

1.9.97

2 years ago

1.9.96

2 years ago

1.9.95

2 years ago

1.9.94

2 years ago

1.9.93

2 years ago

1.9.92

2 years ago

1.9.91

2 years ago

1.9.90

2 years ago

1.9.89

2 years ago

1.9.88

2 years ago

1.9.87

2 years ago

1.9.86

2 years ago

1.9.85

2 years ago

1.9.84

2 years ago

1.9.83

2 years ago

1.9.82

2 years ago

1.9.81

2 years ago

1.9.80

2 years ago

1.9.79

3 years ago

1.9.78

3 years ago

1.9.77

3 years ago

1.9.76

3 years ago

1.9.75

3 years ago

1.9.74

3 years ago

1.9.73

3 years ago

1.9.72

3 years ago

1.9.71

3 years ago

1.9.69

3 years ago

1.9.70

3 years ago

1.9.68

3 years ago

1.9.67

3 years ago

1.9.66

3 years ago

1.9.65

3 years ago

1.9.64

3 years ago

1.9.63

3 years ago

1.9.62

3 years ago

1.9.61

3 years ago

1.9.60

3 years ago

1.9.59

3 years ago

1.9.58

3 years ago

1.9.57

3 years ago

1.9.56

3 years ago

1.9.55

3 years ago

1.9.54

3 years ago

1.9.53

3 years ago

1.9.52

3 years ago

1.9.51

3 years ago

1.9.50

3 years ago

1.9.49

3 years ago

1.9.48

3 years ago

1.9.47

3 years ago

1.9.46

3 years ago

1.9.45

3 years ago

1.9.44

3 years ago

1.9.43

3 years ago

1.9.42

3 years ago

1.9.41

3 years ago

1.9.40

3 years ago

1.9.39

3 years ago

1.9.38

3 years ago

1.9.37

3 years ago

1.9.36

3 years ago

1.9.35

3 years ago

1.9.34

3 years ago

1.9.33

3 years ago

1.9.32

3 years ago

1.9.31

3 years ago

1.9.30

3 years ago

1.9.29

3 years ago

1.9.28

3 years ago

1.9.27

3 years ago

1.9.26

3 years ago

1.9.25

3 years ago

1.9.24

3 years ago

1.9.23

3 years ago

1.9.22

3 years ago

1.9.21

3 years ago

1.9.20

3 years ago

1.9.19

3 years ago

1.9.18

3 years ago

1.9.17

3 years ago

1.9.16

3 years ago

1.9.15

3 years ago

1.9.14

3 years ago

1.9.13

3 years ago

1.9.12

3 years ago

1.9.11

3 years ago

1.9.10

3 years ago

1.9.9

3 years ago

1.9.8

3 years ago

1.9.7

3 years ago

1.9.6

3 years ago

1.9.5

3 years ago

1.9.4

3 years ago

1.9.3

3 years ago

1.9.2

3 years ago

1.9.1

3 years ago

1.9.0

3 years ago

1.8.69

3 years ago

1.8.68

3 years ago

1.8.67

3 years ago

1.8.66

3 years ago

1.8.65

3 years ago

1.8.64

3 years ago

1.8.63

3 years ago

1.8.62

3 years ago

1.8.61

3 years ago

1.8.60

3 years ago

1.8.59

3 years ago

1.8.58

3 years ago

1.8.57

3 years ago

1.8.56

3 years ago

1.8.55

3 years ago

1.8.54

3 years ago

1.8.50

3 years ago

1.8.51

3 years ago

1.8.52

3 years ago

1.8.53

3 years ago

1.8.49

3 years ago

1.8.48

3 years ago

1.8.47

3 years ago

1.8.46

3 years ago

1.8.45

3 years ago

1.8.44

3 years ago

1.8.43

3 years ago

1.8.41

3 years ago

1.8.42

3 years ago

1.8.40

3 years ago

1.8.39

3 years ago

1.8.38

3 years ago

1.8.37

3 years ago

1.8.36

3 years ago

1.8.35

3 years ago

1.8.34

3 years ago

1.8.33

3 years ago

1.8.32

4 years ago

1.8.31

4 years ago

1.8.30

4 years ago

1.8.28

4 years ago

1.8.29

4 years ago

1.8.27

4 years ago

1.8.25

4 years ago

1.8.26

4 years ago

1.8.24

4 years ago

1.8.23

4 years ago

1.8.22

4 years ago

1.8.21

4 years ago

1.8.20

4 years ago

1.8.19

4 years ago

1.8.18

4 years ago

1.8.17

4 years ago

1.8.16

4 years ago

1.8.15

4 years ago

1.8.14

4 years ago

1.8.13

4 years ago

1.8.12

4 years ago

1.8.11

4 years ago

1.8.9

4 years ago

1.8.10

4 years ago

1.8.8

4 years ago

1.8.7

4 years ago

1.8.6

4 years ago

1.8.5

4 years ago

1.8.4

4 years ago

1.8.3

4 years ago

1.8.2

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

1.7.13

4 years ago

1.7.12

4 years ago

1.7.11

4 years ago

1.7.10

4 years ago

1.7.9

4 years ago

1.7.8

4 years ago

1.7.7

4 years ago

1.7.6

4 years ago

1.7.5

4 years ago

1.7.4

4 years ago

1.7.3

4 years ago

1.7.2

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.7.0-beta.1

4 years ago

1.6.12

4 years ago

1.6.11

4 years ago

1.6.10

4 years ago

1.6.9

4 years ago

1.6.8

4 years ago

1.6.7

4 years ago

1.6.6

4 years ago

1.6.4

4 years ago

1.6.5

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago