Граф коммитов

432 Коммитов

Автор SHA1 Сообщение Дата
Jeremy Meng d8b577111a
[EngSys] Pin @azure/msal-* version temporarily (#31819)
because upgrading them caused identity unit tests to fail. This allows
us to upgrade other packages to address security alerts.
2024-11-19 15:29:16 -08:00
Maor Leger 86ed16f451
[identity] Migrate to ESM and tshy (#31647)
### Packages impacted by this PR

@azure/identity-broker
@azure/identity 

### Issues associated with this PR

#31338 

### Describe the problem that is addressed by this PR

Migrates identity and identity-broker to ESM, tshy, and Vitest
2024-11-13 15:26:24 -08:00
Jeremy Meng ae84780ce1
[dev-tool] stop rolling up types for ESM (#31720)
For packages that have been migrated to ESM, Rolled up dts files are no
longer used but they are still packaged because our `files` field
include an entry of `dist/`. Since they are not used anymore, this PR
stops generating them, instead of more complicated approach of excluding
them from `npm pack`.
2024-11-13 10:01:13 -08:00
Jeremy Meng cf8d25ff5e
Fix compiler errors in tests and samples (#31649)
After moving to ESM/tshy, we no longer build tests/samples. This PR
enables running "typecheck" as an optional rush bulk command, and fixes
some of the errors found.

The known errors reported on files from vite/vitest/chai are ignored.

The update-snippets dev-tool command throws error of reading undefined
in some cases, adding a null check fixes it.

Snippets are updated as well after snippets.spec.ts files are fixed.
2024-11-06 13:31:08 -08:00
Jeremy Meng d52374b87e
[eslint-plugin] turn off `n/no-process-exit` rule for samples-dev/ (#31626) 2024-11-04 12:11:01 -08:00
Jeremy Meng a28e8f0795 [EngSys] move to vendored version of cross-env via dev-tool
***NO_CI***

- apply the transformation

- update samples' README
2024-11-02 00:48:06 +00:00
Jeremy Meng 980f3cbb89 [EngSys] move `uglify-js` to dev-tool vendored
- add dep to `uglify-js` in dev-tool

- rush update

- replace "uglifyjs" with "dev-tool run vendored yglifyjs"

- remove dependency to "uglifyjs" in sdk packages

***NO_CI***
2024-10-30 18:01:20 +00:00
Jeremy Meng 6a2c7300eb [eslint-plugin] add rule "@typescript-eslint/consistent-type-imports": "warn"
- apply lint:fix results

- revert fixes that are not related to consistent-type-imports and cases error

- regenerate .api.md files

- format

- update core-comparison diff
2024-10-30 15:48:52 +00:00
Jeremy Meng 1cae9db8e1 [EngSys] remove "audit" NPM script and it's related file
as we no longer use it and rely on GitHub security features.

***NO_CI***
2024-10-25 19:28:06 +00:00
Jeremy Meng af5c6a8006
[dev-tool] react to NodeJS `spawn` security fix (#29414)
Node made a breaking change in a security release for 18/20 where `spawn()` no longer loads `.cmd` files by default. nodejs/node#52554.

This PR sets the `shell: true` option when running vendored command on Windows.
2024-10-23 13:30:55 -07:00
Maor Leger b3bda3a2f9
[attestation] Migrate to ESM and tshy (#31433)
### Packages impacted by this PR

@azure/attestation

### Issues associated with this PR

#31338 

### Describe the problem that is addressed by this PR

Migrates `@azure/attestation` to ESM and tshy.

Co-authored-by: Deyaaeldeen Almahallawi <dealmaha@microsoft.com>
2024-10-22 09:39:30 -07:00
Jeremy Meng 1f4c88c136
[EngSys] upgrade dev dependency `@typescript-eslint/*` to `~8.10.0` (#31466)
- replace version string with ~8.10.0
- rush update
- [monitor-opentelemetry-exporter] fixing linting error of unnecessary `undefine` type for the optional parameter
2024-10-18 13:22:56 -07:00
Maor Leger 155d4be91b
[dev-tool] Migrate package codemods (#31324)
### Packages impacted by this PR

@azure/dev-tool

### Issues associated with this PR

Resolves #31325

### Describe the problem that is addressed by this PR

In order to automate as much as possible, we're introducing a set of
codemods to dev-tool's migrate-package command which can be added to by anyone.
These codemods will run in sequence and commit their work in stages for ease
of reviewing
2024-10-14 09:01:46 -07:00
Maor Leger 2ffa690a77
[dev-tool] Upgrade ts-morph to 24.x (#31326)
Resolves #31321
2024-10-07 17:25:07 +00:00
Maor Leger dc16f1486b
[dev-tool] Update readme (#31295)
Just update the readme to specify dev-tool uses tsx instead of ts-node
now
2024-10-02 13:54:13 -07:00
Maor Leger 543f973590
[dev-tool] newline fix (#31294)
Fixes newline character to use `\n` in windows as well as other OS's
2024-10-02 20:28:04 +00:00
Maor Leger e99e5dd409
[dev-tool] Use tsx (#31284)
### Packages impacted by this PR

@azure/dev-tool

### Issues associated with this PR

Resolves #29672

### Describe the problem that is addressed by this PR

With the move to ESM and tshy we've been running into issues using the
existing TS_NODE
based loader in dev-tool. Specifically we're seeing errors such as:

```
[run-samples] Error: Must use import to load ES Module: D:\a_work\1\s\sdk\template\template\samples-dev\getConfigurationSetting.ts
require() of ES modules is not supported.
require() of D:\a_work\1\s\sdk\template\template\samples-dev\getConfigurationSetting.ts from D:\a_work\1\s\common\tools\dev-tool\src\commands\samples\run.ts is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from D:\a_work\1\s\sdk\template\template\package.json.
```

ts-node is being phased out for tsx, a modern alternative that handles
hybrid scenarios like us in much simpler manner.

This PR switches our loader from ts-node to tsx. Now we can run samples
again for both cjs and esm!
2024-10-02 12:23:56 -07:00
Jeremy Meng 652a7ffa89 [eslint-plugin] fix ts-naming-options rule issue
***NO_CI***

Currently the rule only handles the case of

```ts
  clientMethod(options: MethodOptions) {}
```

but not when the options bag parameter has a default value

```ts
  clientMethod(options: MethodOptions = {}) {}
```

This change adds code to handle the latter.

- Add two unit tests

- Update the affected packages to suppress this rule as a warning

- react to the fix
2024-10-02 16:40:01 +00:00
Maor Leger 47e5f01431
[dev-tool] migrate-package command improvements (#31269)
### Packages impacted by this PR

@azure/dev-tool

### Issues associated with this PR

N/A - part of migrations

### Describe the problem that is addressed by this PR

A few quality-of-life improvements as I migrate keyvault packages to
ESM:

1. Allow skipping browser test configuration
2. Ensure linters are happy by appending an empty line to updated json files
3. Replace `tsc -p .` with `dev-tool run build-package` in the scripts section
4. Replace `@azure-tools/test-utils` with `@azure-tools/test-utils-vitest`
5. Remove `tshy` from the dependencies to add since `build-package` uses
a vendored tshy version
2024-09-30 14:50:58 -07:00
Maor Leger f0271b99c6
[dev-tool] Generate detailed report for ESM migrations (#31252)
### Packages impacted by this PR

dev-tool

### Issues associated with this PR

### Describe the problem that is addressed by this PR

A few QoL additions as we aim to complete the ESM migration:

- output markdown
- Add verbose mode to output individual package status

I only focused on ESM migration as we plan to migrate ESM + Vitest in a
single commit. This all builds off of the work Matt started and allows us to
keep an up-to-date wiki for folks to follow the migration status
2024-09-27 14:09:33 -07:00
Matthew Podwysocki 61c8b9aae4 [EngSys] Add update-snippets to all package.json files ***NO_CI*** 2024-09-26 17:59:37 +00:00
Jeremy Meng 0804cc1620
[dev-tool] only process api.json files if they are generated (#31213)
This PR fixes an error in extra-api command when a package doesn't
enable the docModel generation, we were trying to open an api.md file
that doesn't exists.
2024-09-25 13:30:53 -07:00
Maor Leger 64c72d5dda [engsys] Move all packages to build-package script ***NO_CI*** 2024-09-25 18:52:35 +00:00
Maor Leger bfefb073bb
[dev-tool] Add build-package command (#31197)
### Packages impacted by this PR

core

### Issues associated with this PR

N/A

### Describe the problem that is addressed by this PR

As we look to migrate all packages to tshy we want to make sure we are
able to move away from tshy if ever needed. This PR adds a build-package command
that can later be used to consolidate some of the commands and decouple a bit
from tshy

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?

We can just call tshy directly, but one of the "selling" points of tshy
is that we can always eject and do what it does manually if we run into issues.
This helps streamline that without having to update 400 package.json files if
needed.

Frankly, I am not 100% sure if this is needed and I admit that `tshy` is
still an entry in packages' json, but I think we can live with the `tshy`
entry longer than we can with a `tshy` tool migration.
2024-09-25 10:14:07 -07:00
Jeremy Meng 4abda1b83d
[eslint-plugin] remove legacy configs (#31203)
Now that we have moved to ESLint v9, classic configs are no longer used.
This PR removes them.
2024-09-25 09:35:27 -04:00
Matthew Podwysocki 9fcee80f1a
[core] Add README snippets for core (#31204)
### Packages impacted by this PR

- @azure/dev-tool
- @azure/abort-controller
- @azure/core-amqp
- @azure/core-auth
- @azure/core-client
- @azure-rest/core-client
- @azure/core-http-compat
- @azure/core-lro
- @azure/core-paging
- @azure/core-rest-pipeline
- @azure/core-tracing
- @azure/core-util
- @azure/core-xml
- @azure/logger
- @typespec/ts-http-runtime

### Issues associated with this PR


### Describe the problem that is addressed by this PR

Adds snippets extraction to core.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
2024-09-25 09:35:12 -04:00
Jeremy Meng 13f5beb45a
[eslint-plugin] turning off some rules for test/snippets.spec.ts (#31205)
as its code is meant to be included in docs and not required to be
perfect.
2024-09-24 14:06:22 -07:00
Jeremy Meng 3b67e63dcd
[dev-tool] generate merged api.json from subpath exports (#31164)
This PR creates a merged api.json file from individual api.json files of
subpath exports. The `ApiModel` type from api-extractor-model already
allows multiple `EntryPoint` but so far only one is added.

With this new file, we can also attach more information to the
`metadata` properties. Even though they are not loaded by `ApiModel`, we
could still read that information from the file directly. This saves us
from having to upload multiple files to ApiView.
2024-09-23 16:52:22 -07:00
Minh-Anh Phan 2d2ccf5e42
[Dev-Tool] Update the build-test command to check for browser files (#31184)
### Describe the problem that is addressed by this PR
The current overrides for the browser specific files only replace them
if they are under "src" directory. This PR adds the "test" directory for
test coverage
2024-09-23 10:31:24 -07:00
Matthew Podwysocki 8597959155
[dev-tool] Add snippets extraction (#31143)
### Packages impacted by this PR

- @azure/dev-tool

### Issues associated with this PR

### Describe the problem that is addressed by this PR

This PR implements a new dev-tool command: `dev-tool run
update-snippets`.

This command looks for code fences in markdown files and JSDoc comments,
and updates them with the contents of test methods in a file named
`snippets.spec.ts`.

For example, the following fence indicates that the contents of a test
named "new_configurationclient" should be used:

````
```js snippet:new_configurationclient
```
````

After running `dev-tool run update-snippets`, the contents of the
snippet will be populated:

````
```js snippet:new_configurationclient
import { ConfigurationClient } from "@azure/template";
import { DefaultAzureCredential } from "@azure/identity";

const client = new ConfigurationClient(
  "<app configuration endpoint>",
  new DefaultAzureCredential()
);
```
````

To accomplish this, the command uses the TypeScript compiler API to
extract and transpile snippets from `snippets.spec.ts`. Snippets are the
contents of calls to the `it` function. If syntax with the shape
`it(<literal string>, <function with block>)` appears in
`snippets.spec.ts`, it will be considered a snippet that is valid for
injection.

("Function with block" means either a `function () { ... }` expression
or an arrow function with a block on the arrow side (`() => { ... }`).
An arrow function that has an expression on the right hand side (`() =>
(...)`) will not be recognized.)

For example:

```ts
  it("new_configurationclient", function () {
    // @ts-ignore
    const client = new ConfigurationClient(
      process.env.ENDPOINT ?? "<app configuration endpoint>",
      new DefaultAzureCredential()
    );
  });
```

The transpiler automatically "cleans" and validates the snippet using
similar techniques as the sample transpiler. As a result, it enforces
the same syntactic rules that the sample transpiler does. In addition to
those, it removes references to `process.env` (if an alternative is
specified), removes compiler pragmas like `// @ts-ignore`, and
automatically inserts imports for symbols that the snippet uses. So in
the above snippet, imports for `ConfigurationClient` and
`DefaultAzureCredential` are required, automatically detected, and
injected into the resulting snippet.

Snippets without `snippet:${name}` tags are _errors_ when using this
command, so a package must be fully migrated to use it.

### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_

- #24536

### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
2024-09-20 19:05:10 -04:00
Jeremy Meng e11ec1aa1d
[eslint-plugin] ignore *.api.md files from linting (#31180)
### Packages impacted by this PR
`@eslint-plugin-azure-sdk`
2024-09-20 12:31:41 -07:00
Jeremy Meng a7b3656a05 [EngSys] upgrade dev dependency `typescript` version to `~5.6.2`
***NO_CI***

- replace version to "~5.6.2"
- rush update
- add `"skipLibCheck": true` for several packages that are affected by https://github.com/vitest-dev/vitest/issues/4688

- [formrecognizer] help TypeScript to understand with more explicit type

- [schema-registry-{avro,json}] skip lib check due to lru-cache issue with the Iterator TReturn change

https://github.com/isaacs/node-lru-cache/issues/348
2024-09-19 18:07:31 -07:00
Jeremy Meng e1e7eb4b9f
[eslint-plugin] exclude *.config.*ts from linting (#31050)
so we don't have errors in editors when opening vitest configs
2024-09-11 15:10:03 -07:00
Jeremy Meng b7e1fd2698
[eslint-plugin] fix `ts-modules-only-named` invalid test cases (#30924)
There's some change in `typescript-eslint` that breaks some eslint test
cases.
Previously when running tests, in a rule's `create()` method, we get a
relative
path for `context.filename`, and when we pass a setting of `{ main:
"src/test.ts" }` in rule tester option, the two were considered the same
file,
therefore the following condition check failed, and we continue to
report error
for default exports.


6dd8b582e2/common/tools/eslint-plugin-azure-sdk/src/rules/ts-modules-only-named.ts (L31)

After the upgrade, `context.filename` now contains the full path, the
file
`src/test.ts` in our test fixture has a full path of
`/.../common/tools/eslint-plugin-azure-sdk/tests/fixture/src/test.ts`.
It is not
considered the same file as the passed settings implies
`/.../common/tools/eslint-plugin-azure-sdk/src/test.ts` when we run the
tests.
So we return earlier instead of going to check for default exports.

This is not an issue in real scenario where we have settings of `{ main:
"src/index.ts" }`, which would match the full path of the file we are
linting
when we run `eslint` from a package directory.

This PR fixes the test by passing `tests/fixture/src/test.ts` in the
settings so
that it matches the full path of `context.filename` we get in
`create()`.
2024-08-28 14:52:44 -07:00
Jeremy Meng d5f6d677ec [EngSys] standardize OSS copyright header
- [eslint-plugin] github-source-headers rule should use "MIT License".

  This change updates our linter rule and the whole repository to have consistent
  license header.

***NO_CI***

- remove "All rights reserved." from header

- "MIT license" => "MIT License"
2024-08-27 13:01:38 -07:00
Jeremy Meng 7029a9a745
[dev-tool] add command to type check files not being built by tshy (#30810)
In our current setup, tshy won't build test and samples-dev folder even
they are
included in tsconfig.json. This PR adds a command that does the
type-checking
for all files included in tsconfig.json, and allow additional files to
be passed
in as well.
2024-08-27 09:23:48 -07:00
Jeremy Meng 6041bc3950
[eslint-plugin] add an override to turn off tsdoc/syntax for samples-dev (#30902)
because dev-tool is using @summary and @azsdk-weight when publishing
samples.
2024-08-26 16:18:45 -07:00
Jeremy Meng bf2a1f74bf
[EngSys] upgrade dev dependency `@eslint/js` to ^9.9.0 (#30901)
to be consistent with `eslint` version.

Also removed the eslint plugin helper. It was added to help
vscode-eslint
extension to resolve plugin packages. With flat config it is no longer
needed.
2024-08-26 16:08:52 -07:00
Jeremy Meng 0a7913a414 remove temporary logging 2024-08-23 17:04:42 -07:00
Jeremy Meng c34a1c6482 skip linting for config files for the two packages that don't depend on dev-tool 2024-08-23 16:38:09 -07:00
Jeremy Meng 5adb09d715 [engsys] upgrade dev dependency eslint to v9
***NO_CI***

- bump eslint version to ^9.9.0
- [eslint-plugin] remove eslint-plugin-import for now. Will re-visit until it supports eslint v9
2024-08-23 16:37:40 -07:00
Jeremy Meng 038ed97cd2
[eslint-plugin] fix tests after upgrading typescript-eslint (#30889)
- adjust options passed `RuleTester` constructor
- remove `recommended` property that no longer exists
- use `output` of array to indicate multi-pass fixes with overlapping
range
- temporarily disable two test cases of ts-modules-only-named suite.
2024-08-23 16:13:22 -07:00
Jeremy Meng 2ce3c5feb4 [eslint-plugin] upgrade typescript-eslint to v8
***NO_CI***

- bump typescript-eslint dependencies version to ~8.2.0

- [eslint-plugin] suppress new linting errors appearing with v8

- [eslint-plugin] react to removed typescript-eslint property

  related PR https://github.com/typescript-eslint/typescript-eslint/pull/9025

- [eslint-plugin] turn off @typescript-eslint/no-unused-expressions

  as no-unused-expressions is already reported by eslint

- [dev-tool] fix new linting errors

- Remove @typescript-eslint/ban-types that no longer exists

  and replace with more specific rules wherever applicable.

- [cosmosdb] combine the test eslint config with the main one

- delete catch expression when caught error is not used

- fix or suppress linting errors in code files
2024-08-23 10:19:23 -07:00
Jeremy Meng 1764824335 add patterns for json and source blocks in markdown
because in flat config, the path is resolved relative to the config file.
The added patterns are for when the central flat config is used.
2024-08-22 11:41:29 -07:00
Jeremy Meng a0f2553fce
[eslint-plugin] turn off `eslint-plugin-n` rules for browsers (#30795)
Add a configuration to turn off all `eslint-plugin-n` rules for browser
code files.

Also remove the redundant `plugins` block in `nCustomization` because
the
plugin's "flat/recommended" config already does that


e5e758ea0c/lib/index.js (L87)

-------

### Packages impacted by this PR

eslint-plugin-azure-sdk
2024-08-21 09:11:32 -07:00
Jeremy Meng 0854e57c06
[linting] move monitor-opentelemetry-exporter to use flat config (#30792)
- add a config in eslint-plugin-azure-sdk for linting with type
information
- remove .eslint* and replace with eslint.config.mjs
- remove --ext from linting NPM scripts
- fix linting error: URL is now available in global scope on our
supported platforms.
2024-08-16 17:18:54 -07:00
Jeremy Meng 9c2c8eecc2
[eslint-plugin] upgrade `eslint-plugin-no-only-tests` to `^3.3.0` (#30775)
which allows up to remove the fixup as the new version supports flat
config.

-------

### Packages impacted by this PR
eslint-plugin-azure-sdk
2024-08-15 16:03:38 -07:00
Jeremy Meng d53f35436a
[eslint-plugin] enable eslint-plugin-promise for our flat config (#30774)
now that the plugin has flat config support

-------

### Packages impacted by this PR
eslint-plugin-azure-sdk
2024-08-15 16:03:06 -07:00
Jeremy Meng 405c244bb1 [linting] move perf tests to use eslint flat config
***NO_CI***

- add one flat config file for perf tests

- update NPM scripts of these packages to use that flat config for perf tests

  As eslint v8 still not switched to flat config by default, this change
  temporarily uses `cross-env` to set `ESLINT_USE_FLAT_CONFIG=true`

  Once we moved to eslint v9 the env var can be removed.
2024-08-15 10:56:56 -07:00
Jeremy Meng 732f0502dd
[lint] remove usage of passing internal eslintrc via command line (#30761)
and replacing them with eslint.config.mjs so that both command line
eslint and
the vscode eslint extension can use the same config.

- since vite-plugin-browser-test-map doesn't depend on
eslint-plugin-azure-sdk, add linter dev dependencies and a flat config
to it.

- add an internal flat config to our eslint plugin. use it in added flat
config for test utility packages
2024-08-14 18:37:10 -07:00