Environment details
- OS: Windows
- Package version: 2.0.0-beta.4
Steps to reproduce
-
Create a configuration file in the project root:
# See https://linter.aip.dev/configuration and https://linter.aip.dev/rules/
---
- included_paths:
- '**/*.proto'
disabled_rules:
- 'all'
enabled_rules:
- 'core::0191::proto-package'
- included_paths:
- '**/third_party/**'
disabled_rules:
- 'all'
-
Create a file .\third_party\google\type\phone_number.proto in the project. The file contents is a copy of https://github.com/googleapis/googleapis/blob/9070e63a1f574261c153ef6e94afc55677200337/google/type/phone_number.proto
-
Run the console command
api-linter-newest --config .api-linter.yaml --proto-path=third_party .\third_party\google\type\phone_number.proto
This returns an error:
- file_path: .\third_party\google\type\phone_number.proto
problems:
- message: 'Proto package and directory structure mismatch: The proto package must match the proto directory structure.'
location:
start_position:
line_number: 17
column_number: 1
end_position:
line_number: 17
column_number: 20
path: .\third_party\google\type\phone_number.proto
rule_id: core::0191::proto-package
rule_doc_uri: https://linter.aip.dev/191/proto-package
however, the rule core::0191::proto-package should be disabled for .\third_party\google\type\phone_number.proto.
This isn't reproduced via WSL + Ubuntu.
Use case details
The problem appears insignificant when using plain CLI with just a couple of .proto to lint.
However, it's more important in CI/CD scenarios. When you run api-linter in CI/CD for a pull request, it can have a lot of changed files. As I see from #1480 and https://linter.aip.dev/ currently there's no way to specify a directory or glob pattern as a linting target. We don't have full control over third_party files, so it's handy to disable all rules for this directory.
I understand that filtering files to lint is a workaround. Windows is also less commonly used in CI/CD. But having it covered via the config file is convenient.
Another use case is IDE. api-linter has plugins for popular IDE's, like:
These plugins respect the config file and don't provide other way to exclude some files/directories from linting.
The main project rules don't necessary work for third_party files, so it's handy to turn off api-linter IDE diagnostics for this directory.
The abovementioned config file purposes
Just for better understanding of the context. The config makes the following:
- Freeze the rule set for the main project, so that new rules form newer
api-linter versions don't appear unexpectedly.
- Permanently disable all checks for
third_party because the files are just copied there and we don't modify them to comply with the main project's rules.
Environment details
Steps to reproduce
Create a configuration file in the project root:
Create a file
.\third_party\google\type\phone_number.protoin the project. The file contents is a copy of https://github.com/googleapis/googleapis/blob/9070e63a1f574261c153ef6e94afc55677200337/google/type/phone_number.protoRun the console command
This returns an error:
however, the rule
core::0191::proto-packageshould be disabled for.\third_party\google\type\phone_number.proto.This isn't reproduced via WSL + Ubuntu.
Use case details
The problem appears insignificant when using plain CLI with just a couple of
.prototo lint.However, it's more important in CI/CD scenarios. When you run
api-linterin CI/CD for a pull request, it can have a lot of changed files. As I see from #1480 and https://linter.aip.dev/ currently there's no way to specify a directory or glob pattern as a linting target. We don't have full control overthird_partyfiles, so it's handy to disable all rules for this directory.I understand that filtering files to lint is a workaround. Windows is also less commonly used in CI/CD. But having it covered via the config file is convenient.
Another use case is IDE.
api-linterhas plugins for popular IDE's, like:These plugins respect the config file and don't provide other way to exclude some files/directories from linting.
The main project rules don't necessary work for
third_partyfiles, so it's handy to turn offapi-linterIDE diagnostics for this directory.The abovementioned config file purposes
Just for better understanding of the context. The config makes the following:
api-linterversions don't appear unexpectedly.third_partybecause the files are just copied there and we don't modify them to comply with the main project's rules.