Commit graph

51 commits

Author SHA1 Message Date
Matthieu Riegler
5220cea223 build: add a noDuplicateEnumValue rule (#63483)
It caught several legitimate issues.
In the cases I wasn't sure, I just disabled the rule.

fixes #45843

PR Close #63483
2025-09-10 22:16:10 +00:00
Joey Perrott
de4c06cf5c build: migrate tslint rules from dev-infra to local (#62709)
Migrate the tslint rules used in dev-infra to locally defined rules as they are unused in other repos

PR Close #62709
2025-07-22 10:07:13 -04:00
Paul Gschwendtner
810b0a7e5c refactor: add explicit types for exports relying on inferred call return type (#61312)
As part of the Bazel toolchain migration we noticed that implicit types
generated by the TypeScript compiler sometimes end up referencing types
from other packages (i.e. cross-package imports).

These imports currently work just because the Bazel `ts_library` and
`ng_module` rules automatically inserted a `<amd-module
name="@angular/x" />` into `.d.ts` of packages. This helped TS figure
out how to import a given file. Notably this is custom logic that is not
occuring in vanilla TS or Angular compilations—so we will drop this
magic as part of the toolchain cleanup!

To improve code quality and keep the existing behavior working, we are
doing the following:

- adding a lint rule that reduces the risk of such imports breaking. The
  failure scenario without the rule is that API goldens show unexpected
  diffs, and types might be duplicated in a different package!

- keeping the `<amd-module` headers, but we manually insert them into
  the package entry-points. This should ensure we don't regress
  anywhere; while we also improved general safety around this above.

Long-term, isolated declarations or a lint rule from eslint-typescript
can make this even more robust.

PR Close #61312
2025-05-13 22:45:18 +00:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Joey Perrott
0bd55a684f refactor(docs-infra): complete removal of aio directory (#56496)
Finish removal of aio directory as it is no longer used or relied upon.

PR Close #56496
2024-06-18 12:26:00 -07:00
Joey Perrott
a2aca69bd3 refactor: migrate forms to prettier formatting (#55423)
Migrate formatting to prettier for forms from clang-format

PR Close #55423
2024-04-19 13:49:24 -07:00
Alan Agius
d4bd3f198b build: configure tslint to ban performance.mark usages (#52505)
While `performance.mark` is available on all supported browsers and node.js version this API is not available in JSDOM which is used by Jest and Cloudflare worker.

PR Close #52505
2023-11-03 07:43:36 -07:00
Joey Perrott
7fd650a898 build: update lint path for @angular/build-tooling rules (#49266)
Update to the new path.

PR Close #49266
2023-02-28 11:56:28 -08:00
Paul Gschwendtner
13f10de40e test: update code fixes spec to work with esm-cjs interop lint (#48731)
The TSLint rule for ESM/CJS interop was apparently not working
for a short period of time due to diverging TypeScript versions.

This commit fixes the lint warning to replace the type-only
import with a default import. Even thoughn not striclty needed
for types- the rule enforces a default import as that is the safer
approach for runtime imported symbols.

Also the rule is updated to not disallow `cluster` anymore. The
types for cluster do no allow for e.g. `cluster.Worker` if cluster
refers to the default import. The whole lint rule is not strictly
needed anymore since we build & test with ESM in this repo now!

PR Close #48731
2023-01-13 14:10:39 +00:00
Paul Gschwendtner
acf98268f8 refactor: update language-service package and tests to work with ESM (#48521)
The Angular Language Service package is now tested & compiled using ESM.
Previously it was a mismatch of CommonJS and ESM.

Still the language-service ESM output is transformed into a single UMD
bundle to allow for module resolution to be overriden. See
`bundles/BUILD`.

This is kept as is. To fully ship ESM (language-service is an exception
here), we need to:

 * Update all code to no longer reference typescript via import. Instead
   typescript needs to be passed around so that the extension can
   control the version
 * The VSCode extension/ the TS server needs to be able to load ESM. It
   looks like the server supports ESM global plugins, but the extension
   might not yet.

This is out of scope for the dev-infra effort as it requires more
insight into VSCode & the extension system & the TS language server.

PR Close #48521
2022-12-19 19:50:44 +00:00
Paul Gschwendtner
661134fd21 refactor: update compiler-cli babel linker to be ESM only (#48521)
Since the linker is no longer being tested with CommonJS, we can remove
most of the CJS/ESM interop trickery.

PR Close #48521
2022-12-19 19:50:43 +00:00
Derek Cormier
3c24466cd3 build(bazel): fix linting errors
Exclude third_party vendored code from linting to preserve original form
2022-11-22 13:51:16 -07:00
Kristiyan Kostadinov
ddb95c5184 refactor(compiler): replace most usages of getMutableClone (#47167)
Replaces (almost) all of the usages of the deprecated `getMutableClone` function from TypeScript which has started to log deprecation warnings in version 4.8 and will likely be removed in version 5.0. The one place we have left is in the default import handling of ngtsc which will be more difficult to remove.

PR Close #47167
2022-08-22 10:40:50 -07:00
Paul Gschwendtner
b757b1387c build: update dev-infra packages and account for build-tooling split from ng-dev (#46976)
The dev-infra build tooling is now decoupled from `ng-dev`. This will
make it easier to update `ng-dev` without necessarily needing to upgrade
the whole build system, Bazel etc. This is useful when e.g. new release
tool features have been added and should also be ported to active LTS
branches.

PR Close #46976
2022-08-02 09:37:37 -07:00
AleksanderBodurri
445fbf81fd refactor(devtools): bring the angular devtools directory into the root bazel workspace
Previously devtools used a nested workspace for its bazel configurations. This meant framework dependencies were consumed via npm.

Now devtools is part of the root bazel directory that all other files in this codebase fall under. This allows us to build devtools using local angular packages, removing the need to consume these dependencies with npn. This is useful because we no longer have to update these dependencies with an automated tool like renovate, and our CI tests will always run against the most up to date framework packages.
2022-01-26 16:35:31 -05:00
AleksanderBodurri
2a1ff17b42 refactor(devtools): run tslint --fix on devtools codebase
This commit runs tslint --fix with the angular/angular tslint configuration on the files inside the devtools codebase.

Notably, the file-header rule in `tslint.json` was missing a default attribute. This commit adds that default attribute and sets it to the
license header that is present in all files in this repo. After running tslint --fix with this default added, this commit added the license header to all files in the devtools directory. Note for the reviewer: the automatically added license headers were added as comments with the "/*!" prefix. Since we want these comments removed in builds, and the rest of the codebase uses "/**", a simple find and replace was performed on the devtools directory to change these prefixes to "/**".
2022-01-26 16:35:31 -05:00
AleksanderBodurri
8b84412d76 refactor(devtools): run ng-dev format on angular devtools files
Formats the entire devtools directory with the ng-dev formatting tool. Previously we relied on prettier, so this commit also remove prettier from devtools' dependencies.
2022-01-26 16:35:30 -05:00
Paul Gschwendtner
d15a692789 build: enable esModuleInterop in TypeScript compilations (#43431)
Enables the `esModuleInterop` for all TypeScript compilations in the
project. This allows us to emit proper ESM-compatible code. e.g.
consider the following import:

```ts
import * as ts from 'typescript';
```

This import currently will break at runtime in NodeJS because the
`typescript` package is not shipping ESM. It's still a CommonJS module.
ES modules are able to import from `typescript` though, using an import
statement as above, but everything in `module.exports` is being exposed
as the `default` named export. TypeScript at runtime does not have any
other named exports, so for actual ESM compatibility, all of our imports
need to be switched to:

```
import ts from 'typescript';
```

The `esModuleInterop` option allows this to work even though the
`d.ts` file of TS currently suggests that there are _only_ named exports.
The TypeScript language service will now suggest the correct import form as
shown above. It doesn't enforce that unfortunately, but this commit also
adds a lint rule that enforces certain patterns so that we emit imports
that are compatible with both ESM and CJS output (CJS still needed here
since tests run with CJS devmode output still; this is a future project
to switch that over to ESM!)

PR Close #43431
2021-10-01 18:28:45 +00:00
Joey Perrott
81e4257761 build: remove dev-infra directory and migrate to relying on @angular/dev-infra-private-builds (#43061)
Remove the dev-infra directory and complete the migration to using the code generated by the
angular/dev-infra repository.

PR Close #43061
2021-08-16 10:44:27 -07:00
Paul Gschwendtner
72c03a0d4f build: remove ts-api-guardian from repository (#42735)
This commit removes `ts-api-guardian` from the repository. We introduced
a new tool for testing API signature that is part of the shared
dev-infra package. The TS API guardian package will be deprecated for
the public in favor of Microsoft's API extractor that has support for
more parts of the syntax, such as alias exports.

PR Close #42735
2021-07-26 12:02:14 -07:00
Paul Gschwendtner
04642e7985 feat(dev-infra): add lint rule to enforce no-implicit-override abstract members (#42512)
TypeScript introduced a new flag called `noImplicitOverride` as part
of TypeScript v4.3. This flag introduces a new keyword called `override`
that can be applied to members which override declarations from a base
class. This helps with code health as TS will report an error if e.g.
the base class changes the method name but the override would still
have the old method name. Similarly, if the base class removes the method
completely, TS would complain that the memeber with `override` no longer
overrides any method.

A similar concept applies to abstract methods, with the exception that
TypeScript's builtin `noImplicitOverride` option does not flag members
which are implemented as part of an abstract class. We want to enforce
this as a best-practice in the repository as adding `override` to such
implemented members will cause TS to complain if an abstract member is
removed, but still implemented by derived classes.

More details: https://github.com/microsoft/TypeScript/issues/44457.

PR Close #42512
2021-07-12 13:11:16 -07:00
Paul Gschwendtner
2d0ff0a5d3 ci: add lint error for files with missing trailing new-line (#42478)
For quite a while it is an unspoken convention to add a trailing
new-line files within the Angular repository. This was never enforced
automatically, but has been frequently raised in pull requests through
manual review. This commit sets up a lint rule so that this is
"officially" enforced and doesn't require manual review.

PR Close #42478
2021-06-04 13:31:03 -07:00
Kristiyan Kostadinov
3e192bfa4d build: fix linting against jasmine focus functions (#42415)
We were linting against usages of `fdescribe` and `fit` by referencing the `no-jasmine-focus` rule which isn't installed, causing tslint to log the following:

```
Could not find implementations for the following rules specified in the configuration:
    no-jasmine-focus
Try upgrading TSLint and/or ensuring that you have all necessary custom rules installed.
If TSLint was recently upgraded, you may have old rules configured which need to be cleaned
```

These changes switch to using the built-in `ban` rule.

PR Close #42415
2021-06-01 10:16:55 -07:00
Joey Perrott
c05169318e build: exclude build-worker file from formatting (#40012)
Exclude the generated build-worker.js file from formatting as it is
generated and not subject to formatting restrictions.

PR Close #40012
2020-12-08 12:06:53 -08:00
Pete Bacon Darwin
793d66afa5 test(compiler-cli): create "full compile" compliance test rules (#39617)
This commit contains the basic runner logic and a couple of sample test cases
for the "full compile" compliance tests, where source files are compiled
to full definitions and checked against expectations.

PR Close #39617
2020-11-13 11:25:56 -08:00
Joey Perrott
d331e09b71 refactor(dev-infra): create ng-dev executable locally in the repo (#39089)
Rather than running ng-dev via ts-node, going forward ng-dev is generated and run
locally via node.  Additionally, the generated file is tested on each commit to
ensure that the local generated version stays up to date.

PR Close #39089
2020-10-22 13:36:14 -07:00
Joey Perrott
5aeb9a4124 build: Update file-header lint rule to Google LLC (#37205)
Update the file-header lint rule to properly reference Google LLC
rather than Google Inc, for the required headers.

PR Close #37205
2020-05-26 14:26:58 -04:00
Adam Plumer
388dc93cee feat: remove @angular/http (#27038)
The legacy HTTP package was deprecated in v5 with the launch of
@angular/common/http. The legacy package hasn't been published
since v7, and will therefore not include a migration.

PR Close #27038
2020-05-05 17:42:01 -07:00
Paul Gschwendtner
5615928df9 build: no longer run tslint from within gulp task (#35800)
Switches our tslint setup to the standard `tslint.json` linter excludes.
The set of files that need to be linted is specified through a Yarn script.

For IDEs, open files are linted with the closest tslint configuration, if the
tslint IDE extension is set up, and the source file is not excluded.

We cannot use the language service plugin for tslint as we have multiple nested
tsconfig files, and we don't want to add the plugin to each tsconfig. We
could reduce that bloat by just extending from a top-level tsconfig that
defines the language service plugin, but unfortunately the tslint plugin does
not allow the use of tslint configs which are not part of the tsconfig project.

This is problematic since the tslint configuration is at the project root, and we
don't want to copy tslint configurations next to each tsconfig file.

Additionally, linting of `d.ts` files has been re-enabled. This has been
disabled in the past and a TODO has been left. This commit fixes the
lint issues and re-enables linting.

PR Close #35800
2020-03-03 09:20:49 -08:00
Danny Skoog
c60d7563a8 style: enforce disallowance of object constructor (#33211)
Applying the `prefer-literal` tslint rule to object enforces the style guide rule https://google.github.io/styleguide/jsguide.html#features-objects-ctor

PR Close #33211
2019-12-03 10:08:25 -08:00
Danny Skoog
0e260d2c3b style: enforce disallowance of String, Number and Boolean constructors (#33210)
The `no-construct` tslint rule partially enforces the style guide rule https://google.github.io/styleguide/jsguide.html#disallowed-features-wrapper-objects

PR Close #33210
2019-10-17 14:12:00 -04:00
Filipe Silva
ac34a1429b refactor: remove toplevel property accesses (#29329)
PR Close #29329
2019-05-16 12:08:49 -07:00
Paul Gschwendtner
7cbc36fdac build: remove unused rollup.config.js files (#28646)
Since we build and publish the individual packages
using Bazel and `build.sh` has been removed, we can
safely remove the `rollup.config.js` files which are no
longer needed because the `ng_package` bazel rule
automatically handles the rollup settings and globals.

PR Close #28646
2019-02-14 19:28:08 +00:00
Miško Hevery
116946fb11 style: tslint enforces no debugger statements left behind (#25532)
PR Close #25532
2018-08-16 16:00:22 -07:00
Hans Larsen
f1a9e1e361 build: add lint rule for global flags in rollup config (#20028)
We now verify that every imports is part of the globals defined in the files rollup.config.js.

PR Close #20028
2017-10-30 23:09:16 -04:00
Olivier Combe
0f5c70d563 build: update npm dependencies (#19328)
PR Close #19328
2017-09-22 13:20:52 -07:00
Victor Berchet
1b547886d0 build(tslint): enable no-inner-declarations (#13316) 2016-12-08 13:46:08 -08:00
Bowen Ni
2c02d34c05 refactor(lint): Don't allow console.log
Enable tslint check for `console.log` as a follow-up to
https://github.com/angular/angular/issues/13018
2016-11-23 15:47:01 -08:00
Joao Dias
8f5dd1f11e chore(lint): enforce no var keyword rule 2016-11-12 16:40:17 -08:00
Joao Dias
a0aecac0e5 chore(lint): replace enforce-copyright-header rule with the native equivalent 2016-10-31 11:27:35 -07:00
Joao Dias
e86573bac8 chore(lint): replace gulp check-task with tslint no-jasmine-focus rule
fixes #11800
2016-10-28 15:53:15 -07:00
Joao Dias
0a94845435 chore(lint): replace duplicate-module-import rule with no-duplicate-imports 2016-10-28 15:53:15 -07:00
Peter Bacon Darwin
a2d35641e3 chore(tslint.json): semicolon rule expects an array 2016-10-19 22:38:14 +01:00
Alex Eagle
4c762a6be3 chore(lint): enable lint check for duplicate vars 2016-07-13 12:33:39 -07:00
ScottSWu
a5f2cc73f6 chore(lint): Add lint check for license headers
Added a tslint check to make sure all source files begin with a license
header (at the very beginning or after a `#!`).

Relates to #9380
2016-06-23 09:46:32 -07:00
Alex Eagle
9f506cd330 chore(lint): remove unused lint checks
Now that we have --noImplicitAny we don't need these checks for explicit types in specific locations.

Also re-enable the check to disallow keywords as variable names.
2016-06-09 11:34:53 -07:00
Alex Eagle
b5d14c26d2 chore(lint): enable requireInternalWithUnderscore tslint check 2016-05-27 09:31:18 -07:00
Alex Eagle
2019050db2 chore(lint): enable duplicateModuleImport tslint check 2016-05-27 09:17:08 -07:00
Alex Eagle
ef0c32512c chore(lint): enable semicolon and variable-name tslint checks 2016-05-26 15:46:03 -07:00
Alex Eagle
666dc75c15 chore(lint): disallow duplicate imports from a module
Closes #7859
2016-05-20 15:59:33 -07:00