Skip to content

Commit beb0421

Browse files
authored
Merge pull request #2 from code4rena-dev/nlf/update-eslint-config
fix: sync eslint config with api v0
2 parents d911205 + 4d7b338 commit beb0421

File tree

3 files changed

+105
-5
lines changed

3 files changed

+105
-5
lines changed

.eslintrc.js

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,65 @@ module.exports = {
1616
"plugin:@typescript-eslint/strict",
1717
],
1818
rules: {
19-
semi: "off", // have to disable eslint's core semicolon rules before enabling typescript-eslint's
19+
// require semi-colons via @typescript-eslint
20+
semi: "off",
2021
"@typescript-eslint/semi": "error",
2122
"@typescript-eslint/member-delimiter-style": "error",
22-
quotes: ["error", "double", { "avoidEscape": true }],
23+
24+
// 2 space indentation, allow anything for switch statements and template strings
25+
indent: "off", // disable eslint's core indent rule
26+
"@typescript-eslint/indent": ["error", 2, {
27+
SwitchCase: 1,
28+
ignoredNodes: ["TemplateLiteral"],
29+
}],
30+
31+
// allow multiple spaces for comments after a line, property values, and variable declarations
32+
// these are here to allow for aligning blocks
33+
"no-multi-spaces": ["error", {
34+
ignoreEOLComments: true,
35+
exceptions: {
36+
Property: true,
37+
VariableDeclarator: true,
38+
},
39+
}],
40+
41+
// don't allow trailing spaces
42+
"no-trailing-spaces": "error",
43+
44+
// only allow whitespace before property access when chaining on new lines
45+
"no-whitespace-before-property": "error",
46+
47+
// require that dots for property access are on the same line as the property
48+
"dot-location": ["error", "property"],
49+
50+
// require no spaces around parens in function calls
51+
"func-call-spacing": "off",
52+
"@typescript-eslint/func-call-spacing": ["error", "never"],
53+
54+
// require double quotes, but avoid escaping
55+
quotes: "off",
56+
"@typescript-eslint/quotes": ["error", "double", {
57+
avoidEscape: true,
58+
allowTemplateLiterals: true,
59+
}],
60+
61+
// IIFE wrap -> (function foo() {})()
62+
"wrap-iife": ["error", "inside"],
63+
64+
// don't allow spaces before commas, require at least one after
65+
"comma-spacing": "off",
66+
"@typescript-eslint/comma-spacing": "error",
67+
68+
// require at least one space before and after keywords
69+
"keyword-spacing": "off",
70+
"@typescript-eslint/keyword-spacing": "error",
2371
},
2472
ignorePatterns,
2573
overrides: [{
2674
files: ["test/**/*"],
2775
rules: {
76+
// non-null assertions can be useful in tests where we've already asserted something
77+
// exists before attempting to assert its value
2878
"@typescript-eslint/no-non-null-assertion": "off",
2979
},
3080
}],

lib/content/eslintrc.js

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,65 @@ module.exports = {
1616
"plugin:@typescript-eslint/strict",
1717
],
1818
rules: {
19-
semi: "off", // have to disable eslint's core semicolon rules before enabling typescript-eslint's
19+
// require semi-colons via @typescript-eslint
20+
semi: "off",
2021
"@typescript-eslint/semi": "error",
2122
"@typescript-eslint/member-delimiter-style": "error",
22-
quotes: ["error", "double", { "avoidEscape": true }],
23+
24+
// 2 space indentation, allow anything for switch statements and template strings
25+
indent: "off", // disable eslint's core indent rule
26+
"@typescript-eslint/indent": ["error", 2, {
27+
SwitchCase: 1,
28+
ignoredNodes: ["TemplateLiteral"],
29+
}],
30+
31+
// allow multiple spaces for comments after a line, property values, and variable declarations
32+
// these are here to allow for aligning blocks
33+
"no-multi-spaces": ["error", {
34+
ignoreEOLComments: true,
35+
exceptions: {
36+
Property: true,
37+
VariableDeclarator: true,
38+
},
39+
}],
40+
41+
// don't allow trailing spaces
42+
"no-trailing-spaces": "error",
43+
44+
// only allow whitespace before property access when chaining on new lines
45+
"no-whitespace-before-property": "error",
46+
47+
// require that dots for property access are on the same line as the property
48+
"dot-location": ["error", "property"],
49+
50+
// require no spaces around parens in function calls
51+
"func-call-spacing": "off",
52+
"@typescript-eslint/func-call-spacing": ["error", "never"],
53+
54+
// require double quotes, but avoid escaping
55+
quotes: "off",
56+
"@typescript-eslint/quotes": ["error", "double", {
57+
avoidEscape: true,
58+
allowTemplateLiterals: true,
59+
}],
60+
61+
// IIFE wrap -> (function foo() {})()
62+
"wrap-iife": ["error", "inside"],
63+
64+
// don't allow spaces before commas, require at least one after
65+
"comma-spacing": "off",
66+
"@typescript-eslint/comma-spacing": "error",
67+
68+
// require at least one space before and after keywords
69+
"keyword-spacing": "off",
70+
"@typescript-eslint/keyword-spacing": "error",
2371
},
2472
ignorePatterns,
2573
overrides: [{
2674
files: ["test/**/*"],
2775
rules: {
76+
// non-null assertions can be useful in tests where we've already asserted something
77+
// exists before attempting to assert its value
2878
"@typescript-eslint/no-non-null-assertion": "off",
2979
},
3080
}],

lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { dirname, join } from "node:path";
22
import { readFileSync } from "node:fs";
33
import { readFile, rm } from "node:fs/promises";
44
import { copy, json, pkg, type Skeleton } from "code-skeleton";
5-
5+
66
const ownPkg = JSON.parse(
77
readFileSync(join(dirname(__dirname), "package.json"), { encoding: "utf8" })
88
) as { name: string; version: string };

0 commit comments

Comments
 (0)