Skip to content

Commit 4a29e1b

Browse files
committed
Configure ESLint
1 parent b743af8 commit 4a29e1b

File tree

12 files changed

+893
-35
lines changed

12 files changed

+893
-35
lines changed

.eslintrc.cjs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// @ts-check
2+
3+
/** @type {import("eslint").Linter.Config} */
4+
const config = {
5+
extends: [
6+
"eslint:recommended",
7+
"plugin:@typescript-eslint/recommended",
8+
"plugin:node/recommended",
9+
"prettier",
10+
],
11+
plugins: ["@babel/development"],
12+
parser: "@typescript-eslint/parser",
13+
reportUnusedDisableDirectives: true,
14+
rules: {
15+
"@typescript-eslint/no-non-null-assertion": "off",
16+
"@typescript-eslint/no-unused-vars": [
17+
"warn",
18+
{
19+
varsIgnorePattern: "^_",
20+
argsIgnorePattern: "^_",
21+
caughtErrorsIgnorePattern: "^_",
22+
},
23+
],
24+
"no-constant-condition": [
25+
"error",
26+
{
27+
checkLoops: false,
28+
},
29+
],
30+
"node/no-unsupported-features/es-syntax": "off",
31+
// Specifying *.js for *.ts doesn't work now
32+
"node/no-missing-import": "off",
33+
// Disabling it until it skips type-only imports
34+
"node/no-unpublished-import": "off",
35+
// We target newer Node, so this is unnecessary
36+
"no-inner-declarations": "off",
37+
},
38+
overrides: [
39+
{
40+
files: ["src/**/*.ts"],
41+
extends: [
42+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
43+
],
44+
parserOptions: {
45+
project: ["./tsconfig.json"],
46+
tsconfigRootDir: __dirname,
47+
},
48+
},
49+
{
50+
files: ["*.test.ts"],
51+
extends: ["plugin:jest/recommended"],
52+
rules: {
53+
"node/no-unpublished-import": "off",
54+
},
55+
},
56+
],
57+
ignorePatterns: ["cjs/dist/**/*", "dist/**/*", "coverage/**/*"],
58+
};
59+
module.exports = config;

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
run: yarn test
2424
- name: Typecheck
2525
run: yarn tsc
26-
# - name: Lint
27-
# run: yarn lint --max-warnings 0
26+
- name: Lint
27+
run: yarn lint --max-warnings 0
2828
- name: Check formatting
2929
run: yarn fmt:check

.vim/coc-settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"workspace.workspaceFolderCheckCwd": false,
3-
"tsserver.tsdk": ".yarn/sdks/typescript/lib"
3+
"tsserver.tsdk": ".yarn/sdks/typescript/lib",
4+
"eslint.packageManager": "yarn",
5+
"eslint.nodePath": ".yarn/sdks"
46
}

.vscode/extensions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"recommendations": [
33
"arcanis.vscode-zipfs",
4-
"esbenp.prettier-vscode"
4+
"esbenp.prettier-vscode",
5+
"dbaeumer.vscode-eslint"
56
]
67
}

.yarn/sdks/eslint/bin/eslint.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.cjs";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = createRequire(absPnpApiPath);
11+
12+
if (existsSync(absPnpApiPath)) {
13+
if (!process.versions.pnp) {
14+
// Setup the environment to be able to require eslint/bin/eslint.js
15+
require(absPnpApiPath).setup();
16+
}
17+
}
18+
19+
// Defer to the real eslint/bin/eslint.js your application uses
20+
module.exports = absRequire(`eslint/bin/eslint.js`);

.yarn/sdks/eslint/lib/api.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env node
2+
3+
const {existsSync} = require(`fs`);
4+
const {createRequire} = require(`module`);
5+
const {resolve} = require(`path`);
6+
7+
const relPnpApiPath = "../../../../.pnp.cjs";
8+
9+
const absPnpApiPath = resolve(__dirname, relPnpApiPath);
10+
const absRequire = createRequire(absPnpApiPath);
11+
12+
if (existsSync(absPnpApiPath)) {
13+
if (!process.versions.pnp) {
14+
// Setup the environment to be able to require eslint
15+
require(absPnpApiPath).setup();
16+
}
17+
}
18+
19+
// Defer to the real eslint your application uses
20+
module.exports = absRequire(`eslint`);

.yarn/sdks/eslint/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "eslint",
3+
"version": "8.37.0-sdk",
4+
"main": "./lib/api.js",
5+
"type": "commonjs"
6+
}

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@
3737
"build:esm": "babel -x .ts -d dist src --ignore '**/*.test.ts'",
3838
"fmt": "prettier -w .",
3939
"fmt:check": "prettier -c .",
40+
"lint": "eslint .",
4041
"prepack": "$npm_execpath build",
4142
"test": "NODE_OPTIONS='--experimental-vm-modules' yarn jest"
4243
},
4344
"devDependencies": {
4445
"@babel/cli": "^7.21.0",
4546
"@babel/core": "^7.21.3",
47+
"@babel/eslint-plugin-development": "^7.19.1",
4648
"@babel/preset-env": "^7.20.2",
4749
"@babel/preset-typescript": "^7.21.0",
4850
"@babel/types": "^7.21.3",
@@ -51,8 +53,15 @@
5153
"@qnighy/dedent": "^0.1.1",
5254
"@types/babel__core": "^7.20.0",
5355
"@types/babel__traverse": "^7.18.3",
56+
"@types/node": "^18.15.11",
57+
"@typescript-eslint/eslint-plugin": "^5.57.0",
58+
"@typescript-eslint/parser": "^5.57.0",
5459
"@yarnpkg/sdks": "^3.0.0-rc.40",
5560
"babel-jest": "^29.5.0",
61+
"eslint": "^8.37.0",
62+
"eslint-config-prettier": "^8.8.0",
63+
"eslint-plugin-jest": "^27.2.1",
64+
"eslint-plugin-node": "^11.1.0",
5665
"jest": "^29.5.0",
5766
"prettier": "^2.8.7",
5867
"ts-jest-resolver": "^2.0.1",

src/analysis.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ function analyzeOuterCapturings(
225225
): Set<string> {
226226
const capturings = new Set<string>();
227227
function visitIdent(path: NodePath<Identifier | JSXIdentifier>) {
228-
path.getOuterBindingIdentifiers;
229228
const binding = path.scope.getBinding(path.node.name);
230229
if (!binding || binding.path.isAncestor(classPath)) {
231230
capturings.add(path.node.name);

src/analysis/class_fields.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export function analyzeClassFields(
270270
}
271271
constructor = itemPath as NodePath<ClassMethod>;
272272
} else {
273-
throw new AnalysisError(`Not implemented yet: ${kind}`);
273+
throw new AnalysisError(`Not implemented yet: ${kind as string}`);
274274
}
275275
} else if (isClassAccessorProperty(itemPath)) {
276276
throw new AnalysisError(`Not implemented yet: class accessor property`);

0 commit comments

Comments
 (0)