Skip to content

Commit 0978528

Browse files
authored
Merge pull request #152 from docsbydoxdox/feature/eslint
[feat] Added eslint config and npm test target.
2 parents 84bdbe8 + 3eeeb78 commit 0978528

File tree

41 files changed

+2051
-287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2051
-287
lines changed

package-lock.json

Lines changed: 1682 additions & 267 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/doxdox-cli/.eslintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"parser": "@typescript-eslint/parser",
6+
"plugins": ["@typescript-eslint"],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended"
11+
],
12+
"rules": {
13+
"@typescript-eslint/no-explicit-any": "error",
14+
"@typescript-eslint/no-unused-vars": "error",
15+
"no-warning-comments": ["warn", { "terms": ["todo"], "location": "start" }],
16+
"no-magic-numbers": [
17+
"error",
18+
{
19+
"ignore": [-1, 0, 1]
20+
}
21+
]
22+
}
23+
}

packages/doxdox-cli/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ coverage/
22

33
src/
44

5+
.eslintrc
6+
57
.prettierignore
68
.prettierrc
79

packages/doxdox-cli/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@
2626
"@types/jest": "27.4.1",
2727
"@types/node": "17.0.21",
2828
"@types/update-notifier": "5.1.0",
29+
"@typescript-eslint/eslint-plugin": "5.12.1",
30+
"@typescript-eslint/parser": "5.12.1",
31+
"eslint": "8.10.0",
2932
"jest": "27.5.1",
3033
"nodemon": "2.0.15",
3134
"ts-jest": "27.1.3",
3235
"typescript": "4.5.5"
3336
},
3437
"scripts": {
3538
"test": "NODE_OPTIONS=--experimental-vm-modules jest --runInBand --passWithNoTests",
36-
"build": "rm -rf dist/ && tsc && chmod +x ./dist/src/index.js"
39+
"build": "rm -rf dist/ && tsc && chmod +x ./dist/src/index.js",
40+
"lint": "eslint 'src/**/*.ts'"
3741
},
3842
"jest": {
3943
"collectCoverage": true,

packages/doxdox-core/.eslintrc

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"parser": "@typescript-eslint/parser",
6+
"plugins": ["@typescript-eslint"],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended"
11+
],
12+
"rules": {
13+
"@typescript-eslint/no-explicit-any": "error",
14+
"@typescript-eslint/no-unused-vars": "error",
15+
"no-warning-comments": ["warn", { "terms": ["todo"], "location": "start" }],
16+
"no-magic-numbers": [
17+
"error",
18+
{
19+
"ignore": [-1, 0, 1]
20+
}
21+
]
22+
}
23+
}

packages/doxdox-core/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ src/
44

55
.doxdoxignore
66

7+
.eslintrc
8+
79
.prettierignore
810
.prettierrc
911

packages/doxdox-core/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,17 @@
1111
"devDependencies": {
1212
"@types/jest": "27.4.1",
1313
"@types/node": "17.0.21",
14+
"@typescript-eslint/eslint-plugin": "5.12.1",
15+
"@typescript-eslint/parser": "5.12.1",
16+
"eslint": "8.10.0",
1417
"jest": "27.5.1",
1518
"ts-jest": "27.1.3",
1619
"typescript": "4.5.5"
1720
},
1821
"scripts": {
1922
"test": "NODE_OPTIONS=--experimental-vm-modules jest --runInBand --passWithNoTests",
20-
"build": "rm -rf dist/ && tsc"
23+
"build": "rm -rf dist/ && tsc",
24+
"lint": "eslint 'src/**/*.ts'"
2125
},
2226
"jest": {
2327
"collectCoverage": true,

packages/doxdox-core/src/loader.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const loadPluginFromPackagePath = async <T>(
2323
if (pkg.exports) {
2424
return await loadPluginFromFile(join(path, pkg.exports));
2525
}
26-
} catch (err: any) {
26+
} catch (err) {
2727
if (process.env.DEBUG) {
2828
console.error(err);
2929
}
@@ -49,7 +49,7 @@ export const loadPluginFromFile = async <T>(
4949
): Promise<T | null> => {
5050
try {
5151
return (await import(pathToFileURL(resolve(path)).href)).default;
52-
} catch (err: any) {
52+
} catch (err) {
5353
if (process.env.DEBUG) {
5454
console.error(err);
5555
}
@@ -104,7 +104,7 @@ export const loadPlugin = async <T>(
104104
join(directory, pathOrPackage.replace(prefixPattern, ''))
105105
);
106106
}
107-
} catch (err: any) {
107+
} catch (err) {
108108
if (process.env.DEBUG) {
109109
console.error(err);
110110
}

packages/doxdox-core/src/utils.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Package } from './types';
2323

2424
export const findFileInPath = async (
2525
input: string,
26-
fileName: string = 'package.json'
26+
fileName = 'package.json'
2727
): Promise<string | null> => {
2828
try {
2929
const inputDirectory = (await fs.stat(input)).isFile()
@@ -37,7 +37,7 @@ export const findFileInPath = async (
3737
if (fileStat.isFile()) {
3838
return filePath;
3939
}
40-
} catch (err: any) {
40+
} catch (err) {
4141
if (process.env.DEBUG) {
4242
console.error(err);
4343
}
@@ -57,7 +57,8 @@ export const findFileInPath = async (
5757

5858
export const findParentNodeModules = async (
5959
currentDirectory: string,
60-
maxDepth: number = 5
60+
// eslint-disable-next-line no-magic-numbers
61+
maxDepth = 5
6162
): Promise<string | null> => {
6263
if (maxDepth > 0) {
6364
try {
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"env": {
3+
"node": true
4+
},
5+
"parser": "@typescript-eslint/parser",
6+
"plugins": ["@typescript-eslint"],
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:@typescript-eslint/eslint-recommended",
10+
"plugin:@typescript-eslint/recommended"
11+
],
12+
"rules": {
13+
"@typescript-eslint/no-explicit-any": "error",
14+
"@typescript-eslint/no-unused-vars": "error",
15+
"no-warning-comments": ["warn", { "terms": ["todo"], "location": "start" }],
16+
"no-magic-numbers": [
17+
"error",
18+
{
19+
"ignore": [-1, 0, 1]
20+
}
21+
]
22+
}
23+
}

0 commit comments

Comments
 (0)