forked from CMU-313/fall23-nodebb-op
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
70 lines (63 loc) · 2.06 KB
/
.eslintrc.cjs
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const fs = require('fs');
const path = require('path');
// Directories that contain TypeScript files of note
const tsDirs = [
"public/src",
"src",
"test",
];
// Helper walk function to check all directories
function walk(dir) {
var results = [];
var list = fs.readdirSync(dir);
list.forEach(function(file) {
file = dir + '/' + file;
var stat = fs.statSync(file);
if (stat && stat.isDirectory()) {
results = results.concat(walk(file));
} else {
results.push(file);
}
});
return results;
}
// Find all JS files that were compiled from TS
function find_compiled_js() {
let jsFilesList = [];
tsDirs.forEach(tsDir => {
let filesList = walk(tsDir);
const tsFilesList = filesList.filter((file) => path.extname(file).toLowerCase() === '.ts');
jsFilesList = jsFilesList.concat(filesList.filter(
(file) => path.extname(file).toLowerCase() === '.js' &&
tsFilesList.find(tsFile => tsFile === (file.replace(/\.[^/.]+$/, "") + ".ts")) !== undefined));
});
if (jsFilesList.length == 0) return "";
return jsFilesList;
}
module.exports = {
extends: ["nodebb"],
root: true,
ignorePatterns: find_compiled_js(),
rules: {
"indent": ["error", 4]
},
overrides: [
{
files: ["**/*.ts", "**/*.tsx"],
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
parserOptions: {
ecmaFeatures: { jsx: true },
project: "./tsconfig.json"
},
rules: {
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
}
}
]
};