npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-roku

v1.5.3

Published

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

Downloads

1,172

Readme

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.