@@ -4,38 +4,101 @@ module.exports = {
44 node : true ,
55 } ,
66 extends : [ 'prettier' , 'eslint:recommended' ] ,
7- plugins : [ 'sentry-sdk' ] ,
7+ plugins : [ 'sentry-sdk' , 'jsdoc' ] ,
8+ ignorePatterns : [ 'eslint-plugin-sentry-sdk' ] ,
89 overrides : [
910 {
11+ // Configuration for JavaScript files
1012 files : [ '*.js' ] ,
1113 rules : {
1214 'no-unused-vars' : [ 'error' , { argsIgnorePattern : '^_' } ] ,
1315 } ,
1416 } ,
1517 {
16- files : [ '*.ts' ] ,
18+ // Configuration for typescript files
19+ files : [ '*.ts' , '*.tsx' ] ,
1720 extends : [ 'plugin:@typescript-eslint/recommended' , 'prettier/@typescript-eslint' ] ,
1821 plugins : [ '@typescript-eslint' ] ,
1922 parser : '@typescript-eslint/parser' ,
2023 rules : {
24+ // We want to prevent async await usage in our files to prevent uncessary bundle size.
2125 'sentry-sdk/no-async-await' : 'error' ,
26+
2227 // Make sure variables marked with _ are ignored (ex. _varName)
2328 '@typescript-eslint/no-unused-vars' : [ 'warn' , { argsIgnorePattern : '^_' } ] ,
29+
30+ // Make sure that all ts-ignore comments are given a description
31+ '@typescript-eslint/ban-ts-comment' : [
32+ 'warn' ,
33+ {
34+ 'ts-ignore' : 'allow-with-description' ,
35+ } ,
36+ ] ,
37+
38+ // Types usage should be explicit as possible, so we prevent usage of inferrable types.
39+ // This is especially important because we have a public API, so usage needs to be as
40+ // easy to understand as possible
41+ '@typescript-eslint/no-inferrable-types' : 'off' ,
42+
43+ // Enforce type annotations to maintain consistency. This is especially important as
44+ // we have a public API, so we want changes to be very explicit.
45+ '@typescript-eslint/typedef' : [ 'error' , { arrowParameter : false } ] ,
46+ '@typescript-eslint/explicit-function-return-type' : 'error' ,
47+
48+ // Consistent ordering of fields, methods and constructors for classes should be enforced
49+ '@typescript-eslint/member-ordering' : 'error' ,
50+
51+ // Private and protected members of a class should be prefixed with a leading underscore
52+ '@typescript-eslint/naming-convention' : [
53+ 'error' ,
54+ {
55+ selector : 'memberLike' ,
56+ modifiers : [ 'private' ] ,
57+ format : [ 'camelCase' ] ,
58+ leadingUnderscore : 'require' ,
59+ } ,
60+ {
61+ selector : 'memberLike' ,
62+ modifiers : [ 'protected' ] ,
63+ format : [ 'camelCase' ] ,
64+ leadingUnderscore : 'require' ,
65+ } ,
66+ ] ,
67+
68+ // JSDOC comments are required for classes and methods
69+ 'jsdoc/require-jsdoc' : [
70+ 'error' ,
71+ { require : { ClassDeclaration : true , MethodDefinition : true } , checkConstructors : false } ,
72+ ] ,
2473 } ,
2574 } ,
2675 {
76+ // Configuration for test files
2777 env : {
2878 jest : true ,
2979 } ,
30- files : [ '*.test.ts' ] ,
80+ files : [ '*.test.ts' , '*.test.tsx' , '*.test.js' , '*.test.jsx' ] ,
81+ rules : {
82+ 'sentry-sdk/no-async-await' : 'off' ,
83+ 'jsdoc/require-jsdoc' : 'off' ,
84+ } ,
3185 } ,
3286 {
87+ // Configuration for config files like webpack/rollback
3388 files : [ '*.config.js' ] ,
3489 parserOptions : {
3590 sourceType : 'module' ,
3691 ecmaVersion : 2018 ,
3792 } ,
3893 } ,
3994 ] ,
40- rules : { } ,
95+
96+ rules : {
97+ // We want to prevent usage of unary operators outside of for loops
98+ 'no-plusplus' : [ 'error' , { allowForLoopAfterthoughts : true } ] ,
99+
100+ // disallow usage of console and alert
101+ 'no-console' : 'error' ,
102+ 'no-alert' : 'error' ,
103+ } ,
41104} ;
0 commit comments