From 1d96b8f92db6b1cb0418312fccd16386eebbb7d1 Mon Sep 17 00:00:00 2001 From: Alessio Bianchini Date: Fri, 26 Jul 2024 12:44:35 +0200 Subject: [PATCH] Updated version.ts and demo-app, removed unused files --- CHANGELOG.md | 6 + README.md | 2 +- package.json | 2 +- projects/libs/flex-layout/package.json | 2 +- projects/libs/flex-layout/tsconfig.lib.json | 8 +- projects/libs/flex-layout/version.ts | 5 +- tools/package-tools/build-bundles.ts | 156 ------------------ tools/package-tools/build-config.ts | 27 --- tools/package-tools/build-notes.md | 20 --- tools/package-tools/find-build-config.ts | 22 --- tools/package-tools/tsconfig.json | 24 --- tools/package-tools/version-placeholders.ts | 62 ------- tools/tslint-rules/noExposedTodoRule.ts | 34 ---- tools/tslint-rules/noRxjsPatchImportsRule.ts | 44 ----- tools/tslint-rules/noViewEncapsulationRule.ts | 59 ------- .../requireBreakingChangeVersionRule.ts | 38 ----- .../tslint-rules/requireLicenseBannerRule.ts | 61 ------- tools/tslint-rules/tsLoaderRule.js | 13 -- tools/tslint-rules/tsconfig.json | 24 --- tools/tslint-rules/validateDecoratorsRule.ts | 119 ------------- 20 files changed, 18 insertions(+), 710 deletions(-) delete mode 100644 tools/package-tools/build-bundles.ts delete mode 100644 tools/package-tools/build-config.ts delete mode 100644 tools/package-tools/build-notes.md delete mode 100644 tools/package-tools/find-build-config.ts delete mode 100644 tools/package-tools/tsconfig.json delete mode 100644 tools/package-tools/version-placeholders.ts delete mode 100644 tools/tslint-rules/noExposedTodoRule.ts delete mode 100644 tools/tslint-rules/noRxjsPatchImportsRule.ts delete mode 100644 tools/tslint-rules/noViewEncapsulationRule.ts delete mode 100644 tools/tslint-rules/requireBreakingChangeVersionRule.ts delete mode 100644 tools/tslint-rules/requireLicenseBannerRule.ts delete mode 100644 tools/tslint-rules/tsLoaderRule.js delete mode 100644 tools/tslint-rules/tsconfig.json delete mode 100644 tools/tslint-rules/validateDecoratorsRule.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 80d1fb43a..4caea52e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# [18.1.1-beta.2](https://github.com/alessiobianchini/ng-flex-layout/compare/18.1.1-beta.1...18.1.1-beta.2) (2024-07-26) + +* Updated version.ts to expose correct version +* Updated demo-app for latest hight resolution screen +* Removed unused files + # [18.1.1-beta.1](https://github.com/alessiobianchini/ng-flex-layout/compare/17.3.7-beta.1...18.1.1-beta.1) (2024-07-23) * Updated to Angular 18.1.1 diff --git a/README.md b/README.md index d345e2c27..d88432c7b 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ng-flex-layout *** -[![npm version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=js&r=r&ts=1683906897&type=6e&v=18.1.1-beta.1&x2=0)](https://www.npmjs.com/package/ng-flex-layout) +[![npm version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=js&r=r&ts=1683906897&type=6e&v=18.1.1-beta.2&x2=0)](https://www.npmjs.com/package/ng-flex-layout) [![Test lib CI](https://github.com/alessiobianchini/ng-flex-layout/actions/workflows/test-lib.yml/badge.svg)](https://github.com/alessiobianchini/ng-flex-layout/actions/workflows/test-lib.yml) [![CodeQL](https://github.com/alessiobianchini/ng-flex-layout/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/alessiobianchini/ng-flex-layout/actions/workflows/github-code-scanning/codeql) diff --git a/package.json b/package.json index 086f97c18..e01fbf56b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ng-flex-layout", "description": "Angular Flex Layout (DOIT fork)", - "version": "18.1.1-beta.1", + "version": "18.1.1-beta.2", "homepage": "https://github.com/alessiobianchini/flex-layout", "bugs": "https://github.com/alessiobianchini/flex-layout/issues", "repository": { diff --git a/projects/libs/flex-layout/package.json b/projects/libs/flex-layout/package.json index 53125089b..0d59835e7 100644 --- a/projects/libs/flex-layout/package.json +++ b/projects/libs/flex-layout/package.json @@ -1,6 +1,6 @@ { "name": "ng-flex-layout", - "version": "18.1.1-beta.1", + "version": "18.1.1-beta.2", "exports": { "./mq": { "sass": "./core/sass/_layout-bp.scss" diff --git a/projects/libs/flex-layout/tsconfig.lib.json b/projects/libs/flex-layout/tsconfig.lib.json index 738ed7db6..dd910a71a 100644 --- a/projects/libs/flex-layout/tsconfig.lib.json +++ b/projects/libs/flex-layout/tsconfig.lib.json @@ -6,7 +6,11 @@ "declaration": true, "declarationMap": false, "inlineSources": true, - "types": ["jasmine"] + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "types": [ + "jasmine" + ] }, "angularCompilerOptions": { "compilationMode": "partial" @@ -15,4 +19,4 @@ "test.ts", "**/*.spec.ts" ] -} +} \ No newline at end of file diff --git a/projects/libs/flex-layout/version.ts b/projects/libs/flex-layout/version.ts index eb695afc3..c492aa666 100644 --- a/projects/libs/flex-layout/version.ts +++ b/projects/libs/flex-layout/version.ts @@ -6,7 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {Version} from '@angular/core'; +import { Version } from '@angular/core'; +import packageJson from './package.json'; /** Current version of Angular Flex-Layout. */ -export const VERSION = new Version('0.0.0-PLACEHOLDER'); +export const VERSION = new Version(packageJson.version); diff --git a/tools/package-tools/build-bundles.ts b/tools/package-tools/build-bundles.ts deleted file mode 100644 index c0d727a22..000000000 --- a/tools/package-tools/build-bundles.ts +++ /dev/null @@ -1,156 +0,0 @@ -import {join} from 'path'; -import {buildConfig} from './build-config'; -import {BuildPackage} from './build-package'; -import {rollupRemoveLicensesPlugin} from './rollup-remove-licenses'; -import {rollupGlobals, dashCaseToCamelCase} from './rollup-globals'; -import {remapSourcemap} from './sourcemap-remap'; - -// There are no type definitions available for these imports. -const rollup = require('rollup'); - -/** Directory where all bundles will be created in. */ -const fesm2015Dir = join(buildConfig.outputDir, 'fesm2015'); -const fesm2020Dir = join(buildConfig.outputDir, 'fesm2020'); - - -/** Utility for creating bundles from raw ngc output. */ -export class PackageBundler { - - /** Name of the AMD module for the primary entry point of the build package. */ - private readonly primaryAmdModuleName: string; - - constructor(private buildPackage: BuildPackage) { - this.primaryAmdModuleName = this.getAmdModuleName(buildPackage.name); - } - - /** Creates all bundles for the package and all associated entry points (UMD, ES5, ES2015). */ - async createBundles() { - for (const entryPoint of this.buildPackage.secondaryEntryPoints) { - await this.bundleSecondaryEntryPoint(entryPoint); - } - - await this.bundlePrimaryEntryPoint(); - } - - /** Bundles the primary entry-point w/ given entry file, e.g. @angular/cdk */ - private async bundlePrimaryEntryPoint() { - const packageName = this.buildPackage.name; - - return this.bundleEntryPoint({ - entryFile: this.buildPackage.entryFilePath, - esm2015EntryFile: join(this.buildPackage.esm2015OutputDir, 'index.js'), - importName: `@angular/${this.buildPackage.name}`, - moduleName: this.primaryAmdModuleName, - esm2015Dest: join(fesm2015Dir, `${packageName}.mjs`), - esm2020Dest: join(fesm2020Dir, `${packageName}.mjs`), - }); - } - - /** Bundles a single secondary entry-point w/ given entry file, e.g. @angular/cdk/a11y */ - private async bundleSecondaryEntryPoint(entryPointName: string) { - const packageName = this.buildPackage.name; - const entryFile = join(this.buildPackage.outputDir, entryPointName, 'index.js'); - const esm2015EntryFile = join(this.buildPackage.esm2015OutputDir, entryPointName, 'index.js'); - - return this.bundleEntryPoint({ - entryFile, - esm2015EntryFile, - importName: `@angular/${this.buildPackage.name}/${entryPointName}`, - moduleName: this.getAmdModuleName(packageName, entryPointName), - esm2015Dest: join(fesm2015Dir, `${packageName}`, `${entryPointName}.mjs`), - esm2020Dest: join(fesm2020Dir, `${packageName}`, `${entryPointName}.mjs`), - }); - } - - /** - * Creates the ES5, ES2015, and UMD bundles for the specified entry-point. - * @param config Configuration that specifies the entry-point, module name, and output - * bundle paths. - */ - private async bundleEntryPoint(config: BundlesConfig) { - // Build FESM-2020 bundle file. - await this.createRollupBundle({ - importName: config.importName, - moduleName: config.moduleName, - entry: config.entryFile, - dest: config.esm2020Dest, - format: 'es', - }); - - // Build FESM-2015 bundle file. - await this.createRollupBundle({ - importName: config.importName, - moduleName: config.moduleName, - entry: config.esm2015EntryFile, - dest: config.esm2015Dest, - format: 'es', - }); - - // Remaps the sourcemaps to be based on top of the original TypeScript source files. - await remapSourcemap(config.esm2020Dest); - await remapSourcemap(config.esm2015Dest); - } - - /** Creates a rollup bundle of a specified JavaScript file.*/ - private async createRollupBundle(config: RollupBundleConfig) { - const bundleOptions = { - context: 'this', - external: Object.keys(rollupGlobals), - input: config.entry, - onwarn: (message: string) => { - // TODO(jelbourn): figure out *why* rollup warns about certain symbols not being found - // when those symbols don't appear to be in the input file in the first place. - if (/but never used/.test(message)) { - return false; - } - - console.warn(message); - }, - plugins: [ - rollupRemoveLicensesPlugin, - ] - }; - - const writeOptions = { - name: config.moduleName || 'ng.flexLayout', - amd: {id: config.importName}, - banner: buildConfig.licenseBanner, - format: config.format, - file: config.dest, - globals: rollupGlobals, - sourcemap: true - }; - - return rollup.rollup(bundleOptions).then((bundle: any) => bundle.write(writeOptions)); - } - - /** Gets the AMD module name for a package and an optional entry point. */ - private getAmdModuleName(packageName: string, entryPointName?: string) { - let amdModuleName = `ng.${dashCaseToCamelCase(packageName)}`; - - if (entryPointName) { - amdModuleName += `.${dashCaseToCamelCase(entryPointName)}`; - } - - return amdModuleName; - } -} - -/** Configuration for creating library bundles. */ -interface BundlesConfig { - entryFile: string; - esm2015EntryFile: string; - importName: string; - moduleName: string; - esm2015Dest: string; - esm2020Dest: string; -} - -/** Configuration for creating a bundle via rollup. */ -interface RollupBundleConfig { - entry: string; - dest: string; - format: string; - moduleName: string; - importName: string; -} diff --git a/tools/package-tools/build-config.ts b/tools/package-tools/build-config.ts deleted file mode 100644 index f0f170ebb..000000000 --- a/tools/package-tools/build-config.ts +++ /dev/null @@ -1,27 +0,0 @@ -import {findBuildConfig} from './find-build-config'; - -export interface BuildConfig { - /** Current version of the project. */ - projectVersion: string; - /** Required Angular version for the project. */ - angularVersion: string; - /** Path to the root of the project. */ - projectDir: string; - /** Path to the directory where all packages are living. */ - packagesDir: string; - /** Path to the directory where the output will be stored. */ - outputDir: string; - /** License banner that will be placed inside of every bundle. */ - licenseBanner: string; -} - -// Search for a build config by walking up the current working directory of the Node process. -const buildConfigPath = findBuildConfig(); - -if (!buildConfigPath) { - throw 'Flex Layout Build tools were not able to find a build config. ' + - 'Please create a "build-config.js" file in your project.'; -} - -// Load the config file using a basic CommonJS import. -export const buildConfig = require(buildConfigPath) as BuildConfig; diff --git a/tools/package-tools/build-notes.md b/tools/package-tools/build-notes.md deleted file mode 100644 index f3a397436..000000000 --- a/tools/package-tools/build-notes.md +++ /dev/null @@ -1,20 +0,0 @@ -In order to ensure our source maps trace back properly (and code -size analysis tools can use these maps), we have made some changes -to our build process. These changes will align with angular/angular's -build process while we wait to update to Angular 5.x. - -* Instead of downleveling to ES2015, creating a Rollup bundle, then -transpiling that bundle down to ES5, we now downlevel to both ES2015 -and ES5, then create separate Rollup bundles for each. Note: We have to -use NGC for both ES2015 and ES5 downleveling (rather than using TSC for -the second pass and copying over flat files) because TSC generates -decorator code that build-optimizer is not designed to support. For now, -decorators must be passed through NGC. - -* We are removing sorcery until we can upgrade tsickle and ngc to latest. -Our versions of these break when mapping all the way back to TS. -(temporary) - -* We have to add separate tsconfigs for transpiling to ES5 because our -version of ngc doesn't allow overrides. When we update to compiler-cli -5.x, we should be able to remove these files. (temporary) diff --git a/tools/package-tools/find-build-config.ts b/tools/package-tools/find-build-config.ts deleted file mode 100644 index efea9145e..000000000 --- a/tools/package-tools/find-build-config.ts +++ /dev/null @@ -1,22 +0,0 @@ -import {resolve, dirname, join} from 'path'; -import {existsSync} from 'fs'; - -/** Name of the build config file. */ -const BUILD_CONFIG_FILENAME = 'build-config.js'; - -/** Method that searches for a build config file that will be used for packaging. */ -export function findBuildConfig(): string | null { - let currentDir = process.cwd(); - - while (!existsSync(resolve(currentDir, BUILD_CONFIG_FILENAME))) { - let parentDir = dirname(currentDir); - - if (parentDir === currentDir) { - return null; - } - - currentDir = parentDir; - } - - return join(currentDir, BUILD_CONFIG_FILENAME); -} diff --git a/tools/package-tools/tsconfig.json b/tools/package-tools/tsconfig.json deleted file mode 100644 index bc115ad5e..000000000 --- a/tools/package-tools/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noUnusedParameters": true, - "lib": ["es2020", "dom"], - "module": "commonjs", - "moduleResolution": "node", - "esModuleInterop": true, - "outDir": "../../dist/tools/gulp", - "noUnusedLocals": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictPropertyInitialization": true, - "noImplicitThis": true, - "noEmitOnError": true, - "noImplicitAny": true, - "target": "es2020", - "removeComments": true, - "types": [ - "node" - ], - "baseUrl": ".", - } -} diff --git a/tools/package-tools/version-placeholders.ts b/tools/package-tools/version-placeholders.ts deleted file mode 100644 index 04c7ecae4..000000000 --- a/tools/package-tools/version-placeholders.ts +++ /dev/null @@ -1,62 +0,0 @@ -import {readFileSync, writeFileSync} from 'fs'; -import {platform} from 'os'; -import {buildConfig} from './build-config'; -import {spawnSync} from 'child_process'; - -/** Variable that is set to the string for version placeholders. */ -const versionPlaceholderText = '0.0.0-PLACEHOLDER'; - -/** Placeholder that will be replaced with the required Angular version. */ -const ngVersionPlaceholderText = '0.0.0-NG'; - -/** RegExp that matches version placeholders inside of a file. */ -const ngVersionPlaceholderRegex = new RegExp(ngVersionPlaceholderText, 'g'); - -/** Expression that matches Angular version placeholders within a file. */ -const versionPlaceholderRegex = new RegExp(versionPlaceholderText, 'g'); - -/** - * Walks through every file in a directory and replaces the version placeholders with the current - * version of Library. - */ -export function replaceVersionPlaceholders(packageDir: string) { - // Resolve files that contain version placeholders using Grep or Findstr since those are - // extremely fast and also have a very simple usage. - const files = findFilesWithPlaceholders(packageDir); - - // Walk through every file that contains version placeholders and replace those with the current - // version of the root package.json file. - files.forEach(filePath => { - const fileContent = readFileSync(filePath, 'utf-8') - .replace(ngVersionPlaceholderRegex, buildConfig.angularVersion) - .replace(versionPlaceholderRegex, buildConfig.projectVersion); - - writeFileSync(filePath, fileContent); - }); -} - -/** Finds all files in the specified package dir where version placeholders are included. */ -function findFilesWithPlaceholders(packageDir: string): string[] { - const findCommand = buildPlaceholderFindCommand(packageDir); - return spawnSync(findCommand.binary, findCommand.args).stdout - .toString() - .split(/[\n\r]/) - .filter(String); -} - -/** Builds the command that will be executed to find all files containing version placeholders. */ -function buildPlaceholderFindCommand(packageDir: string) { - if (platform() === 'win32') { - return { - binary: 'findstr', - args: ['/msi', `${ngVersionPlaceholderText} ${versionPlaceholderText}`, `${packageDir}\\*`] - }; - } else { - return { - binary: 'grep', - args: ['-ril', `${ngVersionPlaceholderText}\\|${versionPlaceholderText}`, packageDir] - }; - } -} - -replaceVersionPlaceholders('./dist/releases/flex-layout'); diff --git a/tools/tslint-rules/noExposedTodoRule.ts b/tools/tslint-rules/noExposedTodoRule.ts deleted file mode 100644 index 4c5a8b795..000000000 --- a/tools/tslint-rules/noExposedTodoRule.ts +++ /dev/null @@ -1,34 +0,0 @@ -// import ts from 'typescript'; -// import {Rules, RuleWalker} from 'tslint'; -// import {forEachComment} from 'tsutils'; - -// const ERROR_MESSAGE = -// 'A TODO may only appear in inline (//) style comments. ' + -// 'This is meant to prevent a TODO from being accidentally included in any public API docs.'; - -// /** -// * Rule that walks through all comments inside of the library and adds failures when it -// * detects TODO's inside of multi-line comments. TODOs need to be placed inside of single-line -// * comments. -// */ -// export class Rule extends Rules.AbstractRule { - -// apply(sourceFile: ts.SourceFile) { -// return this.applyWithWalker(new NoExposedTodoWalker(sourceFile, this.getOptions())); -// } -// } - -// class NoExposedTodoWalker extends RuleWalker { - -// visitSourceFile(sourceFile: ts.SourceFile) { -// forEachComment(sourceFile, (text, commentRange) => { -// const isTodoComment = text.substring(commentRange.pos, commentRange.end).includes('TODO:'); - -// if (commentRange.kind === ts.SyntaxKind.MultiLineCommentTrivia && isTodoComment) { -// this.addFailureAt(commentRange.pos, commentRange.end - commentRange.pos, ERROR_MESSAGE); -// } -// }); - -// super.visitSourceFile(sourceFile); -// } -// } diff --git a/tools/tslint-rules/noRxjsPatchImportsRule.ts b/tools/tslint-rules/noRxjsPatchImportsRule.ts deleted file mode 100644 index 679c88dd4..000000000 --- a/tools/tslint-rules/noRxjsPatchImportsRule.ts +++ /dev/null @@ -1,44 +0,0 @@ -// import path from 'path'; -// import ts from 'typescript'; -// import {IOptions, Rules, RuleWalker} from 'eslint'; -// import minimatch from 'minimatch'; - -// const ERROR_MESSAGE = 'Uses of RxJS patch imports are forbidden.'; - -// /** -// * Rule that prevents uses of RxJS patch imports (e.g. `import 'rxjs/add/operator/map'). -// * Supports allowing usage in specific files via `"no-patch-imports": [true, "\.spec\.ts$"]`. -// */ -// export class Rule extends Rules.AbstractRule { -// apply(sourceFile: ts.SourceFile) { -// return this.applyWithWalker(new Walker(sourceFile, this.getOptions())); -// } -// } - -// class Walker extends RuleWalker { - -// /** Whether the walker should check the current source file. */ -// private _enabled: boolean; - -// constructor(sourceFile: ts.SourceFile, options: IOptions) { -// super(sourceFile, options); - -// // Globs that are used to determine which files to lint. -// const fileGlobs = options.ruleArguments || []; - -// // Relative path for the current TypeScript source file. -// const relativeFilePath = path.relative(process.cwd(), sourceFile.fileName); - -// // Whether the file should be checked at all. -// this._enabled = fileGlobs.some(p => minimatch(relativeFilePath, p)); -// } - -// visitImportDeclaration(node: ts.ImportDeclaration) { -// // Walk through the imports and check if they start with `rxjs/add`. -// if (this._enabled && node.moduleSpecifier.getText().startsWith('rxjs/add', 1)) { -// this.addFailureAtNode(node, ERROR_MESSAGE); -// } - -// super.visitImportDeclaration(node); -// } -// } diff --git a/tools/tslint-rules/noViewEncapsulationRule.ts b/tools/tslint-rules/noViewEncapsulationRule.ts deleted file mode 100644 index 3b92c3e1b..000000000 --- a/tools/tslint-rules/noViewEncapsulationRule.ts +++ /dev/null @@ -1,59 +0,0 @@ -// import path from 'path'; -// import ts from 'typescript'; -// import {IOptions, Rules, RuleWalker} from 'tslint'; -// import minimatch from 'minimatch'; - -// const ERROR_MESSAGE = 'Components must turn off view encapsulation.'; - -// // TODO(crisbeto): combine this with the OnPush rule when it gets in. - -// /** -// * Rule that enforces that view encapsulation is turned off on all components. -// * Supports allowing usage in specific files via `"no-view-encapsulation": [true, "\.spec\.ts$"]`. -// */ -// export class Rule extends Rules.AbstractRule { -// apply(sourceFile: ts.SourceFile) { -// return this.applyWithWalker(new Walker(sourceFile, this.getOptions())); -// } -// } - -// class Walker extends RuleWalker { - -// /** Whether the walker should check the current source file. */ -// private _enabled: boolean; - -// constructor(sourceFile: ts.SourceFile, options: IOptions) { -// super(sourceFile, options); - -// // Globs that are used to determine which files to lint. -// const fileGlobs = options.ruleArguments || []; - -// // Relative path for the current TypeScript source file. -// const relativeFilePath = path.relative(process.cwd(), sourceFile.fileName); - -// // Whether the file should be checked at all. -// this._enabled = fileGlobs.some(p => minimatch(relativeFilePath, p)); -// } - -// visitClassDeclaration(node: ts.ClassDeclaration) { -// if (!this._enabled || !node.decorators) { -// return; -// } - -// node.decorators -// .map(decorator => decorator.expression as any) -// .filter(expression => expression.expression.getText() === 'Component') -// .filter(expression => expression.arguments.length && expression.arguments[0].properties) -// .forEach(expression => { -// const hasTurnedOffEncapsulation = expression.arguments[0].properties.some((prop: any) => { -// const value = prop.initializer.getText(); -// return prop.name.getText() === 'encapsulation' && value.endsWith('.None'); -// }); - -// if (!hasTurnedOffEncapsulation) { -// this.addFailureAtNode(expression.parent, ERROR_MESSAGE); -// } -// }); -// } - -// } diff --git a/tools/tslint-rules/requireBreakingChangeVersionRule.ts b/tools/tslint-rules/requireBreakingChangeVersionRule.ts deleted file mode 100644 index b8455919f..000000000 --- a/tools/tslint-rules/requireBreakingChangeVersionRule.ts +++ /dev/null @@ -1,38 +0,0 @@ -// import ts from 'typescript'; -// import {Rules, RuleFailure, WalkContext} from 'tslint'; -// import {forEachComment} from 'tsutils'; - -// /** Doc tag that can be used to indicate a breaking change. */ -// const BREAKING_CHANGE = '@breaking-change'; - -// /** Name of the old doc tag that was being used to indicate a breaking change. */ -// const DELETION_TARGET = '@deletion-target'; - -// /** -// * Rule that ensures that comments, indicating a deprecation -// * or a breaking change, have a valid version. -// */ -// export class Rule extends Rules.AbstractRule { -// apply(sourceFile: ts.SourceFile): RuleFailure[] { -// return this.applyWithFunction(sourceFile, (ctx: WalkContext) => { -// forEachComment(ctx.sourceFile, (file, {pos, end}) => { -// const commentText = file.substring(pos, end); - -// // TODO(crisbeto): remove this check once most of the pending -// // PRs start using `breaking-change`. -// if (commentText.indexOf(DELETION_TARGET) > -1) { -// ctx.addFailure(pos, end, `${DELETION_TARGET} has been replaced with ${BREAKING_CHANGE}.`); -// return; -// } - -// const hasBreakingChange = commentText.indexOf(BREAKING_CHANGE) > -1; - -// if (!hasBreakingChange && commentText.indexOf('@deprecated') > -1) { -// ctx.addFailure(pos, end, `@deprecated marker has to have a ${BREAKING_CHANGE}.`); -// } if (hasBreakingChange && !/\d+\.\d+\.\d+/.test(commentText)) { -// ctx.addFailure(pos, end, `${BREAKING_CHANGE} must have a version.`); -// } -// }); -// }); -// } -// } diff --git a/tools/tslint-rules/requireLicenseBannerRule.ts b/tools/tslint-rules/requireLicenseBannerRule.ts deleted file mode 100644 index 2a5c07b0e..000000000 --- a/tools/tslint-rules/requireLicenseBannerRule.ts +++ /dev/null @@ -1,61 +0,0 @@ -// import path from 'path'; -// import ts from 'typescript'; -// import {IOptions, Replacement, Rules, RuleWalker} from 'tslint'; -// import minimatch from 'minimatch'; - -// const buildConfig = require('../../build-config'); - -// /** License banner that is placed at the top of every public TypeScript file. */ -// const licenseBanner = buildConfig.licenseBanner; - -// /** Failure message that will be shown if a license banner is missing. */ -// const ERROR_MESSAGE = 'Missing license header in this TypeScript file. ' + -// 'Every TypeScript file of the library needs to have the Google license banner at the top.'; - -// /** TSLint fix that can be used to add the license banner easily. */ -// const tslintFix = Replacement.appendText(0, licenseBanner + '\n\n'); - -// /** -// * Rule that walks through all TypeScript files of public packages and shows failures if a -// * file does not have the license banner at the top of the file. -// */ -// export class Rule extends Rules.AbstractRule { - -// apply(sourceFile: ts.SourceFile) { -// return this.applyWithWalker(new RequireLicenseBannerWalker(sourceFile, this.getOptions())); -// } -// } - -// class RequireLicenseBannerWalker extends RuleWalker { - -// /** Whether the walker should check the current source file. */ -// private _enabled: boolean; - -// constructor(sourceFile: ts.SourceFile, options: IOptions) { -// super(sourceFile, options); - -// // Globs that are used to determine which files to lint. -// const fileGlobs = options.ruleArguments; - -// // Relative path for the current TypeScript source file. -// const relativeFilePath = path.relative(process.cwd(), sourceFile.fileName); - -// // Whether the file should be checked at all. -// this._enabled = fileGlobs.some(p => minimatch(relativeFilePath, p)); -// } - -// visitSourceFile(sourceFile: ts.SourceFile) { -// if (!this._enabled) { -// return; -// } - -// const fileContent = sourceFile.getFullText(); -// const licenseCommentPos = fileContent.indexOf(licenseBanner); - -// if (licenseCommentPos !== 0) { -// return this.addFailureAt(0, 0, ERROR_MESSAGE, tslintFix); -// } - -// super.visitSourceFile(sourceFile); -// } -// } diff --git a/tools/tslint-rules/tsLoaderRule.js b/tools/tslint-rules/tsLoaderRule.js deleted file mode 100644 index 1dd7a3253..000000000 --- a/tools/tslint-rules/tsLoaderRule.js +++ /dev/null @@ -1,13 +0,0 @@ -// const path = require('path'); -// const Lint = require('tslint'); - -// // Custom rule that registers all of the custom rules, written in TypeScript, with ts-node. -// // This is necessary, because `tslint` and IDEs won't execute any rules that aren't in a .js file. -// require('ts-node').register({ -// project: path.join(__dirname, './tsconfig.json') -// }); - -// // Add a noop rule so tslint doesn't complain. -// exports.Rule = class Rule extends Lint.Rules.AbstractRule { -// apply() {} -// } diff --git a/tools/tslint-rules/tsconfig.json b/tools/tslint-rules/tsconfig.json deleted file mode 100644 index bc115ad5e..000000000 --- a/tools/tslint-rules/tsconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "noUnusedParameters": true, - "lib": ["es2020", "dom"], - "module": "commonjs", - "moduleResolution": "node", - "esModuleInterop": true, - "outDir": "../../dist/tools/gulp", - "noUnusedLocals": true, - "strictNullChecks": true, - "strictFunctionTypes": true, - "strictPropertyInitialization": true, - "noImplicitThis": true, - "noEmitOnError": true, - "noImplicitAny": true, - "target": "es2020", - "removeComments": true, - "types": [ - "node" - ], - "baseUrl": ".", - } -} diff --git a/tools/tslint-rules/validateDecoratorsRule.ts b/tools/tslint-rules/validateDecoratorsRule.ts deleted file mode 100644 index 75abc2039..000000000 --- a/tools/tslint-rules/validateDecoratorsRule.ts +++ /dev/null @@ -1,119 +0,0 @@ -// import path from 'path'; -// import ts from 'typescript'; -// import {IOptions, Rules, RuleWalker} from 'tslint'; -// import minimatch from 'minimatch'; - -// /** -// * Rule that enforces certain decorator properties to be defined and to match a pattern. -// * Supports allowing usage in specific files via the third argument. E.g. -// * -// * ``` -// * "validate-decorators": [true, { -// * "Component": { -// * "encapsulation": "\\.None$" -// * } -// * }, "src/lib"] -// * ``` -// */ -// export class Rule extends Rules.AbstractRule { -// apply(sourceFile: ts.SourceFile) { -// return this.applyWithWalker(new Walker(sourceFile, this.getOptions())); -// } -// } - -// /** Rules that can be used to validate the decorators in a file. */ -// type DecoratorRules = {[key: string]: {[key: string]: RegExp}}; - -// class Walker extends RuleWalker { -// // Whether the file should be checked at all. -// private _enabled: boolean; - -// // Rules that will be used to validate the decorators. -// private _rules: DecoratorRules; - -// constructor(sourceFile: ts.SourceFile, options: IOptions) { -// super(sourceFile, options); - -// // Globs that are used to determine which files to lint. -// const fileGlobs = options.ruleArguments.slice(1) || []; - -// // Relative path for the current TypeScript source file. -// const relativeFilePath = path.relative(process.cwd(), sourceFile.fileName); - -// this._rules = this._generateRules(options.ruleArguments[0]); -// this._enabled = Object.keys(this._rules).length > 0 && -// fileGlobs.some(p => minimatch(relativeFilePath, p)); -// } - -// visitClassDeclaration(node: ts.ClassDeclaration) { -// if (this._enabled && ts.canHaveDecorators(node)) { -// ts.getDecorators(node)! -// .map(decorator => decorator.expression as any) -// .filter(expression => expression.arguments.length && expression.arguments[0].properties) -// .forEach(expression => this._validatedDecorator(expression)); -// } - -// super.visitClassDeclaration(node); -// } - -// /** -// * Validates that a decorator matches all of the defined rules. -// * @param decorator Decorator to be checked. -// */ -// private _validatedDecorator(decorator: any) { -// // Get the rules that are relevant for the current decorator. -// const rules = this._rules[decorator.expression.getText()]; - -// // Don't do anything if there are no rules. -// if (!rules) { -// return; -// } - -// // Extract the property names and values. -// const props = decorator.arguments[0].properties.map((node: ts.PropertyAssignment) => ({ -// name: node.name.getText(), -// value: node.initializer.getText(), -// node -// })); - -// // Find all of the rule properties that are missing from the decorator. -// const missing = Object.keys(rules).filter(key => !props.find((prop: any) => prop.name === key)); - -// if (missing.length) { -// // Exit early if any of the properties are missing. -// this.addFailureAtNode(decorator.parent, 'Missing required properties: ' + missing.join(', ')); -// } else { -// // If all the necessary properties are defined, ensure that they match the pattern. -// props -// .filter((prop: any) => rules[prop.name]) -// .filter((prop: any) => !rules[prop.name].test(prop.value)) -// .forEach((prop: any) => { -// this.addFailureAtNode(prop.node, -// `Invalid value for property. Expected value to match "${rules[prop.name]}".`); -// }); -// } -// } - -// /** -// * Cleans out the blank rules that are passed through the tslint.json -// * and converts the string patterns into regular expressions. -// * @param config Config object passed in via the tslint.json. -// * @returns Sanitized rules. -// */ -// private _generateRules(config: {[key: string]: {[key: string]: string}}): DecoratorRules { -// const output: DecoratorRules = {}; - -// if (config) { -// Object.keys(config) -// .filter(decoratorName => Object.keys(config[decoratorName]).length > 0) -// .forEach(decoratorName => { -// output[decoratorName] = Object.keys(config[decoratorName]).reduce((accumulator, prop) => { -// accumulator[prop] = new RegExp(config[decoratorName][prop]); -// return accumulator; -// }, {} as {[key: string]: RegExp}); -// }); -// } - -// return output; -// } -// }