10.0.0 • Published 2 months ago

@rimac-technology/style-guide v10.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Style Guide

This repository encapsulates all the different configurations we use at Rimac Technology when developing with JS

Firstly install the style guide @rimac-technology/style-guide and then pick the configurations you need:

Prettier

  1. Install prettier as a dev dependency

  2. Create a new file at the root of your project called .prettierrc.js with the following

module.exports = {
    ...require('@rimac-technology/style-guide/prettier'),
}
  1. Create a .prettierignore file with the following
CHANGELOG.md # If your project contains it
  1. Add a script to your package.json with prettier --loglevel warn --no-editorconfig --no-error-on-unmatched-pattern --check \"./**/*{yaml,yml,json,md,gql,graphql,prisma}\"

    • Adjust the glob to match files you want to check
    • This glob will match all the files recursively in your project
  2. Do a test run and see what prettier matches and add files you don't want to check in it since prettier still doesn't support having .gitignore and .prettierignore working together

Package JSON

  1. Install npm-package-json-lint as a dev dependency

  2. Create a new file at the root of your project called .packagerc.js with

    • If you are using workspaces
    module.exports = {
        extends: '@rimac-technology/style-guide/package-json/workspaces',
    }
    • If you are not using workspaces
    module.exports = {
        extends: '@rimac-technology/style-guide/package-json/core',
    }
  3. Add a script to your package.json with npmPkgJsonLint --configFile ./.packagerc.js .

ESLint

  1. Install eslint as a dev dependency

  2. Create a new file at the root of your project called .eslintrc.js with the following

    • Make sure parserOptions.project points to the correct tsconfig.json location
module.exports = {
    extends: [require.resolve('@rimac-technology/style-guide/eslint/core')],
    parser: '@typescript-eslint/parser',
    parserOptions: {
        project: './tsconfig.json',
    },
    ignorePatterns: ['**/*generated.json'],
}
  1. Add a script to your package.json with eslint './**/*.{js,ts}' --quiet --cache --cache-strategy content --cache-location '.eslintcache/'

    • Adjust the glob to match files your want to check
      • For example all ts, js and tsx files: ./**/*.${js,ts,tsx}
  2. You can use any of the optional rulesets

    • @rimac-technology/style-guide/eslint/react
    • @rimac-technology/style-guide/eslint/jest
    • @rimac-technology/style-guide/eslint/mobx
    • @rimac-technology/style-guide/eslint/next
      • You need to add a setting to point to your pages directory in .eslintrc.js config file like so
        module.exports = {
            // Other config stuff
            settings: {
                next: {
                    rootDir: './packages/web/',
                },
            },
            // Other config stuff
        }
    • Example configuration with overrides for only .test.ts files with jest ruleset
    module.exports = {
        extends: [require.resolve('@rimac-technology/style-guide/eslint/core')],
        parser: '@typescript-eslint/parser',
        parserOptions: {
            project: './tsconfig.json',
        },
        overrides: [
            {
                files: ['**/*.test.ts'],
                extends: [require.resolve('@rimac-technology/style-guide/eslint/jest')],
            },
        ],
    }
  3. Add eslint cache to .gitignore like so

.eslintcache

Stylelint

  1. Install stylelint as a dev dependency

  2. Create a new file at the root of your project called .stylelintrc.js with the following

module.exports = {
    extends: '@rimac-technology/style-guide/stylelint',
}
  1. Add a script to your package.json with stylelint --cache --allow-empty-input './**/*.css'

  2. Add stylelint cache to .gitignore like so

.stylelintcache

CSpell

  1. Install cspell as a dev dependency

  2. Create a new file at the root of your project called .cspell.json with the following

{
    "useGitignore": true,
    "cache": {
        "useCache": true,
        "cacheStrategy": "content",
        "cacheLocation": "./.cspellcache"
    },
    "ignorePaths": [
        // Add ignored paths/files here
    ],
    "ignoreWords": [
        // Add words here
    ]
}
  1. Add a script to your package.json with cspell --no-progress --no-summary '**'

  2. Add cspell cache to .gitignore like so

.cspellcache
10.0.0

2 months ago

9.3.0-beta.3

2 months ago

10.0.0-beta.1

2 months ago

9.3.0-beta.2

2 months ago

9.3.0-beta.1

2 months ago

9.2.1

5 months ago

8.1.0

9 months ago

9.1.1

8 months ago

9.1.0

8 months ago

9.1.3

7 months ago

9.1.2

7 months ago

8.0.3

10 months ago

8.0.2

10 months ago

9.2.0

6 months ago

9.0.0

9 months ago

8.0.1

12 months ago

8.0.0

12 months ago

6.1.0

1 year ago

6.1.1

1 year ago

7.0.0

1 year ago

5.0.0

1 year ago

6.0.0

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

3.0.0

1 year ago

4.0.1

1 year ago

4.0.0

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago