Skip to content

Commit

Permalink
Add ESLint support
Browse files Browse the repository at this point in the history
  • Loading branch information
dandv committed Feb 8, 2020
1 parent 2b972e6 commit f816fe6
Show file tree
Hide file tree
Showing 4 changed files with 1,117 additions and 3 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2019,
sourceType: 'module',
},
plugins: [
'@typescript-eslint',
],
env: {
node: true, // for `console`
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
],
};
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ const influx = new Influx.InfluxDB();

# Import your own modules without specifying an extension

Run Node with the `node --experimental-specifier-resolution=node` parameter:
When transpiling, [TypeScript won't generate an extension for you](https://github.com/microsoft/TypeScript/issues/16577). Run Node with the `node --experimental-specifier-resolution=node` parameter:

node --experimental-specifier-resolution=node run.js

Otherwise, [node mandates that you specify the extension](https://nodejs.org/api/esm.html#esm_mandatory_file_extensions) in the `import` statement.

# Run the resulting JavaScript code

Add `"type": "module"` to `package.json`, because [TypeScript can't generate files with the .mjs extension](https://github.com/microsoft/TypeScript/issues/18442#issuecomment-581738714).
Add `"type": "module"` to `package.json`, because [TypeScript can't generate files with the .mjs extension](https://github.com/microsoft/TypeScript/issues/18442#issuecomment-581738714).

# ESLint

To be able to run `eslint`, we must create an `.eslintrc.cjs` file, rather than a `.js` one. Then, install the required dependencies:

npm i -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser
Loading

0 comments on commit f816fe6

Please sign in to comment.