2022-01-03 19:36:51 +03:00
|
|
|
# Copyright (c) 2022 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
2020-01-21 16:39:54 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
load("@language_support_ts_deps//eslint:index.bzl", _eslint_test = "eslint_test")
|
2020-01-22 18:07:20 +03:00
|
|
|
load("@os_info//:os_info.bzl", "is_windows")
|
2020-01-21 16:39:54 +03:00
|
|
|
|
2020-04-01 14:41:35 +03:00
|
|
|
def eslint_test(name, srcs, tsconfig = ":tsconfig.json", eslintrc = ":.eslintrc.json", data = [], **kwargs):
|
2020-01-21 16:39:54 +03:00
|
|
|
"""Run eslint on the given typescript source.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name: The name of the generated test rule.
|
|
|
|
srcs: The source files to lint.
|
|
|
|
tsconfig: The tsconfig.json file.
|
2020-04-01 14:41:35 +03:00
|
|
|
eslintrc: The .eslintrc.json file.
|
2020-01-21 16:39:54 +03:00
|
|
|
data: Additional runtime dependencies.
|
|
|
|
"""
|
|
|
|
eslint_deps = [
|
|
|
|
"@language_support_ts_deps//@typescript-eslint",
|
2021-05-07 15:00:54 +03:00
|
|
|
"@language_support_ts_deps//@typescript-eslint/eslint-plugin",
|
2020-01-22 18:07:20 +03:00
|
|
|
] if not is_windows else []
|
2020-01-21 16:39:54 +03:00
|
|
|
templated_args = [
|
|
|
|
"--config",
|
2020-04-01 14:41:35 +03:00
|
|
|
"$(rlocation $(location %s))" % eslintrc,
|
|
|
|
"--parser-options",
|
Upgrade rules_nodejs to version 1.6.0 (#5539)
* Upgrade rules_nodejs to version 1.6.0
closes #5367
This includes the fixes for the issues in jest that we’ve been seeing.
changelog_begin
changelog_end
* Fix eslint rules
* A bit of progress
* Try to add LinkablePackageInfo (doesn’t seem to work yet)
* Add rootDirs
* revert da_ts_library
* da_ts_library: add LinkablePackageInfo info
* Remove react hook workaround
Since rules_nodejs 1.6.0 this fails with the following error:
```
● Test suite failed to run
Configuration error:
Could not locate module react mapped as:
/.../execroot/com_github_digital_asset_daml/bazel-out/k8-opt/bin/language-support/ts/daml-react/test.sh.runfiles/com_github_digital_asset_daml/node_modules/react/umd/react.development.js.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^react$/": "/.../execroot/com_github_digital_asset_daml/bazel-out/k8-opt/bin/language-support/ts/daml-react/test.sh.runfiles/com_github_digital_asset_daml/node_modules/react/umd/react.development.js"
},
"resolver": null
}
49 | // like a promis without being one.
50 | /* eslint-disable @typescript-eslint/no-floating-promises */
> 51 | var react_1 = __importStar(require("react"));
| ^
52 | var react_hooks_1 = require("@testing-library/react-hooks");
53 | var index_1 = __importStar(require("./index"));
54 | var events_1 = require("events");
at createNoMappedModuleFoundError (../../../../../../../../../../../node_modules/jest-resolve/build/index.js:501:17)
at Object.<anonymous> (index.test.js:51:28)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 1.88s
Ran all test suites within paths "language-support/ts/daml-react/DamlLedger.d.ts", "language-support/ts/daml-react/DamlLedger.js", "language-support/ts/daml-react/context.d.ts", "language-support/ts/daml-react/context.js", "language-support/ts/daml-react/hooks.d.ts", "language-support/ts/daml-react/hooks.js", "language-support/ts/daml-react/index.d.ts", "language-support/ts/daml-react/index.js", "language-support/ts/daml-react/index.test.d.ts", "language-support/ts/daml-react/index.test.js".
=
```
* rootDirs is not needed for tsc
This is only required for ts_project
* Update yarn Bazel packages
* docs/theme add missing dependencies
* Remove unused attribute module_root
Co-authored-by: Andreas Herrmann <andreas.herrmann@tweag.io>
2020-04-17 15:03:33 +03:00
|
|
|
'{\"tsconfigRootDir":"$$(dirname $$(rlocation $(location %s)))"}' % tsconfig,
|
2020-04-01 14:41:35 +03:00
|
|
|
"--max-warnings",
|
|
|
|
"0",
|
2020-01-21 16:39:54 +03:00
|
|
|
]
|
|
|
|
for src in srcs:
|
|
|
|
templated_args.append("$(rlocation $(location %s))" % src)
|
|
|
|
_eslint_test(
|
|
|
|
name = name,
|
2020-04-01 14:41:35 +03:00
|
|
|
data = srcs + [tsconfig, eslintrc] + data + eslint_deps,
|
2020-01-21 16:39:54 +03:00
|
|
|
templated_args = templated_args,
|
|
|
|
**kwargs
|
2020-01-22 18:07:20 +03:00
|
|
|
) if not is_windows else None
|