All Projects → RokuRoad → eslint-plugin-roku

RokuRoad / eslint-plugin-roku

Licence: MIT license
ESLint plugin to parse and lint BrightScript files

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
Brightscript
28 projects

Projects that are alternatives of or similar to eslint-plugin-roku

roku-libs
Compilation of utilities for Roku development
Stars: ✭ 47 (+6.82%)
Mutual labels:  roku, brightscript, roku-development
crash-course
This course is intended to quickly get you up to speed on Roku SceneGraph. It's aimed at an audience of developers who are familiar with streaming video applications but are unfamiliar with Roku.
Stars: ✭ 118 (+168.18%)
Mutual labels:  roku, brightscript, roku-development
lint-html-with-css
Lint HTML with CSS. A collection of CSS snippets from the hashtag #lintHTMLwithCSS on twitter. These CSS snippets intend to warn developers about common mistakes made in HTML.
Stars: ✭ 35 (-20.45%)
Mutual labels:  lint, linter
Husky.Net
Git hooks made easy with Husky.Net internal task runner! 🐶 It brings the dev-dependency concept to the .NET world!
Stars: ✭ 394 (+795.45%)
Mutual labels:  lint, linter
flexlint
A flexible linter with rules defined by regular expression
Stars: ✭ 19 (-56.82%)
Mutual labels:  lint, linter
Sql Lint
An SQL linter
Stars: ✭ 243 (+452.27%)
Mutual labels:  lint, linter
elm-lint
elm-lint lints Elm source code, to add additional guarantees to your project.
Stars: ✭ 27 (-38.64%)
Mutual labels:  lint, linter
nano-staged
Tiny tool to run commands for modified, staged, and committed files in a GIT repository.
Stars: ✭ 347 (+688.64%)
Mutual labels:  lint, linter
Whispers
Identify hardcoded secrets and dangerous behaviours
Stars: ✭ 66 (+50%)
Mutual labels:  lint, linter
npm-groovy-lint
Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files using command line
Stars: ✭ 124 (+181.82%)
Mutual labels:  lint, linter
lints
Lint all your JavaScript, CSS, HTML, Markdown and Dockerfiles with a single command
Stars: ✭ 14 (-68.18%)
Mutual labels:  lint, linter
ukor
A Roku build tool with support for build flavors
Stars: ✭ 45 (+2.27%)
Mutual labels:  roku, brightscript
Fsharplint
Lint tool for F#
Stars: ✭ 224 (+409.09%)
Mutual labels:  lint, linter
D Scanner
Swiss-army knife for D source code
Stars: ✭ 221 (+402.27%)
Mutual labels:  lint, linter
therapist
Work out your commitment issues.
Stars: ✭ 29 (-34.09%)
Mutual labels:  lint, linter
Protoc Gen Lint
A plug-in for Google's Protocol Buffers (protobufs) compiler to lint .proto files for style violations.
Stars: ✭ 221 (+402.27%)
Mutual labels:  lint, linter
yamburger
YAML syntax got you down? That's a YAMBURGER!
Stars: ✭ 32 (-27.27%)
Mutual labels:  lint, linter
Ue4 Style Guide
An attempt to make Unreal Engine 4 projects more consistent
Stars: ✭ 2,656 (+5936.36%)
Mutual labels:  lint, linter
Woke
✊ Detect non-inclusive language in your source code.
Stars: ✭ 190 (+331.82%)
Mutual labels:  lint, linter
actionlint
Static checker for GitHub Actions workflow files
Stars: ✭ 1,385 (+3047.73%)
Mutual labels:  lint, linter

npm version Downloads/month Build Status CircleCI Coverage Status Dependency Status Greenkeeper badge CodeFactor

The ESLint custom plugin with rules and parser for .brs files.

Sample Project

ESLint plugin for BrightScript

We going to skip the part why linting is important so you can read more about it at ESLint site. Primary motivation for this development is absence of reliable tools for Roku development (at least at the time this work started) and performance criteria.

Demo

Latest tests gave measurement of about 14 seconds for a 1000 files of BrightScript

This plugin provides parsing and linting tool for your Roku project. While ESLint rules for Javascript are not 1 to 1 replaceable you are able to quickly develop or translate any other rules to work with brightscript. It's written in typescript but could use any JS- technology you like

VSCode Integration

    "eslint.validate": [   {
        "language": "brightscript",
        "autoFix": false
    } ],
Linter Warnings

Warnings

Syntax Errors

Syntax

Disable rules with comments

? "this is a valid log" ' eslint-disable-line

or

' eslint-disable-next-line [rule]
? "this is a valid log"

note: whole file eslint-disable does not work as there is no block quote in brightscript

Installation

You'll first need to install ESLint:

With Yarn

yarn add --dev eslint

With npm

$ npm i eslint --save-dev

Next, install eslint-plugin-roku:

With Yarn

yarn add --dev eslint-plugin-roku

With npm

$ npm install eslint-plugin-roku --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-roku globally.

Configuration

{
  "extends": "plugin:roku/recommended",
  "rules": {
    "roku/no-print": "error",
    "roku/no-stop": "warn",
    "roku/sub-to-function": "warn",
    "roku/function-no-return": "warn",
    "roku/no-unused-params": "warn",
    "roku/function-no-return-type": "warn",
    "roku/function-name-camelcase": "warn",
    "roku/no-uninitialized-variables": "error",
    "roku/no-uninitialized-functions": "error",
  }
}

Plugin-Provided Rules

Just as any other project this one requires more feedback and linting rules ideas

Parsing and AST

This documentation will be available at https://github.com/RokuRoad/bright

Writing rules

https://eslint.org/docs/developer-guide/working-with-rules

Testing rules

Typical test for a rule will look like

Test runner and valid / invalid factories to wrap your test code into testable solution

import { invalidFactory, runTest, validFactory } from '../helpers'

Define name of your rule, it will be used to require it and run tests

const RULE_NAME = 'sub-to-function'

Provide prefix and suffix, so you can test function body or root element like library import of the function itself

const valid = validFactory(RULE_NAME, '', '')
const invalid = invalidFactory(RULE_NAME, '', '')

Define cases to match against. Invalid cases will provide error messages

runTest(RULE_NAME, {
  invalid: [
    [
      `sub a() as Dynamic
      end sub`,

      [ { message: 'Sub a should not have a return type (dynamic). Consider replacing it with Function' } ]
    ]
  ].map(invalid),
  valid: [
    `sub a()
      print a
     end sub
  `
  ].map(valid)
})

SceneGraph

Currently in development, check back soon. Rule will be aware of components tree structure so for instance if function is going to be overwritten or just mistakenly left empty.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].