Skip to content

Commit 1f58d63

Browse files
committed
Configure eslint and make command for lint
1 parent 6f17241 commit 1f58d63

File tree

4 files changed

+3759
-4
lines changed

4 files changed

+3759
-4
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ brain-games:
44
node bin/brain-games.js
55
publish:
66
npm publish --dry-run
7+
lint:
8+
npx eslint .

eslint.config.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import globals from 'globals';
2+
3+
import path from 'path';
4+
import { fileURLToPath } from 'url';
5+
import { FlatCompat } from '@eslint/eslintrc';
6+
import pluginJs from '@eslint/js';
7+
import importPlugin from 'eslint-plugin-import';
8+
9+
// mimic CommonJS variables -- not needed if using CommonJS
10+
const __filename = fileURLToPath(import.meta.url);
11+
const __dirname = path.dirname(__filename);
12+
const compat = new FlatCompat({
13+
baseDirectory: __dirname,
14+
recommendedConfig: pluginJs.configs.recommended,
15+
});
16+
17+
export default [
18+
{
19+
languageOptions: {
20+
globals: {
21+
...globals.node,
22+
...globals.jest,
23+
},
24+
parserOptions: {
25+
// Eslint doesn't supply ecmaVersion in `parser.js` `context.parserOptions`
26+
// This is required to avoid ecmaVersion < 2015 error or 'import' / 'export' error
27+
ecmaVersion: 'latest',
28+
sourceType: 'module',
29+
},
30+
},
31+
plugins: { import: importPlugin },
32+
rules: {
33+
...importPlugin.configs.recommended.rules,
34+
},
35+
},
36+
...compat.extends('airbnb-base'),
37+
{
38+
rules: {
39+
'no-underscore-dangle': [
40+
'error',
41+
{
42+
allow: ['__filename', '__dirname'],
43+
},
44+
],
45+
'import/extensions': [
46+
'error',
47+
{
48+
js: 'always',
49+
},
50+
],
51+
'import/no-named-as-default': 'off',
52+
'import/no-named-as-default-member': 'off',
53+
'no-console': 'off',
54+
'import/no-extraneous-dependencies': 'off',
55+
},
56+
},
57+
];

0 commit comments

Comments
 (0)