diff --git a/linters/buildifier/test_data/buildifier_v7.3.1_basic_check.check.shot b/linters/buildifier/test_data/buildifier_v7.3.1_basic_check.check.shot new file mode 100644 index 000000000..51223c11c --- /dev/null +++ b/linters/buildifier/test_data/buildifier_v7.3.1_basic_check.check.shot @@ -0,0 +1,135 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP +// trunk-upgrade-validation:RELEASE + +exports[`Testing linter buildifier test basic_check 1`] = ` +{ + "issues": [ + { + "code": "module-docstring", + "column": "1", + "file": "test_data/basic.bzl", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/bazelbuild/buildtools/blob/main/WARNINGS.md#module-docstring", + "level": "LEVEL_HIGH", + "line": "1", + "linter": "buildifier", + "message": "The file has no module docstring. +A module docstring is a string literal (not a comment) which should be the first statement of a file (it may follow comment lines).", + "targetType": "starlark", + }, + { + "code": "load", + "column": "26", + "file": "test_data/basic.bzl", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/bazelbuild/buildtools/blob/main/WARNINGS.md#load", + "level": "LEVEL_HIGH", + "line": "1", + "linter": "buildifier", + "message": "Loaded symbol "a" is unused. Please remove it. +To disable the warning, add '@unused' in a comment. +If you want to re-export a symbol, use the following pattern: + + load(..., _a = "a", ...) + a = _a", + "targetType": "starlark", + }, + { + "code": "load", + "column": "26", + "file": "test_data/basic.bzl", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/bazelbuild/buildtools/blob/main/WARNINGS.md#load", + "level": "LEVEL_HIGH", + "line": "2", + "linter": "buildifier", + "message": "Loaded symbol "b" is unused. Please remove it. +To disable the warning, add '@unused' in a comment. +If you want to re-export a symbol, use the following pattern: + + load(..., _b = "b", ...) + b = _b", + "targetType": "starlark", + }, + ], + "lintActions": [ + { + "command": "fix", + "fileGroupName": "bazel-build", + "linter": "buildifier", + "paths": [ + "test_data/add_tables.BUILD", + ], + "verb": "TRUNK_VERB_FMT", + }, + { + "command": "fix", + "fileGroupName": "starlark", + "linter": "buildifier", + "paths": [ + "test_data/basic.bzl", + ], + "verb": "TRUNK_VERB_FMT", + }, + { + "command": "warn", + "fileGroupName": "bazel-build", + "linter": "buildifier", + "paths": [ + "test_data/add_tables.BUILD", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "warn", + "fileGroupName": "starlark", + "linter": "buildifier", + "paths": [ + "test_data/basic.bzl", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "warn", + "fileGroupName": "bazel-build", + "linter": "buildifier", + "paths": [ + "test_data/add_tables.BUILD", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "warn", + "fileGroupName": "starlark", + "linter": "buildifier", + "paths": [ + "test_data/basic.bzl", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + ], + "taskFailures": [], + "unformattedFiles": [ + { + "column": "1", + "file": "test_data/add_tables.BUILD", + "issueClass": "ISSUE_CLASS_UNFORMATTED", + "level": "LEVEL_HIGH", + "line": "1", + "linter": "buildifier", + "message": "Incorrect formatting, autoformat by running 'trunk fmt'", + }, + { + "column": "1", + "file": "test_data/basic.bzl", + "issueClass": "ISSUE_CLASS_UNFORMATTED", + "level": "LEVEL_HIGH", + "line": "1", + "linter": "buildifier", + "message": "Incorrect formatting, autoformat by running 'trunk fmt'", + }, + ], +} +`; diff --git a/linters/buildifier/test_data/buildifier_v7.3.1_no_config.test_data.add_tables.BUILD.fmt.shot b/linters/buildifier/test_data/buildifier_v7.3.1_no_config.test_data.add_tables.BUILD.fmt.shot new file mode 100644 index 000000000..54e82961f --- /dev/null +++ b/linters/buildifier/test_data/buildifier_v7.3.1_no_config.test_data.add_tables.BUILD.fmt.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP +// trunk-upgrade-validation:RELEASE + +exports[`Testing formatter buildifier test no_config 1`] = ` +"foo_macro( + fizz = [ + ":lib2", + ":lib1", + ], +) + +filegroup( + name = "files", + srcs = glob(["**"]), +) + +sh_library( + name = "lib1", + srcs = ["src1.sh"], +) + +sh_library( + name = "lib2", + srcs = ["src1.sh"], +) + +sh_binary( + name = "foo", + srcs = ["foo.sh"], + deps = [ + ":lib1", + ":lib2", + ], +) +" +`; diff --git a/linters/buildifier/test_data/buildifier_v7.3.1_no_config.test_data.basic.bzl.fmt.shot b/linters/buildifier/test_data/buildifier_v7.3.1_no_config.test_data.basic.bzl.fmt.shot new file mode 100644 index 000000000..0f9da3bb5 --- /dev/null +++ b/linters/buildifier/test_data/buildifier_v7.3.1_no_config.test_data.basic.bzl.fmt.shot @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP +// trunk-upgrade-validation:RELEASE + +exports[`Testing formatter buildifier test no_config 1`] = ` +"# Misformatted file +def eponymous_name(): + name = native.package_name() + + return name[name.rfind("/") + 1:] +" +`; diff --git a/linters/buildifier/test_data/buildifier_v7.3.1_with_config.test_data.add_tables.BUILD.fmt.shot b/linters/buildifier/test_data/buildifier_v7.3.1_with_config.test_data.add_tables.BUILD.fmt.shot new file mode 100644 index 000000000..e4ce11ada --- /dev/null +++ b/linters/buildifier/test_data/buildifier_v7.3.1_with_config.test_data.add_tables.BUILD.fmt.shot @@ -0,0 +1,36 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP +// trunk-upgrade-validation:RELEASE + +exports[`Testing formatter buildifier test with_config 1`] = ` +"foo_macro( + fizz = [ + ":lib1", + ":lib2", + ], +) + +filegroup( + name = "files", + srcs = glob(["**"]), +) + +sh_library( + name = "lib1", + srcs = ["src1.sh"], +) + +sh_library( + name = "lib2", + srcs = ["src1.sh"], +) + +sh_binary( + name = "foo", + srcs = ["foo.sh"], + deps = [ + ":lib1", + ":lib2", + ], +) +" +`; diff --git a/linters/pyright/test_data/pyright_v1.1.378_basic.check.shot b/linters/pyright/test_data/pyright_v1.1.378_basic.check.shot new file mode 100644 index 000000000..1d230608a --- /dev/null +++ b/linters/pyright/test_data/pyright_v1.1.378_basic.check.shot @@ -0,0 +1,226 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP +// trunk-upgrade-validation:RELEASE + +exports[`Testing linter pyright test basic 1`] = ` +{ + "issues": [ + { + "code": "reportAttributeAccessIssue", + "column": "57", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportAttributeAccessIssue", + "level": "LEVEL_HIGH", + "line": "1", + "linter": "pyright", + "message": ""Enum" is unknown import symbol", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "4", + "offset": "56", + }, + ], + "targetType": "python", + }, + { + "column": "13", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#", + "level": "LEVEL_LOW", + "line": "15", + "linter": "pyright", + "message": "Type of "a.x" is "int | str"", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "3", + "offset": "384", + }, + ], + "targetType": "python", + }, + { + "code": "reportAttributeAccessIssue", + "column": "3", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportAttributeAccessIssue", + "level": "LEVEL_HIGH", + "line": "18", + "linter": "pyright", + "message": "Cannot assign to attribute "x" for class "A" +  Expression of type "float" cannot be assigned to attribute "x" of class "A" +    Type "float" is not assignable to type "int | str" +      "float" is not assignable to "int" +      "float" is not assignable to "str"", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "1", + "offset": "462", + }, + ], + "targetType": "python", + }, + { + "code": "reportUndefinedVariable", + "column": "8", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUndefinedVariable", + "level": "LEVEL_HIGH", + "line": "24", + "linter": "pyright", + "message": ""ClassVar" is not defined", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "8", + "offset": "602", + }, + ], + "targetType": "python", + }, + { + "code": "reportAttributeAccessIssue", + "column": "9", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportAttributeAccessIssue", + "level": "LEVEL_HIGH", + "line": "31", + "linter": "pyright", + "message": "Cannot access attribute "z" for class "type[A]" +  Attribute "z" is unknown", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "1", + "offset": "742", + }, + ], + "targetType": "python", + }, + { + "code": "reportReturnType", + "column": "29", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportReturnType", + "level": "LEVEL_HIGH", + "line": "39", + "linter": "pyright", + "message": "Function with declared return type "bool" must return value on all code paths +  "None" is not assignable to "bool"", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "4", + "offset": "864", + }, + ], + "targetType": "python", + }, + { + "code": "reportReturnType", + "column": "12", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportReturnType", + "level": "LEVEL_HIGH", + "line": "5", + "linter": "pyright", + "message": "Type "int" is not assignable to return type "str" +  "int" is not assignable to "str"", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "1", + "offset": "105", + }, + ], + "targetType": "python", + }, + { + "column": "25", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#", + "level": "LEVEL_LOW", + "line": "51", + "linter": "pyright", + "message": "Type of "val" is "int"", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "3", + "offset": "1128", + }, + ], + "targetType": "python", + }, + { + "column": "39", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#", + "level": "LEVEL_LOW", + "line": "54", + "linter": "pyright", + "message": "Type of "val" is "int"", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "3", + "offset": "1244", + }, + ], + "targetType": "python", + }, + { + "code": "reportRedeclaration", + "column": "7", + "file": "test_data/basic.in.py", + "issueClass": "ISSUE_CLASS_EXISTING", + "issueUrl": "https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportRedeclaration", + "level": "LEVEL_HIGH", + "line": "7", + "linter": "pyright", + "message": "Class declaration "A" is obscured by a declaration of the same name", + "ranges": [ + { + "filePath": "test_data/basic.in.py", + "length": "1", + "offset": "183", + }, + ], + "targetType": "python", + }, + ], + "lintActions": [ + { + "command": "lint", + "fileGroupName": "python", + "linter": "pyright", + "paths": [ + "test_data/basic.in.py", + ], + "verb": "TRUNK_VERB_CHECK", + }, + { + "command": "lint", + "fileGroupName": "python", + "linter": "pyright", + "paths": [ + "test_data/basic.in.py", + ], + "upstream": true, + "verb": "TRUNK_VERB_CHECK", + }, + ], + "taskFailures": [], + "unformattedFiles": [], +} +`;