Skip to content

Commit d2907b4

Browse files
committed
feat(sdk): setup eslint and tsdoc parsing
1 parent 33c23e7 commit d2907b4

File tree

8 files changed

+720
-617
lines changed

8 files changed

+720
-617
lines changed

packages/thirdweb/.eslintrc.cjs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
module.exports = {
2+
extends: [
3+
"eslint:recommended",
4+
"plugin:@typescript-eslint/recommended",
5+
"plugin:storybook/recommended",
6+
],
7+
rules: {
8+
"react-compiler/react-compiler": "error",
9+
"no-restricted-syntax": [
10+
"warn",
11+
{
12+
selector: "CallExpression[callee.name='useEffect']",
13+
message:
14+
'Are you *sure* you need to use "useEffect" here? If you loading any async function prefer using "useQuery".',
15+
},
16+
{
17+
selector: "CallExpression[callee.name='createContext']",
18+
message:
19+
'Are you *sure* you need to use a "Context"? In almost all cases you should prefer passing props directly.',
20+
},
21+
{
22+
selector: "CallExpression[callee.name='defineChain']",
23+
message: "Use getCachedChain instead for all internal usage",
24+
},
25+
],
26+
"no-unused-vars": [
27+
"warn",
28+
{
29+
argsIgnorePattern: "^_",
30+
varsIgnorePattern: "^_",
31+
caughtErrorsIgnorePattern: "^_",
32+
destructuredArrayIgnorePattern: "^_",
33+
ignoreRestSiblings: true,
34+
args: "none", // Ignore variables used in type definitions
35+
},
36+
],
37+
"@typescript-eslint/no-unused-vars": ["off"], // Duplicate of no-unused-vars
38+
"react-compiler/react-compiler": "warn",
39+
"tsdoc/syntax": "warn",
40+
},
41+
parser: "@typescript-eslint/parser",
42+
plugins: ["@typescript-eslint", "react-compiler", "eslint-plugin-tsdoc"],
43+
parserOptions: {
44+
ecmaVersion: 2019,
45+
ecmaFeatures: {
46+
impliedStrict: true,
47+
jsx: true,
48+
},
49+
warnOnUnsupportedTypeScriptVersion: true,
50+
project: "./tsconfig.json",
51+
tsconfigRootDir: __dirname,
52+
},
53+
settings: {
54+
react: {
55+
createClass: "createReactClass",
56+
pragma: "React",
57+
version: "detect",
58+
},
59+
},
60+
overrides: [
61+
// Set all typescript-eslint rules to warning for now
62+
{
63+
files: ["*.ts", "*.tsx"],
64+
rules: Object.fromEntries(
65+
Object.entries(require("@typescript-eslint/eslint-plugin").rules).map(
66+
([ruleName, _rule]) => [`@typescript-eslint/${ruleName}`, "warn"],
67+
),
68+
),
69+
},
70+
// In test files, allow null assertions and anys and eslint is sometimes weird about the react-scope thing
71+
{
72+
files: ["*test.ts?(x)"],
73+
rules: {
74+
"@typescript-eslint/no-non-null-assertion": "off",
75+
"@typescript-eslint/no-explicit-any": "off",
76+
77+
"react/display-name": "off",
78+
},
79+
},
80+
// allow requires in non-transpiled JS files and logical key ordering in config files
81+
{
82+
files: [
83+
"babel-node.js",
84+
"*babel.config.js",
85+
"env.config.js",
86+
"next.config.js",
87+
"webpack.config.js",
88+
"packages/mobile-web/package-builder/**",
89+
],
90+
rules: {},
91+
},
92+
93+
// THIS NEEDS TO GO LAST!
94+
{
95+
files: ["*.ts", "*.js", "*.tsx", "*.jsx"],
96+
extends: ["biome"],
97+
},
98+
],
99+
env: {
100+
browser: true,
101+
node: true,
102+
},
103+
};

0 commit comments

Comments
 (0)