@taiga-ui/eslint-plugin-experience-next 0.345.0 → 0.346.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -0
- package/index.esm.js +63 -6
- package/package.json +1 -1
- package/rules/no-deep-imports-to-indexed-packages.d.ts +3 -0
package/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare const plugin: {
|
|
|
15
15
|
'decorator-key-sort': import("eslint").Rule.RuleModule;
|
|
16
16
|
'injection-token-description': import("eslint").Rule.RuleModule;
|
|
17
17
|
'no-deep-imports': import("eslint").Rule.RuleModule;
|
|
18
|
+
'no-deep-imports-to-indexed-packages': import("@typescript-eslint/utils/ts-eslint").RuleModule<"deepImport", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
18
19
|
'no-href-with-router-link': import("eslint").Rule.RuleModule;
|
|
19
20
|
'no-implicit-public': import("eslint").Rule.RuleModule;
|
|
20
21
|
'no-private-esnext-fields': import("eslint").Rule.RuleModule;
|
package/index.esm.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { readFileSync
|
|
1
|
+
import fs, { readFileSync } from 'node:fs';
|
|
2
2
|
import html from '@html-eslint/eslint-plugin';
|
|
3
3
|
import htmlParser from '@html-eslint/parser';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
4
5
|
import eslint from '@eslint/js';
|
|
5
6
|
import rxjs from '@smarttools/eslint-plugin-rxjs';
|
|
6
7
|
import stylistic from '@stylistic/eslint-plugin';
|
|
@@ -14,9 +15,7 @@ import sonarjs from 'eslint-plugin-sonarjs';
|
|
|
14
15
|
import unicorn from 'eslint-plugin-unicorn';
|
|
15
16
|
import unusedImports from 'eslint-plugin-unused-imports';
|
|
16
17
|
import globals from 'globals';
|
|
17
|
-
import { createRequire } from 'module';
|
|
18
18
|
import tseslint from 'typescript-eslint';
|
|
19
|
-
import fs, { readFileSync } from 'node:fs';
|
|
20
19
|
import { globSync } from 'glob';
|
|
21
20
|
import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
|
|
22
21
|
import ts from 'typescript';
|
|
@@ -419,6 +418,7 @@ var recommended = tseslint.config(progress.configs['recommended-ci'], require('e
|
|
|
419
418
|
],
|
|
420
419
|
},
|
|
421
420
|
],
|
|
421
|
+
'@taiga-ui/experience-next/no-deep-imports-to-indexed-packages': 'error',
|
|
422
422
|
'@taiga-ui/experience-next/no-implicit-public': 'error',
|
|
423
423
|
'@taiga-ui/experience-next/no-private-esnext-fields': 'error',
|
|
424
424
|
'@taiga-ui/experience-next/standalone-imports-sort': 'error',
|
|
@@ -653,6 +653,7 @@ var recommended = tseslint.config(progress.configs['recommended-ci'], require('e
|
|
|
653
653
|
],
|
|
654
654
|
'guard-for-in': 'error',
|
|
655
655
|
'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
|
|
656
|
+
'import/enforce-node-protocol-usage': ['error', 'always'],
|
|
656
657
|
'import/first': 'error',
|
|
657
658
|
'import/newline-after-import': ['error', { count: 1 }],
|
|
658
659
|
'import/no-absolute-path': 'error',
|
|
@@ -1449,8 +1450,8 @@ function intersect(a, b) {
|
|
|
1449
1450
|
return a.some((type) => origin.has(type));
|
|
1450
1451
|
}
|
|
1451
1452
|
|
|
1452
|
-
const createRule = ESLintUtils.RuleCreator((name) => name);
|
|
1453
|
-
var classPropertyNaming = createRule({
|
|
1453
|
+
const createRule$1 = ESLintUtils.RuleCreator((name) => name);
|
|
1454
|
+
var classPropertyNaming = createRule$1({
|
|
1454
1455
|
create(context, [configs]) {
|
|
1455
1456
|
const parserServices = ESLintUtils.getParserServices(context);
|
|
1456
1457
|
const typeChecker = parserServices.program.getTypeChecker();
|
|
@@ -1700,6 +1701,61 @@ const config$6 = {
|
|
|
1700
1701
|
},
|
|
1701
1702
|
};
|
|
1702
1703
|
|
|
1704
|
+
const createRule = ESLintUtils.RuleCreator((name) => name);
|
|
1705
|
+
var noDeepImportsToIndexedPackages = createRule({
|
|
1706
|
+
create(context) {
|
|
1707
|
+
const parserServices = ESLintUtils.getParserServices(context);
|
|
1708
|
+
const program = parserServices.program;
|
|
1709
|
+
const compilerHost = ts.createCompilerHost(program.getCompilerOptions(), true);
|
|
1710
|
+
return {
|
|
1711
|
+
ImportDeclaration(node) {
|
|
1712
|
+
const importPath = node.source.value;
|
|
1713
|
+
if (typeof importPath !== 'string' || importPath.startsWith('.')) {
|
|
1714
|
+
return;
|
|
1715
|
+
}
|
|
1716
|
+
const containingFile = context.filename;
|
|
1717
|
+
const { resolvedModule } = ts.resolveModuleName(importPath, containingFile, program.getCompilerOptions(), compilerHost);
|
|
1718
|
+
const resolvedPath = resolvedModule?.resolvedFileName;
|
|
1719
|
+
if (!resolvedPath || resolvedPath.endsWith('index.ts')) {
|
|
1720
|
+
return;
|
|
1721
|
+
}
|
|
1722
|
+
const dir = path.dirname(resolvedPath);
|
|
1723
|
+
const baseDir = path.resolve(dir, '..');
|
|
1724
|
+
const indexPath = path.join(baseDir, 'index.ts');
|
|
1725
|
+
const ngPackagePath = path.join(baseDir, 'ng-package.json');
|
|
1726
|
+
const packageJsonPath = path.join(baseDir, 'package.json');
|
|
1727
|
+
const hasIndex = fs.existsSync(indexPath);
|
|
1728
|
+
const hasPackage = fs.existsSync(ngPackagePath) || fs.existsSync(packageJsonPath);
|
|
1729
|
+
if (hasIndex && hasPackage) {
|
|
1730
|
+
const relative = path.relative(baseDir, resolvedPath);
|
|
1731
|
+
const shouldFix = !!(relative && !relative.startsWith('..'));
|
|
1732
|
+
if (shouldFix) {
|
|
1733
|
+
const parts = importPath.split('/');
|
|
1734
|
+
const suggestedImport = parts.slice(0, -1).join('/');
|
|
1735
|
+
context.report({
|
|
1736
|
+
data: { importPath, suggestedImport },
|
|
1737
|
+
messageId: 'deepImport',
|
|
1738
|
+
node: node.source,
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
},
|
|
1743
|
+
};
|
|
1744
|
+
},
|
|
1745
|
+
defaultOptions: [],
|
|
1746
|
+
meta: {
|
|
1747
|
+
docs: {
|
|
1748
|
+
description: 'Disallow deep imports from packages that expose an index.ts next to ng-package.json or package.json',
|
|
1749
|
+
},
|
|
1750
|
+
messages: {
|
|
1751
|
+
deepImport: 'Import "{{importPath}}" should go through the package index.ts (use "{{suggestedImport}}").',
|
|
1752
|
+
},
|
|
1753
|
+
schema: [],
|
|
1754
|
+
type: 'problem',
|
|
1755
|
+
},
|
|
1756
|
+
name: 'no-deep-imports-to-indexed-packages',
|
|
1757
|
+
});
|
|
1758
|
+
|
|
1703
1759
|
const MESSAGE_ID$1 = 'no-href-with-router-link';
|
|
1704
1760
|
const ERROR_MESSAGE$1 = 'Do not use href and routerLink attributes together on the same element';
|
|
1705
1761
|
const config$5 = {
|
|
@@ -2051,7 +2107,7 @@ const config = {
|
|
|
2051
2107
|
},
|
|
2052
2108
|
};
|
|
2053
2109
|
|
|
2054
|
-
const pkg = JSON.parse(readFileSync
|
|
2110
|
+
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
|
|
2055
2111
|
const plugin = {
|
|
2056
2112
|
configs: {},
|
|
2057
2113
|
meta: {
|
|
@@ -2064,6 +2120,7 @@ const plugin = {
|
|
|
2064
2120
|
'decorator-key-sort': config$8,
|
|
2065
2121
|
'injection-token-description': config$7,
|
|
2066
2122
|
'no-deep-imports': config$6,
|
|
2123
|
+
'no-deep-imports-to-indexed-packages': noDeepImportsToIndexedPackages,
|
|
2067
2124
|
'no-href-with-router-link': config$5,
|
|
2068
2125
|
'no-implicit-public': config$4,
|
|
2069
2126
|
'no-private-esnext-fields': config$3,
|
package/package.json
CHANGED