[ACS-7429] cleanup APS1 task-list before refactorings (#9650)

This commit is contained in:
Denys Vuika
2024-05-07 14:51:56 -04:00
committed by GitHub
parent e749473a32
commit 20ee286902
42 changed files with 266 additions and 992 deletions

View File

@@ -1,7 +0,0 @@
/npm-debug.log
/.idea
node_modules
coverage
/temp/
local.log
/rules/*.js

View File

@@ -1,15 +0,0 @@
.idea
coverage/
node_modules
temp/
test/
/.editorconfig
/gulpfile.js
/.npmignore
*.tgz
/assets/
local.log

View File

@@ -1,36 +0,0 @@
# adf-tslint-rules
A set of [TSLint](https://github.com/palantir/tslint) rules used on [ADF](https://github.com/Alfresco/alfresco-ng2-components) project.
## Installation
```sh
npm install adf-tslint-rules
```
## Configuration
```javascript
{
"rulesDirectory": [
"node_modules/codelyzer",
"node_modules/adf-tslint-rules"
],
"rules": {
"adf-file-name": true,
"adf-class-name": true,
"adf-no-on-prefix-output-name": true
}
}
```
Supported Rules
-----
Rule Name | Description |
---------- | ------------ |
`adf-file-name` | The name of the File should not start with ADF Alfresco or Activiti prefix |
`adf-class-name` | The name of the class should not start with ADF Alfresco or Activiti prefix |
`adf-no-on-prefix-output-name` | Angular allows for an alternative syntax on-*. If the event itself was prefixed with on this would result in an on-onEvent binding expression |
|

View File

@@ -1,44 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Lint = require("tslint");
const sprintf_js_1 = require("sprintf-js");
const walkerFactory_1 = require("codelyzer/walkerFactory/walkerFactory");
const walkerFn_1 = require("codelyzer/walkerFactory/walkerFn");
const function_1 = require("codelyzer/util/function");
class Rule extends Lint.Rules.AbstractRule {
static invalidName(className) {
var whiteList = ['ActivitiContentComponent', 'ActivitiForm'];
var classNameReg = /^(alfresco|activiti|adf|activity)/ig;
var classNameMatch = classNameReg.exec(className);
var isWhiteListName = whiteList.find((currentWhiteListName) => {
return currentWhiteListName === className;
});
if (classNameMatch && !isWhiteListName) {
return true;
}
return false;
}
apply(sourceFile) {
return this.applyWithWalker(Rule.walkerBuilder(sourceFile, this.getOptions()));
}
}
Rule.metadata = {
ruleName: 'adf-class-name',
type: 'maintainability',
description: `Enforce consistent name avoid prefix`,
descriptionDetails: `See more at https://angular.io/styleguide#style-05-13.`,
rationale: `Consistent conventions make it easy to quickly identify class when you search with autocomplete.`,
options: null,
optionsDescription: "Not configurable.",
typescriptOnly: true,
};
Rule.FAILURE_STRING = 'The name of the class should not start with ADF Alfresco or Activiti prefix ';
Rule.walkerBuilder = walkerFn_1.all(walkerFn_1.validateComponent((meta, suffixList) => function_1.Maybe.lift(meta.controller)
.fmap(controller => controller.name)
.fmap(name => {
const className = name.text;
if (Rule.invalidName(className)) {
return [new walkerFactory_1.Failure(name, sprintf_js_1.sprintf(Rule.FAILURE_STRING + className, className, suffixList))];
}
})));
exports.Rule = Rule;

View File

@@ -1,78 +0,0 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as Lint from 'tslint';
import * as ts from 'typescript';
import { sprintf } from 'sprintf-js';
import { ComponentMetadata } from 'codelyzer/angular/metadata';
import { Failure } from 'codelyzer/walkerFactory/walkerFactory';
import { all, validateComponent } from 'codelyzer/walkerFactory/walkerFn';
import { Maybe, F2 } from 'codelyzer/util/function';
import { IOptions } from 'tslint';
import { NgWalker } from 'codelyzer/angular/ngWalker';
export class Rule extends Lint.Rules.AbstractRule {
public static metadata: Lint.IRuleMetadata = {
ruleName: 'adf-class-name',
type: 'maintainability',
description: `Enforce consistent name avoid prefix`,
descriptionDetails: `See more at https://angular.io/styleguide#style-05-13.`,
rationale: `Consistent conventions make it easy to quickly identify class when you search with autocomplete.`,
options: null,
optionsDescription: "Not configurable.",
typescriptOnly: true,
};
public static FAILURE_STRING = 'The name of the class should not start with ADF Alfresco or Activiti prefix ';
static walkerBuilder: F2<ts.SourceFile, IOptions, NgWalker> =
all(
validateComponent((meta: ComponentMetadata, suffixList?: string[]) =>
Maybe.lift(meta.controller)
.fmap(controller => controller.name)
.fmap(name => {
const className = name.text;
if (Rule.invalidName(className)) {
return [new Failure(name, sprintf(Rule.FAILURE_STRING + className, className, suffixList))];
}
})
));
static invalidName(className: string): boolean {
var whiteList = ['ActivitiContentComponent', 'ActivitiForm'];
var classNameReg = /^(alfresco|activiti|adf|activity)/ig;
var classNameMatch = classNameReg.exec(className);
var isWhiteListName = whiteList.find((currentWhiteListName) => {
return currentWhiteListName === className;
});
if (classNameMatch && !isWhiteListName) {
return true;
}
return false;
}
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(
Rule.walkerBuilder(sourceFile, this.getOptions())
);
}
}

View File

@@ -1,55 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Lint = require("tslint");
class Rule extends Lint.Rules.AbstractRule {
apply(sourceFile) {
return this.applyWithWalker(new AdfFileName(sourceFile, this.getOptions()));
}
}
Rule.metadata = {
ruleName: 'adf-file-name',
type: 'maintainability',
description: `Enforce consistent name avoid prefix`,
descriptionDetails: `See more at https://angular.io/styleguide#style-05-13.`,
rationale: `Consistent conventions make it easy to quickly identify files when you search with autocomplete.`,
options: null,
optionsDescription: "Not configurable.",
typescriptOnly: true,
};
Rule.FAILURE_STRING = 'The name of the File should not start with ADF Alfresco or Activiti prefix ';
Rule.FAILURE_STRING_UNDERSCORE = 'The name of the File should not have _ in the name but you can use - prefer the kebab case';
Rule.FAILURE_STRING_UPPERCASE = 'The name of the File should not start with uppercase';
exports.Rule = Rule;
class AdfFileName extends Lint.RuleWalker {
visitSourceFile(node) {
var whiteList = ['activiti-alfresco.service.ts', 'activiti-alfresco.service.spec.ts',
'alfresco-api.service.ts', 'alfresco-api.service.spects'];
var fileName = this.getFilename();
var fileNameReg = /^(alfresco|activiti|adf|activity)/ig;
var filenameMatch = fileNameReg.exec(fileName);
var isWhiteListName = whiteList.find((currentWhiteListName) => {
return currentWhiteListName === fileName;
});
if (filenameMatch && !isWhiteListName) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING + fileName));
super.visitSourceFile(node);
}
if (fileName.indexOf('_') >= 0) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING_UNDERSCORE + fileName));
super.visitSourceFile(node);
}
if (fileName[0] == fileName[0].toUpperCase()) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING_UPPERCASE + fileName));
super.visitSourceFile(node);
}
}
getFilename() {
const filename = this.getSourceFile().fileName;
const lastSlash = filename.lastIndexOf('/');
if (lastSlash > -1) {
return filename.substring(lastSlash + 1);
}
return filename;
}
}

View File

@@ -1,66 +0,0 @@
import * as ts from "typescript";
import * as Lint from "tslint";
export class Rule extends Lint.Rules.AbstractRule {
public static metadata: Lint.IRuleMetadata = {
ruleName: 'adf-file-name',
type: 'maintainability',
description: `Enforce consistent name avoid prefix`,
descriptionDetails: `See more at https://angular.io/styleguide#style-05-13.`,
rationale: `Consistent conventions make it easy to quickly identify files when you search with autocomplete.`,
options: null,
optionsDescription: "Not configurable.",
typescriptOnly: true,
};
public static FAILURE_STRING = 'The name of the File should not start with ADF Alfresco or Activiti prefix ';
public static FAILURE_STRING_UNDERSCORE = 'The name of the File should not have _ in the name but you can use - ';
public static FAILURE_STRING_UPPERCASE = 'The name of the File should not start with uppercase';
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(new AdfFileName(sourceFile, this.getOptions()));
}
}
// The walker takes care of all the work.
class AdfFileName extends Lint.RuleWalker {
public visitSourceFile(node: ts.SourceFile) {
var whiteList = ['activiti-alfresco.service.ts', 'activiti-alfresco.service.spec.ts',
'alfresco-api.service.ts', 'alfresco-api.service.spects'];
var fileName = this.getFilename();
var fileNameReg = /^(alfresco|activiti|adf|activity)/ig;
var filenameMatch = fileNameReg.exec(fileName);
var isWhiteListName = whiteList.find((currentWhiteListName) => {
return currentWhiteListName === fileName;
});
console.log('error');
if (filenameMatch && !isWhiteListName) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING + fileName));
super.visitSourceFile(node);
}
if (fileName.indexOf('-') >= 0) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING_UNDERSCORE + fileName));
super.visitSourceFile(node);
}
if (fileName[0] == fileName[0].toUpperCase()) {
this.addFailure(this.createFailure(node.getStart(), node.getWidth(), Rule.FAILURE_STRING_UPPERCASE + fileName));
super.visitSourceFile(node);
}
}
private getFilename(): string {
const filename = this.getSourceFile().fileName;
const lastSlash = filename.lastIndexOf('/');
if (lastSlash > -1) {
return filename.substring(lastSlash + 1);
}
return filename;
}
}

View File

@@ -1,34 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Lint = require("tslint");
const sprintf_js_1 = require("sprintf-js");
const ngWalker_1 = require("codelyzer/angular/ngWalker");
class Rule extends Lint.Rules.AbstractRule {
apply(sourceFile) {
return this.applyWithWalker(new ADFOutputPrefixNameRule(sourceFile, this.getOptions()));
}
}
Rule.metadata = {
ruleName: 'adf-prefix-name',
type: 'maintainability',
description: `Name events without the prefix on`,
descriptionDetails: `See more at https://angular.io/guide/styleguide#dont-prefix-output-properties`,
rationale: `Angular allows for an alternative syntax on-*. If the event itself was prefixed with on this would result in an on-onEvent binding expression`,
options: null,
optionsDescription: `Not configurable.`,
typescriptOnly: true,
};
Rule.FAILURE_STRING = 'In the class "%s", the output ' +
'property "%s" should not be prefixed with on';
exports.Rule = Rule;
class ADFOutputPrefixNameRule extends ngWalker_1.NgWalker {
visitNgOutput(property, output, args) {
let className = property.parent.name.text;
let memberName = property.name.text;
if (memberName && memberName.startsWith('on')) {
let failureConfig = [className, memberName];
failureConfig.unshift(Rule.FAILURE_STRING);
this.addFailure(this.createFailure(property.getStart(), property.getWidth(), sprintf_js_1.sprintf.apply(this, failureConfig)));
}
}
}

View File

@@ -1,60 +0,0 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import * as Lint from 'tslint';
import * as ts from 'typescript';
import { sprintf } from 'sprintf-js';
import { NgWalker } from 'codelyzer/angular/ngWalker';
export class Rule extends Lint.Rules.AbstractRule {
public static metadata: Lint.IRuleMetadata = {
ruleName: 'adf-prefix-name',
type: 'maintainability',
description: `Name events without the prefix on`,
descriptionDetails: `See more at https://angular.io/guide/styleguide#dont-prefix-output-properties`,
rationale: `Angular allows for an alternative syntax on-*. If the event itself was prefixed with on this would result in an on-onEvent binding expression`,
options: null,
optionsDescription: `Not configurable.`,
typescriptOnly: true
};
static FAILURE_STRING: string = 'In the class "%s", the output ' +
'property "%s" should not be prefixed with on';
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
return this.applyWithWalker(
new ADFOutputPrefixNameRule(sourceFile,
this.getOptions()));
}
}
class ADFOutputPrefixNameRule extends NgWalker {
visitNgOutput(property: ts.PropertyDeclaration, output: ts.Decorator, args: string[]) {
const className = (<any>property).parent.name.text;
const memberName = (<any>property.name).text;
if (memberName && memberName.startsWith('on')) {
const failureConfig: string[] = [className, memberName];
failureConfig.unshift(Rule.FAILURE_STRING);
this.addFailure(
this.createFailure(
property.getStart(),
property.getWidth(),
sprintf.apply(this, failureConfig)));
}
}
}

View File

@@ -1,9 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var adfClassNameRule_1 = require("./adfClassNameRule");
exports.ADFClassNameRule = adfClassNameRule_1.Rule;
var adfFileNameRule_1 = require("./adfFileNameRule");
exports.ADFComponentSelectorRule = adfFileNameRule_1.Rule;
var adfPrefixNameRule_1 = require("./adfPrefixNameRule");
exports.ADFOutputPrefixNameRule = adfPrefixNameRule_1.Rule;
exports.rulesDirectory = '.';

View File

@@ -1,22 +0,0 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { Rule as ADFClassNameRule } from './adfClassNameRule';
export { Rule as ADFComponentSelectorRule } from './adfFileNameRule';
export { Rule as ADFOutputPrefixNameRule } from './adfPrefixNameRule';
export const rulesDirectory = '.';

View File

@@ -1,108 +0,0 @@
{
"name": "adf-tslint-rules",
"version": "0.0.7",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"app-root-path": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/app-root-path/-/app-root-path-2.0.1.tgz",
"integrity": "sha1-zWLc+OT9WkF+/GZNLlsQZTxlG0Y="
},
"css-selector-tokenizer": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.7.0.tgz",
"integrity": "sha1-5piEdK6MlTR3v15+/s/OzNnPTIY=",
"requires": {
"cssesc": "^0.1.0",
"fastparse": "^1.1.1",
"regexpu-core": "^1.0.0"
}
},
"cssauron": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/cssauron/-/cssauron-1.4.0.tgz",
"integrity": "sha1-pmAt/34EqDBtwNuaVR6S6LVmKtg=",
"requires": {
"through": "X.X.X"
}
},
"cssesc": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/cssesc/-/cssesc-0.1.0.tgz",
"integrity": "sha1-yBSQPkViM3GgR3tAEJqq++6t27Q="
},
"fastparse": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.1.tgz",
"integrity": "sha1-0eJkOzipTXWDtHkGDmxK/8lAcfg="
},
"jsesc": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz",
"integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0="
},
"regenerate": {
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.2.tgz",
"integrity": "sha1-0ZQcZ7rUN+G+dkM63Vs4X5WxkmA="
},
"regexpu-core": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-1.0.0.tgz",
"integrity": "sha1-hqdj9Y7k18L2sQLkdkBQ3n7ZDGs=",
"requires": {
"regenerate": "^1.2.1",
"regjsgen": "^0.2.0",
"regjsparser": "^0.1.4"
}
},
"regjsgen": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz",
"integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc="
},
"regjsparser": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz",
"integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=",
"requires": {
"jsesc": "~0.5.0"
}
},
"semver": {
"version": "5.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
"integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g=="
},
"semver-dsl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/semver-dsl/-/semver-dsl-1.0.1.tgz",
"integrity": "sha1-02eN5VVeimH2Ke7QJTZq5fJzQKA=",
"requires": {
"semver": "^5.3.0"
}
},
"source-map": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.6.tgz",
"integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI="
},
"sprintf-js": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw="
},
"through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU="
},
"typescript": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.4.0.tgz",
"integrity": "sha1-rvWo1AS+ujatM5q/B53d3/+6ht0=",
"dev": true
}
}
}

View File

@@ -1,34 +0,0 @@
{
"name": "adf-tslint-rules",
"description": "Custom Rules for the ADF project",
"version": "0.0.7",
"author": "Hyland Software, Inc. and its affiliates",
"scripts": {
"build": "tsc",
"tscv": "tsc --version",
"tsc": "tsc",
"tsc:watch": "tsc --w"
},
"contributors": [
{
"name": "Eugenio Romano",
"email": "eugenio.romano@alfresco.com"
}
],
"devDependencies": {
"typescript": "2.4.0"
},
"peerDependencies": {
"tslint": ">=5.0.0",
"codelyzer": ">=4.5.0"
},
"dependencies": {
"app-root-path": "2.0.1",
"css-selector-tokenizer": "0.7.0",
"cssauron": "1.4.0",
"semver-dsl": "1.0.1",
"source-map": "0.5.6",
"sprintf-js": "1.0.3"
},
"license": "Apache-2.0"
}

View File

@@ -1,22 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"target": "es6",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"removeComments": true,
"lib": ["es6", "es2015", "dom"],
"noLib": false,
"typeRoots": [
"./node_modules/@types",
"./node_modules"
],
"types": [
"mocha",
"chai",
"node",
"sprintf-js"
]
}
}

View File

@@ -1,5 +0,0 @@
{
"rules": {
"adf-file-naming": true
}
}