Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: microsoft/dtslint
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b0ddfa0c7fe779dff96e6476d13ead6fa35a0f47
Choose a base ref
...
head repository: microsoft/dtslint
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 88b6f8975bb3ae9091c7150ddd52a11732324009
Choose a head ref
  • 3 commits
  • 5 files changed
  • 2 contributors

Commits on Aug 11, 2021

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    fc56160 View commit details

Commits on Aug 12, 2021

  1. Remove 'external module' wording from rules (#340)

    The term now is just 'module'. I improved the wording while I was here.
    sandersn authored Aug 12, 2021

    Verified

    This commit was signed with the committer’s verified signature.
    crazy-max CrazyMax
    Copy the full SHA
    cd084e8 View commit details
  2. 4.1.3 - Improve no-single-module rule

    - Allow single *.ext modules
    - Remove 'external module' wording
    sandersn committed Aug 12, 2021
    Copy the full SHA
    88b6f89 View commit details
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dtslint",
"version": "4.1.3",
"version": "4.1.4",
"description": "Runs tests on TypeScript definition files",
"files": [
"bin",
2 changes: 1 addition & 1 deletion src/rules/noDeclareCurrentPackageRule.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { failure, getCommonDirectoryName } from "../util";
export class Rule extends Lint.Rules.TypedRule {
static metadata: Lint.IRuleMetadata = {
ruleName: "no-declare-current-package",
description: "Don't use an ambient module declaration of the current package; use an external module.",
description: "Don't use an ambient module declaration of the current package; use a normal module.",
optionsDescription: "Not configurable.",
options: null,
type: "functionality",
9 changes: 7 additions & 2 deletions src/rules/noSingleDeclareModuleRule.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import { failure } from "../util";
export class Rule extends Lint.Rules.AbstractRule {
static metadata: Lint.IRuleMetadata = {
ruleName: "no-single-declare-module",
description: "Don't use an ambient module declaration if you can use an external module file.",
description: "Don't use an ambient module declaration if there's just one -- write it as a normal module.",
rationale: "Cuts down on nesting",
optionsDescription: "Not configurable.",
options: null,
@@ -16,7 +16,7 @@ export class Rule extends Lint.Rules.AbstractRule {

static FAILURE_STRING = failure(
Rule.metadata.ruleName,
"File has only 1 module declaration — write it as an external module.");
"File has only 1 ambient module declaration. Move the contents outside the ambient module block, rename the file to match the ambient module name, and remove the block.");

apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithFunction(sourceFile, walk);
@@ -34,6 +34,11 @@ function walk(ctx: Lint.WalkContext<void>): void {
let moduleDecl: ts.ModuleDeclaration | undefined;
for (const statement of sourceFile.statements) {
if (ts.isModuleDeclaration(statement) && ts.isStringLiteral(statement.name)) {
if (statement.name.text.indexOf('*') !== -1) {
// Ignore wildcard module declarations
return;
}

if (moduleDecl === undefined) {
moduleDecl = statement;
} else {
1 change: 1 addition & 0 deletions test/no-single-declare-module/wildcard.d.ts.lint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module "*.svg" {}
2 changes: 1 addition & 1 deletion test/no-single-declare-module/wrong.d.ts.lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
declare module "foo" {}
~~~~~~~~~~~~~~~~~~~~~~~ [File has only 1 module declaration — write it as an external module. See: https://github.com/Microsoft/dtslint/blob/master/docs/no-single-declare-module.md]
~~~~~~~~~~~~~~~~~~~~~~~ [File has only 1 ambient module declaration. Move the contents outside the ambient module block, rename the file to match the ambient module name, and remove the block. See: https://github.com/Microsoft/dtslint/blob/master/docs/no-single-declare-module.md]

// Other global declarations don't affect this. They should go in "declare global".
interface I {}