-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
44 lines (38 loc) · 1.04 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"use strict";
const path = require("path");
const fs = require("fs");
const getRules = require("./rules");
// This will take care of potential symlinks
const appDir = fs.realpathSync(process.cwd());
const isModuleProject = require(path.resolve(appDir, "package.json")).type === "module";
const hasES2022Support = parseInt(process.versions.node.split(".").shift(), 10) >= 16;
const moduleConfig = {
parserOptions: {
ecmaVersion: hasES2022Support ? 2022 : 2021,
sourceType: "module",
},
env: {
node: true,
...(hasES2022Support ? { es2022: true } : { es6: true }),
},
plugins: [ "eslint-plugin-n", "import", "@bonniernews/typescript-rules" ],
};
const commonjsConfig = {
parserOptions: { ecmaVersion: 2021 },
env: {
node: true,
es6: true,
},
plugins: [ "eslint-plugin-n", "@bonniernews/typescript-rules" ],
};
module.exports = {
ignorePatterns: [
"tmp/",
"public/",
"submodule/**",
"logs/",
"docs/",
],
...(isModuleProject ? moduleConfig : commonjsConfig),
rules: getRules(isModuleProject),
};