JSPM

@dazn/eslint-plugin-kopytko

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 153
  • Score
    100M100P100Q70498F
  • License MIT

Set of brightscript rules for eslint

Package Exports

  • @dazn/eslint-plugin-kopytko

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@dazn/eslint-plugin-kopytko) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Kopytko ESLint plugin

An ESLint plugin with a set of rules

Installation

  1. Install eslint peer dependency:
npm i eslint --save-dev
  1. Install eslint-plugin-kopytko:
npm i @dazn/eslint-plugin-kopytko --save-dev

Configuration

In .eslintrc:

{
  "extends": "plugin:@dazn/kopytko/recommended",
  "plugins": ["@dazn/kopytko"],
  "rules": {
    "@dazn/kopytko/dependencies-order": "error",
    "@dazn/kopytko/missing-trailing-comma": "error",
    "@dazn/kopytko/indent": ["error", 2],
  }
}

Rules

indent

Enforces consistent indentation of block, array and object expressions, and function declarations

Examples of incorrect code for this rule, set to 2 characters:

sub test()
  example = [
  1,
    2,
  ]
  if (1 = 1)
  superFunction({
    a: "a",
  b: "b",
      c: "c",
  })
  end if
end sub

  sub another()
  superFunction({})
  end sub

Examples of correct code for this rule, set to 2 characters:

sub test()
  example = [
    1,
    2,
  ]
  if (1 = 1)
    superFunction({
      a: "a",
      b: "b",
      c: "c",
    })
  end if
end sub

sub another()
  superFunction({})
end sub

missing-trailing-comma

Enforces a trailing comma after every property of multiline associative array

The --fix option on the command line can automatically fix some of the problems reported by this rule.

Examples of incorrect code for this rule:

test = {
  a: "a",
  b: "b"
}

Examples of correct code for this rule:

test = {
  a: "a",
  b: "b",
}

dependencies-order

A rule to use with Kopytko Packager 's importing mechanism and Kopytko Unit Testing Framework 's mocking mechanism.

Enforces a proper alphabetical and path-specific order of @import and @mock annotations:

  • @mock annotations have to be after all @import annotations
  • alphabetical order of paths
  • nested paths have to be declared after their root path

Examples of incorrect code for this rule:

' @mock /components/mocked-function.brs
' @import /components/nested/cool-function.brs
' @import /components/nested/another-function.brs
' @import /components/main-function.brs

Examples of correct code for this rule:

' @import /components/main-function.brs
' @import /components/nested/another-function.brs
' @import /components/nested/cool-function.brs
' @mock /components/mocked-function.brs

Recommendation

We recommend to use also eslint-plugin-roku rules