@@ -16,18 +16,21 @@ module.exports = {
1616 } ,
1717 {
1818 // Configuration for typescript files
19- files : [ '*.ts' , '*.tsx' ] ,
19+ files : [ '*.ts' , '*.tsx' , '*.d.ts' ] ,
2020 extends : [ 'plugin:@typescript-eslint/recommended' , 'prettier/@typescript-eslint' ] ,
2121 plugins : [ '@typescript-eslint' ] ,
2222 parser : '@typescript-eslint/parser' ,
23+ parserOptions : {
24+ project : './tsconfig.json' ,
25+ } ,
2326 rules : {
24- // We want to prevent async await usage in our files to prevent uncessary bundle size.
27+ // We want to prevent async await usage in our files to prevent uncessary bundle size. Turned off in tests.
2528 'sentry-sdk/no-async-await' : 'error' ,
2629
27- // Make sure variables marked with _ are ignored (ex. _varName)
30+ // Unused variables should be removed unless they are marked with and underscore (ex. _varName).
2831 '@typescript-eslint/no-unused-vars' : [ 'warn' , { argsIgnorePattern : '^_' } ] ,
2932
30- // Make sure that all ts-ignore comments are given a description
33+ // Make sure that all ts-ignore comments are given a description.
3134 '@typescript-eslint/ban-ts-comment' : [
3235 'warn' ,
3336 {
@@ -37,7 +40,7 @@ module.exports = {
3740
3841 // Types usage should be explicit as possible, so we prevent usage of inferrable types.
3942 // This is especially important because we have a public API, so usage needs to be as
40- // easy to understand as possible
43+ // easy to understand as possible.
4144 '@typescript-eslint/no-inferrable-types' : 'off' ,
4245
4346 // Enforce type annotations to maintain consistency. This is especially important as
@@ -48,6 +51,10 @@ module.exports = {
4851 // Consistent ordering of fields, methods and constructors for classes should be enforced
4952 '@typescript-eslint/member-ordering' : 'error' ,
5053
54+ // Enforce that unbound methods are called within an expected scope. As we frequently pass data between classes
55+ // in SDKs, we should make sure that we are correctly preserving class scope.
56+ '@typescript-eslint/unbound-method' : 'error' ,
57+
5158 // Private and protected members of a class should be prefixed with a leading underscore
5259 '@typescript-eslint/naming-convention' : [
5360 'error' ,
@@ -65,7 +72,8 @@ module.exports = {
6572 } ,
6673 ] ,
6774
68- // JSDOC comments are required for classes and methods
75+ // JSDOC comments are required for classes and methods. As we have a public facing codebase, documentation,
76+ // even if it may seems excessive at times, is important to emphasize. Turned off in tests.
6977 'jsdoc/require-jsdoc' : [
7078 'error' ,
7179 { require : { ClassDeclaration : true , MethodDefinition : true } , checkConstructors : false } ,
@@ -81,6 +89,7 @@ module.exports = {
8189 rules : {
8290 'sentry-sdk/no-async-await' : 'off' ,
8391 'jsdoc/require-jsdoc' : 'off' ,
92+ 'max-lines' : 'off' ,
8493 } ,
8594 } ,
8695 {
@@ -97,8 +106,19 @@ module.exports = {
97106 // We want to prevent usage of unary operators outside of for loops
98107 'no-plusplus' : [ 'error' , { allowForLoopAfterthoughts : true } ] ,
99108
100- // disallow usage of console and alert
109+ // Disallow usage of console and alert
101110 'no-console' : 'error' ,
102111 'no-alert' : 'error' ,
112+
113+ // Prevent reassignment of function parameters, but still allow object properties to be
114+ // reassigned. We want to enforce immutability when possible, but we shouldn't sacrifice
115+ // too much efficiency
116+ 'no-param-reassign' : [ 'error' , { props : false } ] ,
117+
118+ // Prefer use of template expression over string literal concatenation
119+ 'prefer-template' : 'error' ,
120+
121+ // Limit maximum file size to reduce complexity. Turned off in tests.
122+ 'max-lines' : 'error' ,
103123 } ,
104124} ;
0 commit comments