Fixed build for all the packages

This commit is contained in:
VitoAlbano
2024-10-11 22:53:41 +01:00
committed by Vito Albano
parent 1def5dcc0a
commit 62baa655ed
18 changed files with 5930 additions and 567 deletions

View File

@@ -11,8 +11,8 @@
"projectRoot": "lib/eslint-angular",
"outputPath": "dist/libs/eslint-plugin-eslint-angular",
"main": "lib/eslint-angular/index.ts",
"generatePackageJson": true,
"tsConfig": "lib/eslint-angular/tsconfig.lib.prod.json",
"webpackConfig": "lib/eslint-angular/webpack.config.js",
"stylePreprocessorOptions": {
"includePaths": ["lib", "lib/core/src/lib"]
},
@@ -24,14 +24,13 @@
"projectRoot": "lib/eslint-angular",
"outputPath": "dist/libs/eslint-plugin-eslint-angular",
"main": "lib/eslint-angular/index.ts",
"generatePackageJson": true,
"tsConfig": "lib/eslint-angular/tsconfig.lib.prod.json"
}
},
"defaultConfiguration": "production"
},
"lint": {
"executor": "@nrwl/linter:eslint",
"executor": "@nx/eslint:lint:eslint",
"options": {
"lintFilePatterns": ["lib/eslint-angular/**/*.ts"]
}

View File

@@ -33,7 +33,7 @@ const messages = {
type MessageIds = keyof typeof messages;
const filetypeErrors: {regexp: RegExp; messageId: MessageIds}[] = [
const filetypeErrors: { regexp: RegExp; messageId: MessageIds }[] = [
{
regexp: /.*\.spec\.ts/,
messageId: 'useAngularMaterialTestingHarness'
@@ -52,8 +52,7 @@ export default createESLintRule<unknown[], MessageIds>({
meta: {
type: 'suggestion',
docs: {
description: 'Disallows using Angular Material internal selectors',
recommended: 'error'
description: 'Disallows using Angular Material internal selectors'
},
hasSuggestions: true,
schema: [],
@@ -63,9 +62,9 @@ export default createESLintRule<unknown[], MessageIds>({
create(context) {
return {
[ASTSelectors.join(',')](node: TSESTree.Literal | TSESTree.TemplateLiteral) {
const message = filetypeErrors.find((fileTypeError) =>
context.getFilename().match(fileTypeError.regexp)
) || { messageId: 'noAngularMaterialSelectors' };
const message = filetypeErrors.find((fileTypeError) => context.getFilename().match(fileTypeError.regexp)) || {
messageId: 'noAngularMaterialSelectors'
};
context.report({
node,

View File

@@ -21,7 +21,7 @@ import { createESLintRule } from '../../utils/create-eslint-rule/create-eslint-r
export const RULE_NAME = 'use-none-component-view-encapsulation';
type MessageIds = 'useNoneComponentViewEncapsulation'| 'suggestAddViewEncapsulationNone';
type MessageIds = 'useNoneComponentViewEncapsulation' | 'suggestAddViewEncapsulationNone';
type DecoratorForClass = TSESTree.Decorator & {
parent: TSESTree.ClassDeclaration;
};
@@ -53,8 +53,7 @@ export default createESLintRule<unknown[], MessageIds>({
meta: {
type: 'suggestion',
docs: {
description: `Disallows using other encapsulation than \`${viewEncapsulationNone}\``,
recommended: false
description: `Disallows using other encapsulation than \`${viewEncapsulationNone}\``
},
hasSuggestions: true,
schema: [],
@@ -65,18 +64,13 @@ export default createESLintRule<unknown[], MessageIds>({
},
defaultOptions: [],
create(context) {
const encapsulationProperty = Selectors.metadataProperty(
metadataPropertyName
);
const encapsulationProperty = Selectors.metadataProperty(metadataPropertyName);
const withoutEncapsulationProperty =
`${Selectors.COMPONENT_CLASS_DECORATOR}:matches([expression.arguments.length=0], [expression.arguments.0.type='ObjectExpression']:not(:has(${encapsulationProperty})))` as const;
const nonNoneViewEncapsulationNoneProperty =
`${Selectors.COMPONENT_CLASS_DECORATOR} > CallExpression > ObjectExpression > ` +
`${encapsulationProperty}:matches([value.type='Identifier'][value.name='undefined'], [value.object.name='ViewEncapsulation'][value.property.name!='None'])`;
const selectors = [
withoutEncapsulationProperty,
nonNoneViewEncapsulationNoneProperty
].join(',');
const selectors = [withoutEncapsulationProperty, nonNoneViewEncapsulationNoneProperty].join(',');
return {
[selectors](node: DecoratorForClass | PropertyInClassDecorator) {
context.report({
@@ -92,7 +86,7 @@ export default createESLintRule<unknown[], MessageIds>({
fixer,
importName: 'ViewEncapsulation',
moduleName: '@angular/core',
node: node.parent.parent.parent.parent
node: node.parent
}),
ASTUtils.isMemberExpression(node.value)
? fixer.replaceText(node.value.property, 'None')
@@ -107,11 +101,7 @@ export default createESLintRule<unknown[], MessageIds>({
moduleName: '@angular/core',
node: node.parent
}),
RuleFixes.getDecoratorPropertyAddFix(
node,
fixer,
`${metadataPropertyName}: ${viewEncapsulationNone}`
)
RuleFixes.getDecoratorPropertyAddFix(node, fixer, `${metadataPropertyName}: ${viewEncapsulationNone}`)
].filter(isNotNullOrUndefined);
}
}

View File

@@ -11,7 +11,7 @@
"skipLibCheck": true,
"baseUrl": "src",
"types": [
"node"
"node", "@typescript-eslint/utils"
]
},
"include": [

View File

@@ -0,0 +1,20 @@
const { NxAppWebpackPlugin } = require('@nx/webpack/app-plugin');
const { join } = require('path');
module.exports = {
output: {
path: join(__dirname, '../../dist/libs/eslint-angular')
},
devServer: {
port: 4200
},
plugins: [
new NxAppWebpackPlugin({
main: './index.ts',
tsConfig: './tsconfig.lib.json',
index: './index.ts',
outputHashing: process.env['NODE_ENV'] === 'production' ? 'all' : 'none',
optimization: process.env['NODE_ENV'] === 'production'
})
]
};