@taiga-ui/eslint-plugin-experience-next 0.392.0 → 0.394.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 CHANGED
@@ -37,6 +37,11 @@ declare const plugin: {
37
37
  'no-implicit-public': import("@typescript-eslint/utils/ts-eslint").RuleModule<"implicitPublic", [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
38
38
  name: string;
39
39
  };
40
+ 'object-single-line': import("@typescript-eslint/utils/ts-eslint").RuleModule<"oneLine", [{
41
+ printWidth: number;
42
+ }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
43
+ name: string;
44
+ };
40
45
  'prefer-deep-imports': import("@typescript-eslint/utils/ts-eslint").RuleModule<"prefer-deep-imports", [{
41
46
  importFilter: string[] | string;
42
47
  strict?: boolean;
package/index.esm.js CHANGED
@@ -42,9 +42,7 @@ var htmlEslint = defineConfig([
42
42
  plugins: { html },
43
43
  extends: ['html/recommended'],
44
44
  language: 'html/html',
45
- languageOptions: {
46
- parser: htmlParser,
47
- },
45
+ languageOptions: { parser: htmlParser },
48
46
  rules: {
49
47
  '@taiga-ui/experience-next/no-href-with-router-link': 'error',
50
48
  'html/indent': 'off', // prettier conflicts
@@ -100,20 +98,13 @@ var htmlEslint = defineConfig([
100
98
  },
101
99
  ],
102
100
  'html/require-closing-tags': 'off', // prettier conflicts
103
- 'html/require-img-alt': [
104
- 'error',
105
- {
106
- substitute: ['[alt]', '[attr.alt]'],
107
- },
108
- ],
101
+ 'html/require-img-alt': ['error', { substitute: ['[alt]', '[attr.alt]'] }],
109
102
  'html/use-baseline': 'off',
110
103
  },
111
104
  },
112
105
  {
113
106
  files: ['**/demo/**/*.html'],
114
- rules: {
115
- 'html/no-restricted-attr-values': 'off',
116
- },
107
+ rules: { 'html/no-restricted-attr-values': 'off' },
117
108
  },
118
109
  ]);
119
110
 
@@ -204,9 +195,7 @@ const tsconfig = projectJsonExist('tsconfig.eslint.json') ||
204
195
  projectJsonExist('tsconfig.json') ||
205
196
  projectJsonExist('tsconfig.base.json');
206
197
  const parserOptions = tsconfig
207
- ? {
208
- project: [tsconfig],
209
- }
198
+ ? { project: [tsconfig] }
210
199
  : {
211
200
  EXPERIMENTAL_useProjectService: {
212
201
  maximumDefaultProjectFileMatchCount_THIS_WILL_SLOW_DOWN_LINTING: Infinity,
@@ -314,13 +303,7 @@ var recommended = defineConfig([
314
303
  { blankLine: 'any', next: '*', prev: ['case', 'default'] },
315
304
  { blankLine: 'any', next: 'directive', prev: 'directive' },
316
305
  ],
317
- '@stylistic/quotes': [
318
- 'error',
319
- 'single',
320
- {
321
- avoidEscape: true,
322
- },
323
- ],
306
+ '@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
324
307
  '@stylistic/type-annotation-spacing': 'error',
325
308
  '@typescript-eslint/adjacent-overload-signatures': 'off',
326
309
  '@typescript-eslint/array-type': [
@@ -510,9 +493,7 @@ var recommended = defineConfig([
510
493
  '@typescript-eslint/only-throw-error': 'error',
511
494
  '@typescript-eslint/parameter-properties': [
512
495
  'error',
513
- {
514
- allow: ['public readonly', 'protected readonly', 'private readonly'],
515
- },
496
+ { allow: ['public readonly', 'protected readonly', 'private readonly'] },
516
497
  ],
517
498
  '@typescript-eslint/prefer-as-const': 'error',
518
499
  '@typescript-eslint/prefer-destructuring': 'off',
@@ -568,20 +549,8 @@ var recommended = defineConfig([
568
549
  properties: 'above',
569
550
  },
570
551
  ],
571
- eqeqeq: [
572
- 'error',
573
- 'always',
574
- {
575
- null: 'ignore',
576
- },
577
- ],
578
- 'func-style': [
579
- 'error',
580
- 'declaration',
581
- {
582
- allowArrowFunctions: true,
583
- },
584
- ],
552
+ eqeqeq: ['error', 'always', { null: 'ignore' }],
553
+ 'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
585
554
  'guard-for-in': 'error',
586
555
  'import/consistent-type-specifier-style': ['error', 'prefer-inline'],
587
556
  'import/enforce-node-protocol-usage': ['error', 'always'],
@@ -594,12 +563,7 @@ var recommended = defineConfig([
594
563
  'import/no-mutable-exports': 'error',
595
564
  'import/no-self-import': 'error',
596
565
  'import/no-unresolved': 'off',
597
- 'import/no-useless-path-segments': [
598
- 'error',
599
- {
600
- noUselessIndex: true,
601
- },
602
- ],
566
+ 'import/no-useless-path-segments': ['error', { noUselessIndex: true }],
603
567
  'import/no-webpack-loader-syntax': 'error',
604
568
  'lines-around-comment': [
605
569
  'error',
@@ -624,12 +588,7 @@ var recommended = defineConfig([
624
588
  'max-params': ['error', 5],
625
589
  'no-bitwise': 'error',
626
590
  'no-case-declarations': 'error',
627
- 'no-console': [
628
- 'error',
629
- {
630
- allow: ['info', 'assert', 'warn', 'error'],
631
- },
632
- ],
591
+ 'no-console': ['error', { allow: ['info', 'assert', 'warn', 'error'] }],
633
592
  'no-constant-condition': 'error',
634
593
  'no-empty': ['error', { allowEmptyCatch: true }],
635
594
  'no-extra-boolean-cast': 'error',
@@ -761,12 +720,7 @@ var recommended = defineConfig([
761
720
  },
762
721
  ],
763
722
  'prefer-template': 'error',
764
- 'prettier/prettier': [
765
- 'error',
766
- {
767
- endOfLine: 'auto',
768
- },
769
- ],
723
+ 'prettier/prettier': ['error', { endOfLine: 'auto' }],
770
724
  'promise/always-return': 'off',
771
725
  'promise/catch-or-return': 'off',
772
726
  'promise/no-callback-in-promise': 'off',
@@ -776,21 +730,10 @@ var recommended = defineConfig([
776
730
  'simple-import-sort/imports': 'error',
777
731
  'sonarjs/no-identical-functions': 'error',
778
732
  'sonarjs/no-inverted-boolean-check': 'error',
779
- 'spaced-comment': [
780
- 'error',
781
- 'always',
782
- {
783
- markers: ['/'],
784
- },
785
- ],
733
+ 'spaced-comment': ['error', 'always', { markers: ['/'] }],
786
734
  'unicorn/consistent-empty-array-spread': 'error',
787
735
  'unicorn/escape-case': 'error',
788
- 'unicorn/filename-case': [
789
- 'error',
790
- {
791
- case: 'kebabCase',
792
- },
793
- ],
736
+ 'unicorn/filename-case': ['error', { case: 'kebabCase' }],
794
737
  'unicorn/new-for-builtins': 'error',
795
738
  'unicorn/no-array-method-this-argument': 'error',
796
739
  'unicorn/no-array-push-push': 'error',
@@ -816,9 +759,7 @@ var recommended = defineConfig([
816
759
  },
817
760
  {
818
761
  files: ['**/*.{ts,tsx}'],
819
- plugins: {
820
- rxjs,
821
- },
762
+ plugins: { rxjs },
822
763
  extends: [angular.configs.tsRecommended],
823
764
  processor: angular.processInlineTemplates,
824
765
  rules: {
@@ -913,12 +854,11 @@ var recommended = defineConfig([
913
854
  ],
914
855
  '@taiga-ui/experience-next/no-deep-imports-to-indexed-packages': 'error',
915
856
  '@taiga-ui/experience-next/no-implicit-public': 'error',
857
+ '@taiga-ui/experience-next/object-single-line': ['error', { printWidth: 90 }],
916
858
  '@taiga-ui/experience-next/short-tui-imports': 'error',
917
859
  '@taiga-ui/experience-next/standalone-imports-sort': [
918
860
  'error',
919
- {
920
- decorators: ['Component', 'Directive', 'NgModule', 'Pipe'],
921
- },
861
+ { decorators: ['Component', 'Directive', 'NgModule', 'Pipe'] },
922
862
  ],
923
863
  'rxjs/no-compat': 'error',
924
864
  'rxjs/no-connectable': 'error',
@@ -994,9 +934,7 @@ var recommended = defineConfig([
994
934
  'jest/prefer-importing-jest-globals': 'off',
995
935
  'playwright/expect-expect': [
996
936
  'error',
997
- {
998
- assertFunctionNames: ['expect', 'expect.soft'],
999
- },
937
+ { assertFunctionNames: ['expect', 'expect.soft'] },
1000
938
  ],
1001
939
  'playwright/no-force-option': 'error',
1002
940
  'playwright/no-networkidle': 'off',
@@ -1064,9 +1002,7 @@ var recommended = defineConfig([
1064
1002
  'jest/require-to-throw-message': 'off',
1065
1003
  'jest/require-top-level-describe': [
1066
1004
  'error',
1067
- {
1068
- maxNumberOfTopLevelDescribes: 1,
1069
- },
1005
+ { maxNumberOfTopLevelDescribes: 1 },
1070
1006
  ],
1071
1007
  'jest/unbound-method': 'off',
1072
1008
  'jest/valid-title': 'error',
@@ -1102,20 +1038,14 @@ var recommended = defineConfig([
1102
1038
  },
1103
1039
  {
1104
1040
  files: ['**/*.md'],
1105
- plugins: {
1106
- markdown,
1107
- },
1041
+ plugins: { markdown },
1108
1042
  extends: [markdown.configs.recommended],
1109
1043
  language: 'markdown/gfm',
1110
- rules: {
1111
- 'markdown/require-alt-text': 'off',
1112
- },
1044
+ rules: { 'markdown/require-alt-text': 'off' },
1113
1045
  },
1114
1046
  {
1115
1047
  files: ['**/*.md', '**/*.html', '**/*.cy.ts', '**/*.spec.ts'],
1116
- rules: {
1117
- 'no-irregular-whitespace': 'off',
1118
- },
1048
+ rules: { 'no-irregular-whitespace': 'off' },
1119
1049
  },
1120
1050
  ]);
1121
1051
  function projectJsonExist(filename) {
@@ -1248,9 +1178,7 @@ const config$2 = {
1248
1178
  };
1249
1179
  },
1250
1180
  meta: {
1251
- docs: {
1252
- description: 'Exported arrays of class references should use `as const`.',
1253
- },
1181
+ docs: { description: 'Exported arrays of class references should use `as const`.' },
1254
1182
  fixable: 'code',
1255
1183
  messages: {
1256
1184
  shouldUseAsConst: 'Exported array of class references should be marked with `as const`.',
@@ -1298,8 +1226,8 @@ function intersect(a, b) {
1298
1226
  return a.some((type) => origin.has(type));
1299
1227
  }
1300
1228
 
1301
- const createRule$9 = ESLintUtils.RuleCreator((name) => name);
1302
- var classPropertyNaming = createRule$9({
1229
+ const createRule$a = ESLintUtils.RuleCreator((name) => name);
1230
+ var classPropertyNaming = createRule$a({
1303
1231
  create(context, [configs]) {
1304
1232
  const parserServices = ESLintUtils.getParserServices(context);
1305
1233
  const typeChecker = parserServices.program.getTypeChecker();
@@ -1468,9 +1396,9 @@ function isExternalPureTuple(typeChecker, type) {
1468
1396
  return typeArgs.every((item) => isClassType(item));
1469
1397
  }
1470
1398
 
1471
- const createRule$8 = ESLintUtils.RuleCreator((name) => name);
1399
+ const createRule$9 = ESLintUtils.RuleCreator((name) => name);
1472
1400
  const MESSAGE_ID$5 = 'spreadArrays';
1473
- var flatExports = createRule$8({
1401
+ var flatExports = createRule$9({
1474
1402
  create(context) {
1475
1403
  const parserServices = ESLintUtils.getParserServices(context);
1476
1404
  const typeChecker = parserServices.program.getTypeChecker();
@@ -1597,8 +1525,8 @@ var flatExports = createRule$8({
1597
1525
 
1598
1526
  const MESSAGE_ID$4 = 'invalid-injection-token-description';
1599
1527
  const ERROR_MESSAGE$3 = "InjectionToken's description should contain token's name";
1600
- const createRule$7 = ESLintUtils.RuleCreator((name) => name);
1601
- const rule$4 = createRule$7({
1528
+ const createRule$8 = ESLintUtils.RuleCreator((name) => name);
1529
+ const rule$5 = createRule$8({
1602
1530
  create(context) {
1603
1531
  return {
1604
1532
  'NewExpression[callee.name="InjectionToken"]'(node) {
@@ -1638,13 +1566,9 @@ const rule$4 = createRule$7({
1638
1566
  },
1639
1567
  defaultOptions: [],
1640
1568
  meta: {
1641
- docs: {
1642
- description: ERROR_MESSAGE$3,
1643
- },
1569
+ docs: { description: ERROR_MESSAGE$3 },
1644
1570
  fixable: 'code',
1645
- messages: {
1646
- [MESSAGE_ID$4]: ERROR_MESSAGE$3,
1647
- },
1571
+ messages: { [MESSAGE_ID$4]: ERROR_MESSAGE$3 },
1648
1572
  schema: [],
1649
1573
  type: 'problem',
1650
1574
  },
@@ -1660,8 +1584,8 @@ const DEFAULT_OPTIONS = {
1660
1584
  importDeclaration: '^@taiga-ui*',
1661
1585
  projectName: String.raw `(?<=^@taiga-ui/)([-\w]+)`,
1662
1586
  };
1663
- const createRule$6 = ESLintUtils.RuleCreator((name) => name);
1664
- const rule$3 = createRule$6({
1587
+ const createRule$7 = ESLintUtils.RuleCreator((name) => name);
1588
+ const rule$4 = createRule$7({
1665
1589
  create(context) {
1666
1590
  const { currentProject, deepImport, ignoreImports, importDeclaration, projectName, } = { ...DEFAULT_OPTIONS, ...context.options[0] };
1667
1591
  const isDeepImport = (source) => !!source && new RegExp(deepImport, 'g').test(source);
@@ -1703,13 +1627,9 @@ const rule$3 = createRule$6({
1703
1627
  },
1704
1628
  defaultOptions: [DEFAULT_OPTIONS],
1705
1629
  meta: {
1706
- docs: {
1707
- description: ERROR_MESSAGE$2,
1708
- },
1630
+ docs: { description: ERROR_MESSAGE$2 },
1709
1631
  fixable: 'code',
1710
- messages: {
1711
- [MESSAGE_ID$3]: ERROR_MESSAGE$2,
1712
- },
1632
+ messages: { [MESSAGE_ID$3]: ERROR_MESSAGE$2 },
1713
1633
  schema: [
1714
1634
  {
1715
1635
  additionalProperties: false,
@@ -1744,8 +1664,8 @@ const rule$3 = createRule$6({
1744
1664
  name: 'no-deep-imports',
1745
1665
  });
1746
1666
 
1747
- const createRule$5 = ESLintUtils.RuleCreator((name) => name);
1748
- var noDeepImportsToIndexedPackages = createRule$5({
1667
+ const createRule$6 = ESLintUtils.RuleCreator((name) => name);
1668
+ var noDeepImportsToIndexedPackages = createRule$6({
1749
1669
  create(context) {
1750
1670
  const parserServices = ESLintUtils.getParserServices(context);
1751
1671
  const program = parserServices.program;
@@ -1939,19 +1859,15 @@ const config = {
1939
1859
  };
1940
1860
  },
1941
1861
  meta: {
1942
- docs: {
1943
- description: ERROR_MESSAGE$1,
1944
- },
1862
+ docs: { description: ERROR_MESSAGE$1 },
1945
1863
  fixable: 'code',
1946
- messages: {
1947
- [MESSAGE_ID$2]: ERROR_MESSAGE$1,
1948
- },
1864
+ messages: { [MESSAGE_ID$2]: ERROR_MESSAGE$1 },
1949
1865
  type: 'problem',
1950
1866
  },
1951
1867
  };
1952
1868
 
1953
- const createRule$4 = ESLintUtils.RuleCreator((name) => name);
1954
- const rule$2 = createRule$4({
1869
+ const createRule$5 = ESLintUtils.RuleCreator((name) => name);
1870
+ const rule$3 = createRule$5({
1955
1871
  create(context) {
1956
1872
  const checkImplicitPublic = (node) => {
1957
1873
  const classRef = getClass(node);
@@ -2007,9 +1923,7 @@ const rule$2 = createRule$4({
2007
1923
  description: 'Require explicit `public` modifier for class members and parameter properties',
2008
1924
  },
2009
1925
  fixable: 'code',
2010
- messages: {
2011
- implicitPublic: '{{kind}} {{name}} should be marked as public',
2012
- },
1926
+ messages: { implicitPublic: '{{kind}} {{name}} should be marked as public' },
2013
1927
  schema: [],
2014
1928
  type: 'problem',
2015
1929
  },
@@ -2025,6 +1939,285 @@ function getClass(node) {
2025
1939
  return getClass(node.parent);
2026
1940
  }
2027
1941
 
1942
+ const createRule$4 = ESLintUtils.RuleCreator((name) => name);
1943
+ const rule$2 = createRule$4({
1944
+ create(context, [{ printWidth }]) {
1945
+ const sourceCode = context.sourceCode;
1946
+ const getLineEndIndex = (lineStartIndex) => {
1947
+ const text = sourceCode.text;
1948
+ const newLineIndex = text.indexOf('\n', lineStartIndex);
1949
+ const rawEndIndex = newLineIndex === -1 ? text.length : newLineIndex;
1950
+ if (rawEndIndex > lineStartIndex && text[rawEndIndex - 1] === '\r') {
1951
+ return rawEndIndex - 1;
1952
+ }
1953
+ return rawEndIndex;
1954
+ };
1955
+ const hasAnyCommentsInside = (node) => sourceCode.getCommentsInside(node).length > 0;
1956
+ const isTemplateLikeExpression = (expression) => expression.type === AST_NODE_TYPES$1.TemplateLiteral ||
1957
+ expression.type === AST_NODE_TYPES$1.TaggedTemplateExpression;
1958
+ const isForbiddenProperty = (property) => {
1959
+ if (property.type !== AST_NODE_TYPES$1.Property) {
1960
+ return false;
1961
+ }
1962
+ if (property.kind === 'get' || property.kind === 'set' || property.method) {
1963
+ return true;
1964
+ }
1965
+ const value = property.value;
1966
+ if (value && typeof value === 'object' && 'type' in value) {
1967
+ const expression = value;
1968
+ if (isTemplateLikeExpression(expression)) {
1969
+ return true;
1970
+ }
1971
+ }
1972
+ return false;
1973
+ };
1974
+ const canInlineObjectExpression = (node) => {
1975
+ if (!node?.loc ||
1976
+ node.properties.length !== 1 ||
1977
+ hasAnyCommentsInside(node)) {
1978
+ return false;
1979
+ }
1980
+ const [onlyProperty] = node.properties;
1981
+ return !onlyProperty ? false : !isForbiddenProperty(onlyProperty);
1982
+ };
1983
+ const unwrapExpression = (expression) => {
1984
+ let current = expression;
1985
+ let didUnwrap = true;
1986
+ while (didUnwrap) {
1987
+ didUnwrap = false;
1988
+ switch (current.type) {
1989
+ case AST_NODE_TYPES$1.ChainExpression:
1990
+ current = current.expression;
1991
+ didUnwrap = true;
1992
+ break;
1993
+ case AST_NODE_TYPES$1.TSAsExpression:
1994
+ current = current.expression;
1995
+ didUnwrap = true;
1996
+ break;
1997
+ case AST_NODE_TYPES$1.TSNonNullExpression:
1998
+ current = current.expression;
1999
+ didUnwrap = true;
2000
+ break;
2001
+ case AST_NODE_TYPES$1.TSTypeAssertion:
2002
+ current = current.expression;
2003
+ didUnwrap = true;
2004
+ break;
2005
+ }
2006
+ }
2007
+ return current;
2008
+ };
2009
+ const getParenthesizedInner = (expression) => {
2010
+ const anyExpression = expression;
2011
+ if (anyExpression?.type === 'ParenthesizedExpression') {
2012
+ const inner = anyExpression.expression;
2013
+ if (inner) {
2014
+ return inner;
2015
+ }
2016
+ }
2017
+ return null;
2018
+ };
2019
+ const spreadNeedsParens = (argument) => {
2020
+ switch (argument.type) {
2021
+ case AST_NODE_TYPES$1.AssignmentExpression:
2022
+ case AST_NODE_TYPES$1.BinaryExpression:
2023
+ case AST_NODE_TYPES$1.ConditionalExpression:
2024
+ case AST_NODE_TYPES$1.LogicalExpression:
2025
+ case AST_NODE_TYPES$1.SequenceExpression:
2026
+ return true;
2027
+ default:
2028
+ return false;
2029
+ }
2030
+ };
2031
+ const renderSpreadOneLine = (argument) => {
2032
+ const argText = sourceCode.getText(argument);
2033
+ return spreadNeedsParens(argument) ? `...(${argText})` : `...${argText}`;
2034
+ };
2035
+ const renderPropertyOneLine = (property) => {
2036
+ if (property.type === AST_NODE_TYPES$1.SpreadElement) {
2037
+ return renderSpreadOneLine(property.argument);
2038
+ }
2039
+ if (property.type !== AST_NODE_TYPES$1.Property ||
2040
+ property.kind !== 'init' ||
2041
+ property.method) {
2042
+ return sourceCode.getText(property);
2043
+ }
2044
+ if (property.shorthand && property.key.type === AST_NODE_TYPES$1.Identifier) {
2045
+ return property.key.name;
2046
+ }
2047
+ const keyText = sourceCode.getText(property.key);
2048
+ const valueExpression = property.value;
2049
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
2050
+ const valueText = renderExpressionOneLine(valueExpression);
2051
+ if (property.computed) {
2052
+ return `[${keyText}]: ${valueText}`;
2053
+ }
2054
+ return `${keyText}: ${valueText}`;
2055
+ };
2056
+ const renderObjectExpressionOneLine = (node) => {
2057
+ const [onlyProperty] = node.properties;
2058
+ if (!onlyProperty) {
2059
+ return '{}';
2060
+ }
2061
+ return `{${renderPropertyOneLine(onlyProperty)}}`;
2062
+ };
2063
+ const renderExpressionOneLine = (expression) => {
2064
+ const innerParen = getParenthesizedInner(expression);
2065
+ if (innerParen) {
2066
+ const inner = unwrapExpression(innerParen);
2067
+ if (inner.type === AST_NODE_TYPES$1.ObjectExpression &&
2068
+ canInlineObjectExpression(inner)) {
2069
+ return `(${renderObjectExpressionOneLine(inner)})`;
2070
+ }
2071
+ return sourceCode.getText(expression);
2072
+ }
2073
+ const unwrapped = unwrapExpression(expression);
2074
+ if (unwrapped.type === AST_NODE_TYPES$1.ObjectExpression &&
2075
+ canInlineObjectExpression(unwrapped)) {
2076
+ return renderObjectExpressionOneLine(unwrapped);
2077
+ }
2078
+ return sourceCode.getText(expression);
2079
+ };
2080
+ const hasPendingInnerInlineCandidate = (node) => {
2081
+ if (node.properties.length !== 1) {
2082
+ return false;
2083
+ }
2084
+ const [onlyElement] = node.properties;
2085
+ if (onlyElement?.type !== AST_NODE_TYPES$1.Property ||
2086
+ onlyElement.kind !== 'init' ||
2087
+ onlyElement.method) {
2088
+ return false;
2089
+ }
2090
+ const rawValue = onlyElement.value;
2091
+ const value = unwrapExpression(rawValue);
2092
+ const innerParen = getParenthesizedInner(value);
2093
+ if (innerParen) {
2094
+ const inner = unwrapExpression(innerParen);
2095
+ if (inner.type === AST_NODE_TYPES$1.ObjectExpression &&
2096
+ canInlineObjectExpression(inner)) {
2097
+ const innerText = sourceCode.getText(inner);
2098
+ return innerText.includes('\n');
2099
+ }
2100
+ }
2101
+ if (value.type === AST_NODE_TYPES$1.ArrowFunctionExpression) {
2102
+ const bodyAny = value.body;
2103
+ if (bodyAny?.type === 'ParenthesizedExpression') {
2104
+ const bodyInner = bodyAny.expression;
2105
+ if (bodyInner) {
2106
+ const inner = unwrapExpression(bodyInner);
2107
+ if (inner.type === AST_NODE_TYPES$1.ObjectExpression &&
2108
+ canInlineObjectExpression(inner)) {
2109
+ const innerText = sourceCode.getText(inner);
2110
+ return innerText.includes('\n');
2111
+ }
2112
+ }
2113
+ }
2114
+ else if (bodyAny && typeof bodyAny === 'object' && 'type' in bodyAny) {
2115
+ const bodyExpr = unwrapExpression(bodyAny);
2116
+ if (bodyExpr.type === AST_NODE_TYPES$1.ObjectExpression &&
2117
+ canInlineObjectExpression(bodyExpr)) {
2118
+ const innerText = sourceCode.getText(bodyExpr);
2119
+ return innerText.includes('\n');
2120
+ }
2121
+ }
2122
+ }
2123
+ return false;
2124
+ };
2125
+ const hasArrowReturningMultiPropObject = (node) => {
2126
+ if (node.properties.length !== 1) {
2127
+ return false;
2128
+ }
2129
+ const [onlyElement] = node.properties;
2130
+ if (onlyElement?.type !== AST_NODE_TYPES$1.Property ||
2131
+ onlyElement.kind !== 'init' ||
2132
+ onlyElement.method) {
2133
+ return false;
2134
+ }
2135
+ const rawValue = onlyElement.value;
2136
+ const value = unwrapExpression(rawValue);
2137
+ if (value.type !== AST_NODE_TYPES$1.ArrowFunctionExpression) {
2138
+ return false;
2139
+ }
2140
+ const bodyAny = value.body;
2141
+ if (bodyAny?.type === 'ParenthesizedExpression') {
2142
+ const innerRaw = bodyAny.expression;
2143
+ if (!innerRaw) {
2144
+ return false;
2145
+ }
2146
+ const inner = unwrapExpression(innerRaw);
2147
+ return (inner.type === AST_NODE_TYPES$1.ObjectExpression &&
2148
+ inner.properties.length > 1);
2149
+ }
2150
+ if (bodyAny && typeof bodyAny === 'object' && 'type' in bodyAny) {
2151
+ const inner = unwrapExpression(bodyAny);
2152
+ return (inner.type === AST_NODE_TYPES$1.ObjectExpression &&
2153
+ inner.properties.length > 1);
2154
+ }
2155
+ return false;
2156
+ };
2157
+ const fitsPrintWidthAfterFix = (node, fixedText) => {
2158
+ if (!node?.loc) {
2159
+ return false;
2160
+ }
2161
+ const startLine = node.loc.start.line;
2162
+ const endLine = node.loc.end.line;
2163
+ const startLineStartIndex = sourceCode.getIndexFromLoc({
2164
+ column: 0,
2165
+ line: startLine,
2166
+ });
2167
+ const endLineStartIndex = sourceCode.getIndexFromLoc({
2168
+ column: 0,
2169
+ line: endLine,
2170
+ });
2171
+ const endLineEndIndex = getLineEndIndex(endLineStartIndex);
2172
+ const nodeStartIndex = node.range[0];
2173
+ const nodeEndIndex = node.range[1];
2174
+ const prefix = sourceCode.text.slice(startLineStartIndex, nodeStartIndex);
2175
+ const suffix = sourceCode.text.slice(nodeEndIndex, endLineEndIndex);
2176
+ const newLineText = `${prefix}${fixedText}${suffix}`;
2177
+ return newLineText.length <= printWidth;
2178
+ };
2179
+ return {
2180
+ ObjectExpression(node) {
2181
+ const originalText = sourceCode.getText(node);
2182
+ if (!canInlineObjectExpression(node) ||
2183
+ !originalText.includes('\n') ||
2184
+ hasPendingInnerInlineCandidate(node) ||
2185
+ hasArrowReturningMultiPropObject(node)) {
2186
+ return;
2187
+ }
2188
+ const fixedText = renderObjectExpressionOneLine(node);
2189
+ if (!fitsPrintWidthAfterFix(node, fixedText)) {
2190
+ return;
2191
+ }
2192
+ context.report({
2193
+ fix(fixer) {
2194
+ return fixer.replaceText(node, fixedText);
2195
+ },
2196
+ messageId: 'oneLine',
2197
+ node,
2198
+ });
2199
+ },
2200
+ };
2201
+ },
2202
+ defaultOptions: [{ printWidth: 90 }],
2203
+ meta: {
2204
+ docs: {
2205
+ description: 'Enforce single-line formatting for single-property objects when possible (Prettier-friendly)',
2206
+ },
2207
+ fixable: 'whitespace',
2208
+ messages: { oneLine: 'Single-property object should be written in one line' },
2209
+ schema: [
2210
+ {
2211
+ additionalProperties: false,
2212
+ properties: { printWidth: { type: 'number' } },
2213
+ type: 'object',
2214
+ },
2215
+ ],
2216
+ type: 'layout',
2217
+ },
2218
+ name: 'object-single-line',
2219
+ });
2220
+
2028
2221
  const MESSAGE_ID$1 = 'prefer-deep-imports';
2029
2222
  const ERROR_MESSAGE = 'Import via root entry point is prohibited when nested entry points exist';
2030
2223
  const createRule$3 = ESLintUtils.RuleCreator(() => ERROR_MESSAGE);
@@ -2714,19 +2907,11 @@ var standaloneImportsSort = createRule$1({
2714
2907
  },
2715
2908
  };
2716
2909
  },
2717
- defaultOptions: [
2718
- {
2719
- decorators: ['Component', 'Directive', 'NgModule', 'Pipe'],
2720
- },
2721
- ],
2910
+ defaultOptions: [{ decorators: ['Component', 'Directive', 'NgModule', 'Pipe'] }],
2722
2911
  meta: {
2723
- docs: {
2724
- description: 'Sort Angular standalone imports inside decorators.',
2725
- },
2912
+ docs: { description: 'Sort Angular standalone imports inside decorators.' },
2726
2913
  fixable: 'code',
2727
- messages: {
2728
- incorrectOrder: 'Order in imports should be [{{expected}}]',
2729
- },
2914
+ messages: { incorrectOrder: 'Order in imports should be [{{expected}}]' },
2730
2915
  schema: [
2731
2916
  {
2732
2917
  additionalProperties: false,
@@ -2857,11 +3042,12 @@ const plugin = {
2857
3042
  'class-property-naming': classPropertyNaming,
2858
3043
  'decorator-key-sort': config$1,
2859
3044
  'flat-exports': flatExports,
2860
- 'injection-token-description': rule$4,
2861
- 'no-deep-imports': rule$3,
3045
+ 'injection-token-description': rule$5,
3046
+ 'no-deep-imports': rule$4,
2862
3047
  'no-deep-imports-to-indexed-packages': noDeepImportsToIndexedPackages,
2863
3048
  'no-href-with-router-link': config,
2864
- 'no-implicit-public': rule$2,
3049
+ 'no-implicit-public': rule$3,
3050
+ 'object-single-line': rule$2,
2865
3051
  'prefer-deep-imports': preferDeepImports,
2866
3052
  'short-tui-imports': rule$1,
2867
3053
  'standalone-imports-sort': standaloneImportsSort,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ui/eslint-plugin-experience-next",
3
- "version": "0.392.0",
3
+ "version": "0.394.0",
4
4
  "description": "An ESLint plugin to enforce a consistent code styles across taiga-ui projects",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "eslint-plugin-import": "^2.32.0",
28
28
  "eslint-plugin-jest": "^29.12.1",
29
29
  "eslint-plugin-package-json": "^0.88.1",
30
- "eslint-plugin-perfectionist": "^5.3.1",
30
+ "eslint-plugin-perfectionist": "^5.4.0",
31
31
  "eslint-plugin-playwright": "^2.5.0",
32
32
  "eslint-plugin-prettier": "^5.5.5",
33
33
  "eslint-plugin-promise": "^7.2.1",
@@ -0,0 +1,8 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ type Options = [{
3
+ printWidth: number;
4
+ }];
5
+ export declare const rule: ESLintUtils.RuleModule<"oneLine", Options, unknown, ESLintUtils.RuleListener> & {
6
+ name: string;
7
+ };
8
+ export default rule;