0.0.0 • Published 5 years ago

eslint-plugin-nativescript v0.0.0

Weekly downloads
51
License
Apache-2.0
Repository
-
Last release
5 years ago

NativeScript ESLint Rules

This project contains ESLint rules useful for NativeScript projects.

TypeScript Project Setup

  1. Install the necessary dependencies:
npm i -D eslint-plugin-nativescript @typescript-eslint/parser eslint
  1. Add an .eslintrc config file:

.eslintrc

{
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "sourceType": "module"
    },
    "plugins": ["nativescript"],
    "rules": {
        "nativescript/no-short-imports": "error"
    }
}
  1. Lint the project from the command line:
npx eslint --ext=ts src/

Notice that you need to provide the path to your source code. In the example above, that's src/. Change it to match your project

  1. Fix all auto-fixable problems:
npx eslint --ext=ts --fix src/
  1. Optional Set up VSCode to use eslint.
  • Install the dbaeumer.vscode-eslint extension.
  • Add the following to your settings.json file:
"eslint.validate": [
    {
          "autoFix": true,
          "language": "typescript"
    },
    {
          "autoFix": true,
          "language": "javascript"
    }
]

JavaScript Project Setup

  1. Install the necessary dependencies:
npm i -D eslint-plugin-nativescript eslint
  1. Add an .eslintrc config file:

.eslintrc

{
    "parserOptions": {
        "ecmaVersion": 2015
    },
    "plugins": ["nativescript"],
    "rules": {
        "nativescript/no-short-imports": "error"
    }
}
  1. Lint the project from the command line:
npx eslint app/

Notice that you need to provide the path to your source code. In the example above, that's app/. Change it to match your project

  1. Fix all auto-fixable problems:
npx eslint --fix app/
  1. Optional Set up VSCode to use eslint.
  • Install the dbaeumer.vscode-eslint extension.
  • Add the following to your settings.json file:
"eslint.validate": [
    {
        "autoFix": true,
        "language": "javascript"
    }
]