Giter Site home page Giter Site logo

eslint-brightscript's Introduction

ESLint Plugin BrightScript


Getting Started

Installation

Install eslint if you haven't already:

$ yarn add -D eslint
$ npm i --save-dev eslint

Then install the parser and plugin:

$ yarn add -D @hulu/eslint-parser-brightscript @hulu/eslint-plugin-brightscript
$ npm i --save-dev @hulu/eslint-parser-brightscript @hulu/eslint-plugin-brightscript

Usage

Add the following to your .eslintrc to use the recommended rules.

{
    "plugins": ["@hulu/eslint-plugin-brightscript"],
    "extends": ["plugin:@hulu/eslint-plugin-brightscript/recommended"]
}

You can also ignore the recommended config by including the @hulu/eslint-parser-brightscript parser and @hulu/eslint-plugin-brightscript plugin and adding specific rules manually:

{
  "parser": "@hulu/eslint-parser-brightscript",
  "plugins": ["@hulu/eslint-plugin-brightscript"],
  "rules": {
    "@hulu/brightscript/rule-name": "error"
  }
}

eslint-brightscript's People

Contributors

dependabot[bot] avatar heftyfunseeker avatar sjbarag avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

sjbarag

eslint-brightscript's Issues

Rule: `then-after-if`

Some codebases require the optional then keyword at the end of an if/else if statement's condition; others forbid it! Some even require it only for the single-line or only for the block variants of if. An eslint rule means humans don't need to watch for that sort of thing during code reviews!

Schema

Name: then-after-if
Options:

  • String (enum)
    • Values: "always" | "block-only" | "line-only" | "never"

Examples

Block if statements

if foo then
    print "bar"
end if
Option Allowed?
always โœ…
block-only โœ…
line-only ๐Ÿšซ
never ๐Ÿšซ
if foo
    print "bar"
end if
Option Allowed?
always ๐Ÿšซ
block-only ๐Ÿšซ
line-only โœ…
never โœ…

Line if statements

if foo then print "bar"
Option Allowed?
always โœ…
block-only ๐Ÿšซ
line-only โœ…
never ๐Ÿšซ
if foo print "bar"
Option Allowed?
always ๐Ÿšซ
block-only โœ…
line-only ๐Ÿšซ
never โœ…

Rule: `comment-style`

BrightScript comments start with ' or any capitalization of rem. Add a linter rule to ensure those are consistent.

Schema

Name: comment-style
Options:

  • String (enum)
    • Values: "'" | "rem" | "Rem" | "REM"

Note: Other capitalizations are intentionally not included here. I imagine very few people prefer to start comments with reM while also wanting that usage to be consistent.

Examples

' lorem ipsum
Option Allowed?
' โœ…
rem ๐Ÿšซ
Rem ๐Ÿšซ
REM ๐Ÿšซ
rem lorem ipsum
Option Allowed?
' ๐Ÿšซ
rem โœ…
Rem ๐Ÿšซ
REM ๐Ÿšซ
Rem lorem ipsum
Option Allowed?
' ๐Ÿšซ
rem ๐Ÿšซ
Rem โœ…
REM ๐Ÿšซ
REM lorem ipsum
Option Allowed?
' ๐Ÿšซ
rem ๐Ÿšซ
Rem ๐Ÿšซ
REM โœ…

Rule: `keyword-case`

Some people prefer keywords to be lowercase (sub main()). Others prefer uppercase (SUB main()), or title-case (Sub main()). Enforce those preferences with an eslint rule

Schema

Name: keyword-case
Options:

  • String (enum)
    • Values: "lower" | "title" | "upper"

Examples

if foo then
    print "bar"
end if
Option Allowed?
lower โœ…
title ๐Ÿšซ
upper ๐Ÿšซ
If foo Then
    Print "bar"
End If
Option Allowed?
lower ๐Ÿšซ
title โœ…
upper ๐Ÿšซ
IF foo THEN
    PRINT "bar"
END IF
Option Allowed?
lower ๐Ÿšซ
title ๐Ÿšซ
upper โœ…

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.