Skip to content

Commit f816fe6

Browse files
committed
Add ESLint support
1 parent 2b972e6 commit f816fe6

File tree

4 files changed

+1117
-3
lines changed

4 files changed

+1117
-3
lines changed

.eslintrc.cjs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
ecmaVersion: 2019,
5+
sourceType: 'module',
6+
},
7+
plugins: [
8+
'@typescript-eslint',
9+
],
10+
env: {
11+
node: true, // for `console`
12+
},
13+
extends: [
14+
'eslint:recommended',
15+
'plugin:@typescript-eslint/recommended',
16+
],
17+
};

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,18 @@ const influx = new Influx.InfluxDB();
3535

3636
# Import your own modules without specifying an extension
3737

38-
Run Node with the `node --experimental-specifier-resolution=node` parameter:
38+
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:
3939

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

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

4444
# Run the resulting JavaScript code
4545

46-
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).
46+
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).
47+
48+
# ESLint
49+
50+
To be able to run `eslint`, we must create an `.eslintrc.cjs` file, rather than a `.js` one. Then, install the required dependencies:
51+
52+
npm i -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser

0 commit comments

Comments
 (0)