@jamtastic/directus-standardish

0.9.0 • Public • Published

Directus Code Standard ish

Shareable linting configuration for Directus extension projects. Designed to follow standards used in the official project with some potentially controversial caveats (ergo, "-ish"):

  1. No semi-colons 🫰1

  2. Tabs Spaces 😄1

  3. The following @typescript/* rules are re-enabled or changed2:

    • no-explicit-any
    • no-var-require
    • no-non-null-assertion is set to "warn" (planned to set to error)
    • ban-ts-comment
  4. Prettier print width is set to 100 since eslint will handle the absolute max width (lines of code really should not go past 100 characters, and especially not 120)

  5. Vue files have their <script> and <style> tags indented to match the <template> tags1

  6. Markdown prose no longer forcibly wraps (uses default value of "preserve") - use your editors wrap features as forced wrapping is error prone

  7. Addition of more rules that are currently undefined. They will be changed if the Directus project sets any of these rules.

Divider

Installation

Install the package in your Directus project:

$ npm install -D @jamtastic/directus-standardish

Configure your editor

Note: These instructions are VSCode specific.

Install the following extensions:

Add the following to your .vscode/settings.json file in your project:

{
  "stylelint.validate": ["css", "less", "postcss", "vue"],
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[vue]": {
    "editor.defaultFormatter": "octref.vetur"
  },
  "[json]": {
    "editor.defaultFormatter": "vscode.json-language-features"
  }
}

Divider

Usage

Note: This process is done automatically for new extensions in @jamtastic/directus when using the bunny new CLI command.

Add the following to your projects package.json file:

{
  "scripts": {
    "fix": "npm run fix:code && npm run fix:code && npm run fix:style",
    "fix:code": "eslint",
    "fix:format": "prettier",
    "fix:style": "stylelint **/*.{vue,css,scss,sass}",
    "lint": "npm run lint:code && npm run lint:code && npm run lint:style",
    "lint:code": "eslint",
    "lint:format": "prettier",
    "lint:style": "stylelint **/*.{vue,css,scss,sass}"
  },

  // ...

  "eslintConfig": {
    "extends": "@jamtastic/eslint-config-directus"
  },
  "prettier": "@jamtastic/directus-standardish/prettier",
  "stylelint": {
    "extends": "@jamtastic/directus-standardish/stylelint"
  }
}

Other options

Using package.json is the recommended way to use these config files however you may also extend the configuration by following the docs for each linting tool.

Stylelint (in a .stylelintrc file):

extends:
  - 'jamtastic/directus-standardish/stylelint'
rules: // your overrides here
  1. The primary contributor to this project is slightly dyslexic and these settings help them greatly. 2 3

  2. The Directus project already has these marked as for review and may eventually be the same as in this project anyway. Hopefully this is just getting ahead.

Package Sidebar

Install

npm i @jamtastic/directus-standardish

Weekly Downloads

1

Version

0.9.0

License

UNLICENSE

Unpacked Size

6.68 kB

Total Files

4

Last publish

Collaborators

  • binaryben