I am currently exploring Deno as proof-of-concept, and I am trying to find suitable way to setup linting within the project.
Here is part of the eslint configuration that I am thinking of setting up, but I do understand that this can cause more problems due to the differences between Node.JS and Deno:
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
That being said, what are some of practices/methods to set up linting and formatting within Deno/ TypeScript projects?
I understand that deno lint is still a work in progress, and the lack of documentation is hindering me from adopting it at this moment.
JavaScript linters are tools that you can use to help you debug your code. They scan your scripts for common issues and errors, and give you back a report with line numbers that you can use to fix things. In addition to actual bugs and errors, they also check for subjective, stylistic preferences as well.
JSLint. First released by Douglas Crockford in 2002, JSLint is a reliable JavaScript linting tool that can process JSON text and JavaScript source code. It also comes ready with a configuration that, according to Crockford, follows the JS best practices.
A linter is a computer program that analyzes and checks source code. It flags programming errors, indentation errors, formatting errors, bugs, and suspicious constructs.
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code, with the goal of making code more consistent and avoiding bugs. In many ways, it is similar to JSLint and JSHint with a few exceptions: ESLint uses Espree for JavaScript parsing.
This is the eslint
config Deno uses, and works perfectly for std/
which uses Deno
.
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"createDefaultProgram": true
},
"plugins": ["@typescript-eslint"],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
],
"rules": {
"@typescript-eslint/array-type": ["error", { "default": "array-simple" }],
"@typescript-eslint/ban-ts-comment": ["off"],
"@typescript-eslint/explicit-member-accessibility": ["off"],
"@typescript-eslint/explicit-module-boundary-types": ["off"],
"@typescript-eslint/no-non-null-assertion": ["off"],
"@typescript-eslint/no-use-before-define": ["off"],
"@typescript-eslint/no-parameter-properties": ["off"],
"@typescript-eslint/no-unused-vars": [
"error",
{ "argsIgnorePattern": "^_", "varsIgnorePattern": "^_" }
],
"@typescript-eslint/ban-ts-ignore": ["off"],
"@typescript-eslint/no-empty-function": ["off"],
"no-return-await": "error",
"require-await": "error",
"no-async-promise-executor": "error"
},
"overrides": [
{
"files": ["*.js"],
"rules": {
"@typescript-eslint/explicit-function-return-type": ["off"]
}
},
{
"files": ["tools/node_*.js"],
"rules": {
"@typescript-eslint/no-var-requires": ["off"]
}
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With