github.com/googleapis/api-linter@v1.65.2/docs/configuration.md (about) 1 # Configuration 2 3 The linter contains a list of core rules, and by default, they are all enabled. 4 However, one can disable a rule by using a CLI flag, a configuration file or the file 5 comments. 6 7 ## CLI flag 8 9 We can disable a rule using the `-disable_rule` flag. 10 11 Example: 12 13 Disable the rule `core::0140::lower-snake`: 14 15 ```sh 16 api-linter -disable_rule core::0140::lower-snake test.proto 17 ``` 18 19 To disable multiple rules, specify the flag multiple times respectively: 20 21 ```sh 22 api-linter -disable_rule core::0140::lower-snake -disable_rule core::0131::request-name-field test.proto 23 ``` 24 25 ## Configuration file 26 27 The linter accepts a configuration file using the `-config` CLI switch. 28 29 Examples: 30 31 Disable the rule `core::0140::lower-snake` for any proto files under the 32 directory `tests` using a JSON config file: 33 34 ```json 35 [ 36 { 37 "included_paths": ["tests/**/*.proto"], 38 "disabled_rules": ["core::0140::lower-snake"] 39 } 40 ] 41 ``` 42 43 Disable the same rule using a YAML config file: 44 45 ```yaml 46 --- 47 - included_paths: 48 - 'tests/**/*.proto' 49 disabled_rules: 50 - 'core::0140::lower-snake' 51 ``` 52 53 ## Proto comments 54 55 Examples: 56 57 Disable the rule `core::0140::lower-snake` for the entire file: 58 59 ```proto 60 // A file comment: 61 // (-- api-linter: core::0140::lower-snake=disabled --) 62 // 63 // The above comment will disable the rule 64 // `core::0140::lower-snake` for the entire file. 65 66 syntax = "proto3"; 67 68 package google.api.linter.examples; 69 70 message Example { 71 string badFieldName = 1; 72 string anotherBadFieldName = 2; 73 } 74 ``` 75 76 Disable the same rule only for a field by using a leading comment: 77 78 ```protobuf 79 syntax = "proto3"; 80 81 package google.api.linter.examples; 82 83 message Example { 84 // This field will trigger a lint error. 85 string badFieldName = 1; 86 87 // This field will not trigger a lint error. 88 // (-- api-linter: core::0140::lower-snake=disabled --) 89 string anotherBadFieldName = 2; 90 } 91 ```