0.0.0 • Published 5 years ago
eslint-plugin-nativescript v0.0.0
NativeScript ESLint Rules
This project contains ESLint rules useful for NativeScript projects.
TypeScript Project Setup
- Install the necessary dependencies:
npm i -D eslint-plugin-nativescript @typescript-eslint/parser eslint
- Add an
.eslintrc
config file:
.eslintrc
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module"
},
"plugins": ["nativescript"],
"rules": {
"nativescript/no-short-imports": "error"
}
}
- 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
- Fix all auto-fixable problems:
npx eslint --ext=ts --fix src/
- 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
- Install the necessary dependencies:
npm i -D eslint-plugin-nativescript eslint
- Add an
.eslintrc
config file:
.eslintrc
{
"parserOptions": {
"ecmaVersion": 2015
},
"plugins": ["nativescript"],
"rules": {
"nativescript/no-short-imports": "error"
}
}
- 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
- Fix all auto-fixable problems:
npx eslint --fix app/
- 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"
}
]
0.0.0
5 years ago