@dineroregnskab/eslint-plugin-custom-rules 2.0.6 → 2.1.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.
Files changed (178) hide show
  1. package/README.md +49 -9
  2. package/eslint-plugin-custom-rules.js +10 -4
  3. package/package.json +2 -4
  4. package/rules/replace-first-with-take.js +31 -0
  5. package/rules/use-danish-currency-pipe.js +53 -0
  6. package/willy.yaml +5 -0
  7. package/node_modules/@aashutoshrathi/word-wrap/LICENSE +0 -21
  8. package/node_modules/@aashutoshrathi/word-wrap/README.md +0 -182
  9. package/node_modules/@aashutoshrathi/word-wrap/index.d.ts +0 -50
  10. package/node_modules/@aashutoshrathi/word-wrap/index.js +0 -52
  11. package/node_modules/@aashutoshrathi/word-wrap/package.json +0 -81
  12. package/node_modules/@angular-eslint/bundled-angular-compiler/README.md +0 -1
  13. package/node_modules/@angular-eslint/bundled-angular-compiler/dist/index.d.ts +0 -5
  14. package/node_modules/@angular-eslint/bundled-angular-compiler/dist/index.js +0 -32004
  15. package/node_modules/@angular-eslint/bundled-angular-compiler/package.json +0 -19
  16. package/node_modules/@angular-eslint/template-parser/LICENSE +0 -21
  17. package/node_modules/@angular-eslint/template-parser/README.md +0 -1
  18. package/node_modules/@angular-eslint/template-parser/dist/convert-source-span-to-loc.d.ts +0 -6
  19. package/node_modules/@angular-eslint/template-parser/dist/convert-source-span-to-loc.js +0 -69
  20. package/node_modules/@angular-eslint/template-parser/dist/index.d.ts +0 -44
  21. package/node_modules/@angular-eslint/template-parser/dist/index.js +0 -219
  22. package/node_modules/@angular-eslint/template-parser/package.json +0 -28
  23. package/node_modules/@eslint/eslintrc/LICENSE +0 -19
  24. package/node_modules/@eslint/eslintrc/README.md +0 -115
  25. package/node_modules/@eslint/eslintrc/conf/config-schema.js +0 -79
  26. package/node_modules/@eslint/eslintrc/conf/environments.js +0 -215
  27. package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +0 -1104
  28. package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +0 -1
  29. package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +0 -4333
  30. package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +0 -1
  31. package/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js +0 -532
  32. package/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +0 -523
  33. package/node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js +0 -115
  34. package/node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js +0 -145
  35. package/node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js +0 -238
  36. package/node_modules/@eslint/eslintrc/lib/config-array/index.js +0 -19
  37. package/node_modules/@eslint/eslintrc/lib/config-array/override-tester.js +0 -225
  38. package/node_modules/@eslint/eslintrc/lib/config-array-factory.js +0 -1149
  39. package/node_modules/@eslint/eslintrc/lib/flat-compat.js +0 -318
  40. package/node_modules/@eslint/eslintrc/lib/index-universal.js +0 -29
  41. package/node_modules/@eslint/eslintrc/lib/index.js +0 -56
  42. package/node_modules/@eslint/eslintrc/lib/shared/ajv.js +0 -191
  43. package/node_modules/@eslint/eslintrc/lib/shared/config-ops.js +0 -135
  44. package/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +0 -325
  45. package/node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js +0 -63
  46. package/node_modules/@eslint/eslintrc/lib/shared/naming.js +0 -96
  47. package/node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js +0 -42
  48. package/node_modules/@eslint/eslintrc/lib/shared/types.js +0 -149
  49. package/node_modules/@eslint/eslintrc/package.json +0 -82
  50. package/node_modules/@eslint/eslintrc/universal.js +0 -9
  51. package/node_modules/@eslint/js/LICENSE +0 -19
  52. package/node_modules/@eslint/js/README.md +0 -57
  53. package/node_modules/@eslint/js/package.json +0 -31
  54. package/node_modules/@eslint/js/src/configs/eslint-all.js +0 -211
  55. package/node_modules/@eslint/js/src/configs/eslint-recommended.js +0 -76
  56. package/node_modules/@eslint/js/src/index.js +0 -17
  57. package/node_modules/@eslint-community/eslint-utils/LICENSE +0 -21
  58. package/node_modules/@eslint-community/eslint-utils/README.md +0 -37
  59. package/node_modules/@eslint-community/eslint-utils/index.js +0 -2068
  60. package/node_modules/@eslint-community/eslint-utils/index.js.map +0 -1
  61. package/node_modules/@eslint-community/eslint-utils/index.mjs +0 -2027
  62. package/node_modules/@eslint-community/eslint-utils/index.mjs.map +0 -1
  63. package/node_modules/@eslint-community/eslint-utils/package.json +0 -73
  64. package/node_modules/@eslint-community/regexpp/LICENSE +0 -21
  65. package/node_modules/@eslint-community/regexpp/README.md +0 -177
  66. package/node_modules/@eslint-community/regexpp/index.d.ts +0 -1065
  67. package/node_modules/@eslint-community/regexpp/index.js +0 -2747
  68. package/node_modules/@eslint-community/regexpp/index.js.map +0 -1
  69. package/node_modules/@eslint-community/regexpp/index.mjs +0 -2737
  70. package/node_modules/@eslint-community/regexpp/index.mjs.map +0 -1
  71. package/node_modules/@eslint-community/regexpp/package.json +0 -93
  72. package/node_modules/@humanwhocodes/config-array/LICENSE +0 -201
  73. package/node_modules/@humanwhocodes/config-array/README.md +0 -342
  74. package/node_modules/@humanwhocodes/config-array/api.js +0 -1061
  75. package/node_modules/@humanwhocodes/config-array/package.json +0 -61
  76. package/node_modules/@humanwhocodes/module-importer/CHANGELOG.md +0 -15
  77. package/node_modules/@humanwhocodes/module-importer/LICENSE +0 -201
  78. package/node_modules/@humanwhocodes/module-importer/README.md +0 -80
  79. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.cjs +0 -22
  80. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.cts +0 -27
  81. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.d.ts +0 -2
  82. package/node_modules/@humanwhocodes/module-importer/dist/module-importer.js +0 -18
  83. package/node_modules/@humanwhocodes/module-importer/package.json +0 -65
  84. package/node_modules/@humanwhocodes/module-importer/src/module-importer.cjs +0 -81
  85. package/node_modules/@humanwhocodes/module-importer/src/module-importer.js +0 -22
  86. package/node_modules/@humanwhocodes/object-schema/.eslintrc.js +0 -29
  87. package/node_modules/@humanwhocodes/object-schema/.github/workflows/nodejs-test.yml +0 -27
  88. package/node_modules/@humanwhocodes/object-schema/.github/workflows/release-please.yml +0 -39
  89. package/node_modules/@humanwhocodes/object-schema/CHANGELOG.md +0 -26
  90. package/node_modules/@humanwhocodes/object-schema/LICENSE +0 -29
  91. package/node_modules/@humanwhocodes/object-schema/README.md +0 -234
  92. package/node_modules/@humanwhocodes/object-schema/package.json +0 -33
  93. package/node_modules/@humanwhocodes/object-schema/src/index.js +0 -7
  94. package/node_modules/@humanwhocodes/object-schema/src/merge-strategy.js +0 -53
  95. package/node_modules/@humanwhocodes/object-schema/src/object-schema.js +0 -301
  96. package/node_modules/@humanwhocodes/object-schema/src/validation-strategy.js +0 -102
  97. package/node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js +0 -66
  98. package/node_modules/@humanwhocodes/object-schema/tests/object-schema.js +0 -659
  99. package/node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js +0 -186
  100. package/node_modules/@nodelib/fs.scandir/LICENSE +0 -21
  101. package/node_modules/@nodelib/fs.scandir/README.md +0 -171
  102. package/node_modules/@nodelib/fs.scandir/out/adapters/fs.d.ts +0 -20
  103. package/node_modules/@nodelib/fs.scandir/out/adapters/fs.js +0 -19
  104. package/node_modules/@nodelib/fs.scandir/out/constants.d.ts +0 -4
  105. package/node_modules/@nodelib/fs.scandir/out/constants.js +0 -17
  106. package/node_modules/@nodelib/fs.scandir/out/index.d.ts +0 -12
  107. package/node_modules/@nodelib/fs.scandir/out/index.js +0 -26
  108. package/node_modules/@nodelib/fs.scandir/out/providers/async.d.ts +0 -7
  109. package/node_modules/@nodelib/fs.scandir/out/providers/async.js +0 -104
  110. package/node_modules/@nodelib/fs.scandir/out/providers/common.d.ts +0 -1
  111. package/node_modules/@nodelib/fs.scandir/out/providers/common.js +0 -13
  112. package/node_modules/@nodelib/fs.scandir/out/providers/sync.d.ts +0 -5
  113. package/node_modules/@nodelib/fs.scandir/out/providers/sync.js +0 -54
  114. package/node_modules/@nodelib/fs.scandir/out/settings.d.ts +0 -20
  115. package/node_modules/@nodelib/fs.scandir/out/settings.js +0 -24
  116. package/node_modules/@nodelib/fs.scandir/out/types/index.d.ts +0 -20
  117. package/node_modules/@nodelib/fs.scandir/out/types/index.js +0 -2
  118. package/node_modules/@nodelib/fs.scandir/out/utils/fs.d.ts +0 -2
  119. package/node_modules/@nodelib/fs.scandir/out/utils/fs.js +0 -19
  120. package/node_modules/@nodelib/fs.scandir/out/utils/index.d.ts +0 -2
  121. package/node_modules/@nodelib/fs.scandir/out/utils/index.js +0 -5
  122. package/node_modules/@nodelib/fs.scandir/package.json +0 -44
  123. package/node_modules/@nodelib/fs.stat/LICENSE +0 -21
  124. package/node_modules/@nodelib/fs.stat/README.md +0 -126
  125. package/node_modules/@nodelib/fs.stat/out/adapters/fs.d.ts +0 -13
  126. package/node_modules/@nodelib/fs.stat/out/adapters/fs.js +0 -17
  127. package/node_modules/@nodelib/fs.stat/out/index.d.ts +0 -12
  128. package/node_modules/@nodelib/fs.stat/out/index.js +0 -26
  129. package/node_modules/@nodelib/fs.stat/out/providers/async.d.ts +0 -4
  130. package/node_modules/@nodelib/fs.stat/out/providers/async.js +0 -36
  131. package/node_modules/@nodelib/fs.stat/out/providers/sync.d.ts +0 -3
  132. package/node_modules/@nodelib/fs.stat/out/providers/sync.js +0 -23
  133. package/node_modules/@nodelib/fs.stat/out/settings.d.ts +0 -16
  134. package/node_modules/@nodelib/fs.stat/out/settings.js +0 -16
  135. package/node_modules/@nodelib/fs.stat/out/types/index.d.ts +0 -4
  136. package/node_modules/@nodelib/fs.stat/out/types/index.js +0 -2
  137. package/node_modules/@nodelib/fs.stat/package.json +0 -37
  138. package/node_modules/@nodelib/fs.walk/LICENSE +0 -21
  139. package/node_modules/@nodelib/fs.walk/README.md +0 -215
  140. package/node_modules/@nodelib/fs.walk/out/index.d.ts +0 -14
  141. package/node_modules/@nodelib/fs.walk/out/index.js +0 -34
  142. package/node_modules/@nodelib/fs.walk/out/providers/async.d.ts +0 -12
  143. package/node_modules/@nodelib/fs.walk/out/providers/async.js +0 -30
  144. package/node_modules/@nodelib/fs.walk/out/providers/index.d.ts +0 -4
  145. package/node_modules/@nodelib/fs.walk/out/providers/index.js +0 -9
  146. package/node_modules/@nodelib/fs.walk/out/providers/stream.d.ts +0 -12
  147. package/node_modules/@nodelib/fs.walk/out/providers/stream.js +0 -34
  148. package/node_modules/@nodelib/fs.walk/out/providers/sync.d.ts +0 -10
  149. package/node_modules/@nodelib/fs.walk/out/providers/sync.js +0 -14
  150. package/node_modules/@nodelib/fs.walk/out/readers/async.d.ts +0 -30
  151. package/node_modules/@nodelib/fs.walk/out/readers/async.js +0 -97
  152. package/node_modules/@nodelib/fs.walk/out/readers/common.d.ts +0 -7
  153. package/node_modules/@nodelib/fs.walk/out/readers/common.js +0 -31
  154. package/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts +0 -6
  155. package/node_modules/@nodelib/fs.walk/out/readers/reader.js +0 -11
  156. package/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts +0 -15
  157. package/node_modules/@nodelib/fs.walk/out/readers/sync.js +0 -59
  158. package/node_modules/@nodelib/fs.walk/out/settings.d.ts +0 -30
  159. package/node_modules/@nodelib/fs.walk/out/settings.js +0 -26
  160. package/node_modules/@nodelib/fs.walk/out/types/index.d.ts +0 -8
  161. package/node_modules/@nodelib/fs.walk/out/types/index.js +0 -2
  162. package/node_modules/@nodelib/fs.walk/package.json +0 -44
  163. package/node_modules/@ungap/structured-clone/.github/workflows/node.js.yml +0 -31
  164. package/node_modules/@ungap/structured-clone/LICENSE +0 -15
  165. package/node_modules/@ungap/structured-clone/README.md +0 -95
  166. package/node_modules/@ungap/structured-clone/cjs/deserialize.js +0 -78
  167. package/node_modules/@ungap/structured-clone/cjs/index.js +0 -27
  168. package/node_modules/@ungap/structured-clone/cjs/json.js +0 -24
  169. package/node_modules/@ungap/structured-clone/cjs/package.json +0 -1
  170. package/node_modules/@ungap/structured-clone/cjs/serialize.js +0 -160
  171. package/node_modules/@ungap/structured-clone/cjs/types.js +0 -22
  172. package/node_modules/@ungap/structured-clone/esm/deserialize.js +0 -79
  173. package/node_modules/@ungap/structured-clone/esm/index.js +0 -25
  174. package/node_modules/@ungap/structured-clone/esm/json.js +0 -21
  175. package/node_modules/@ungap/structured-clone/esm/serialize.js +0 -161
  176. package/node_modules/@ungap/structured-clone/esm/types.js +0 -11
  177. package/node_modules/@ungap/structured-clone/package.json +0 -53
  178. package/node_modules/@ungap/structured-clone/structured-json.js +0 -1
package/README.md CHANGED
@@ -7,24 +7,63 @@ Custom extended rules for various Dinero specific standards & conventions.
7
7
  Bundled with dinero.Frontend & dinero.Admin package.json, so a general npm install will include it as default.
8
8
 
9
9
  Explicit install:
10
+
10
11
  ```bash
11
12
  npm install @dineroregnskab/eslint-plugin-eslint-custom-rules@latest --save-dev
12
13
  ```
13
14
 
14
- ## Adding rules
15
+ ## Development
16
+
17
+ Run `npm i` in root and in `/example`.
18
+
19
+ ### Adding rules
15
20
 
16
- Add the rule here:
21
+ - Add the rule here: `dinero-web-2.0/Dinero.Packages/Dinero.EslintCustomRules/rules`
17
22
 
18
- `dinero-web-2.0/Dinero.Packages/Dinero.EslintCustomRules/rules`
23
+ - Add the new js rule to this file `eslint-plugin-custom-rules.js`.
19
24
 
20
- You can test the rule by adding some code to test it on here.
25
+ - You can test the rule by adding some HTML code to test it on here `dinero-web-2.0/Dinero.Packages/Dinero.EslintCustomRules/example`
21
26
 
22
- `dinero-web-2.0/Dinero.Packages/Dinero.EslintCustomRules/example`
27
+ - After adding the rule you can restart the ESLint server in vs code by pressing F1 -> ESLint: Restart ESLint Server.
28
+
29
+ Add html rules in `test.html` and run test with
30
+
31
+ ```bash
32
+ npm run testhtml
33
+ ```
23
34
 
24
- And run:
35
+ Add ts rules in `test.ts` and run test with
25
36
 
26
37
  ```bash
27
- npx eslint test.ts
38
+ npm run testts
39
+ ```
40
+
41
+ #### Debugging what the eslint sees
42
+
43
+ Add a rule, and log it with console log, to see in terminal what is going on. Then run `npm run testhtml` npm script to see it in terminal.
44
+
45
+ ```js
46
+ module.exports = {
47
+ meta: {
48
+ type: "suggestion",
49
+ docs: {
50
+ description:
51
+ "Enforce using `danishCurrency` pipe instead of `currency` pipe in Angular HTML templates.",
52
+ },
53
+ fixable: "code",
54
+ schema: [],
55
+ },
56
+
57
+ create(context) {
58
+ return {
59
+ // Target the entire file and traverse each node
60
+ Program(node) {
61
+ console.log("Parsed Node Types:", node);
62
+ },
63
+ };
64
+ },
65
+ };
66
+
28
67
  ```
29
68
 
30
69
  ### Publish & install new rule locally
@@ -34,12 +73,14 @@ Run:
34
73
  ```bash
35
74
  npm patch
36
75
  ```
76
+
37
77
  ```bash
38
78
  npm publish
39
79
  ```
40
80
 
41
81
  - In dinero.Frontend and/or dinero.Admin, update the root `package.json` file with the newly published version number.
42
82
  - Locate the `eslintrc` file and add the new rule in the rules property (under `"files": ["*.html"]`, `"files": ["*.ts"]` etc. respectively).
83
+
43
84
  > **Note: The reference here must be in the format of the package name without "eslint-plugin" + rule name**
44
85
 
45
86
  Example:
@@ -52,9 +93,8 @@ Example:
52
93
  npm i
53
94
  ````
54
95
 
55
- > **Note: You might need to restart the IDE for the new rule to apply**
96
+ > **Note: You need to restart ESLint to apply new rules. Restart the ESLint server in vs code by pressing F1 -> ESLint: Restart ESLint Server or F1 -> reload window**
56
97
 
57
- #
58
98
  See [ESLint custom rule tutorial](https://eslint.org/docs/latest/extend/custom-rule-tutorial) for more.
59
99
 
60
100
  Useful tool for working with AST tree: [AST Explorer](https://astexplorer.net/)
@@ -1,10 +1,16 @@
1
- const returnReducerRule = require('./rules/reducers-should-always-return');
2
- const camelCaseRule = require('./rules/camel-case-attributes');
1
+ const returnReducerRule = require("./rules/reducers-should-always-return");
2
+ const camelCaseRule = require("./rules/camel-case-attributes");
3
+ const dayjsWithTimeZoneRule = require("./rules/dayjs-with-timezone");
4
+ const useDanishCurrencyPipeRule = require("./rules/use-danish-currency-pipe");
5
+ const replaceFirstWithTakeRule = require("./rules/replace-first-with-take");
3
6
 
4
7
  const customRulesPlugin = {
5
8
  rules: {
6
- 'reducers-should-always-return': returnReducerRule,
7
- 'attr-camel-case-rule': camelCaseRule,
9
+ "reducers-should-always-return": returnReducerRule,
10
+ "attr-camel-case-rule": camelCaseRule,
11
+ "dayjs-with-timezone": dayjsWithTimeZoneRule,
12
+ "use-danish-currency-pipe": useDanishCurrencyPipeRule,
13
+ "replace-first-with-take": replaceFirstWithTakeRule,
8
14
  },
9
15
  };
10
16
 
package/package.json CHANGED
@@ -1,11 +1,9 @@
1
1
  {
2
2
  "name": "@dineroregnskab/eslint-plugin-custom-rules",
3
- "version": "2.0.6",
3
+ "version": "2.1.0",
4
4
  "description": "ESLint plugin with custom rules for Dinero Regnskab",
5
5
  "main": "eslint-plugin-custom-rules.js",
6
- "scripts": {
7
- "test": ""
8
- },
6
+ "scripts": {},
9
7
  "keywords": [],
10
8
  "author": "",
11
9
  "license": "ISC",
@@ -0,0 +1,31 @@
1
+ module.exports = {
2
+ meta: {
3
+ type: "suggestion",
4
+ docs: {
5
+ description:
6
+ "Replace `first()` with `take(1)` in TypeScript files.",
7
+ },
8
+ fixable: "code",
9
+ schema: [],
10
+ },
11
+
12
+ create(context) {
13
+ return {
14
+ // Target CallExpressions like `first()`
15
+ CallExpression(node) {
16
+ // Check if the callee (function being called) is `first`
17
+ if (
18
+ node.callee.type === "Identifier" &&
19
+ node.callee.name === "first" &&
20
+ node.arguments.length === 0 // Ensure `first` is called with no arguments
21
+ ) {
22
+ context.report({
23
+ node,
24
+ message:
25
+ "Replace `first()` with `take(1)` to avoid errors if no value is ever emitted.",
26
+ });
27
+ }
28
+ },
29
+ };
30
+ },
31
+ };
@@ -0,0 +1,53 @@
1
+ module.exports = {
2
+ meta: {
3
+ type: "suggestion",
4
+ docs: {
5
+ description:
6
+ "Enforce using `danishCurrency` pipe instead of `currency` pipe in Angular HTML templates.",
7
+ },
8
+ fixable: "code",
9
+ schema: [],
10
+ },
11
+
12
+ create(context) {
13
+ return {
14
+ Program(node) {
15
+ const templateContent = node.value;
16
+ const currencyPipeRegex = /\|\s*currency/g;
17
+
18
+ let match;
19
+ while (
20
+ (match = currencyPipeRegex.exec(templateContent)) !== null
21
+ ) {
22
+ const matchStart = match.index;
23
+ const matchEnd = match.index + match[0].length;
24
+
25
+ const startLine = templateContent
26
+ .slice(0, matchStart)
27
+ .split("\n").length;
28
+ const startColumn =
29
+ matchStart -
30
+ templateContent.lastIndexOf("\n", matchStart) -
31
+ 1;
32
+
33
+ const endLine = templateContent
34
+ .slice(0, matchEnd)
35
+ .split("\n").length;
36
+ const endColumn =
37
+ matchEnd -
38
+ templateContent.lastIndexOf("\n", matchEnd) -
39
+ 1;
40
+
41
+ context.report({
42
+ loc: {
43
+ start: { line: startLine, column: startColumn },
44
+ end: { line: endLine, column: endColumn },
45
+ },
46
+ message:
47
+ "Use `danishCurrency` instead of `currency` pipe. We can't use Angular's native `currency` pipe because it doesn't support inputs with commas as decimal separators.",
48
+ });
49
+ }
50
+ },
51
+ };
52
+ },
53
+ };
package/willy.yaml ADDED
@@ -0,0 +1,5 @@
1
+ type: package
2
+ name: package-eslint-custom-rules
3
+ aliases:
4
+ - eslint-custom-rules
5
+ - eslintcustomrules
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014-2016, Jon Schlinkert
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,182 +0,0 @@
1
- # word-wrap [![NPM version](https://img.shields.io/npm/v/word-wrap.svg?style=flat)](https://www.npmjs.com/package/word-wrap) [![NPM monthly downloads](https://img.shields.io/npm/dm/word-wrap.svg?style=flat)](https://npmjs.org/package/word-wrap) [![NPM total downloads](https://img.shields.io/npm/dt/word-wrap.svg?style=flat)](https://npmjs.org/package/word-wrap) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/word-wrap.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/word-wrap)
2
-
3
- > Wrap words to a specified length.
4
-
5
- ## Install
6
-
7
- Install with [npm](https://www.npmjs.com/):
8
-
9
- ```sh
10
- $ npm install --save word-wrap
11
- ```
12
-
13
- ## Usage
14
-
15
- ```js
16
- var wrap = require('word-wrap');
17
-
18
- wrap('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.');
19
- ```
20
-
21
- Results in:
22
-
23
- ```
24
- Lorem ipsum dolor sit amet, consectetur adipiscing
25
- elit, sed do eiusmod tempor incididunt ut labore
26
- et dolore magna aliqua. Ut enim ad minim veniam,
27
- quis nostrud exercitation ullamco laboris nisi ut
28
- aliquip ex ea commodo consequat.
29
- ```
30
-
31
- ## Options
32
-
33
- ![image](https://cloud.githubusercontent.com/assets/383994/6543728/7a381c08-c4f6-11e4-8b7d-b6ba197569c9.png)
34
-
35
- ### options.width
36
-
37
- Type: `Number`
38
-
39
- Default: `50`
40
-
41
- The width of the text before wrapping to a new line.
42
-
43
- **Example:**
44
-
45
- ```js
46
- wrap(str, {width: 60});
47
- ```
48
-
49
- ### options.indent
50
-
51
- Type: `String`
52
-
53
- Default: `` (none)
54
-
55
- The string to use at the beginning of each line.
56
-
57
- **Example:**
58
-
59
- ```js
60
- wrap(str, {indent: ' '});
61
- ```
62
-
63
- ### options.newline
64
-
65
- Type: `String`
66
-
67
- Default: `\n`
68
-
69
- The string to use at the end of each line.
70
-
71
- **Example:**
72
-
73
- ```js
74
- wrap(str, {newline: '\n\n'});
75
- ```
76
-
77
- ### options.escape
78
-
79
- Type: `function`
80
-
81
- Default: `function(str){return str;}`
82
-
83
- An escape function to run on each line after splitting them.
84
-
85
- **Example:**
86
-
87
- ```js
88
- var xmlescape = require('xml-escape');
89
- wrap(str, {
90
- escape: function(string){
91
- return xmlescape(string);
92
- }
93
- });
94
- ```
95
-
96
- ### options.trim
97
-
98
- Type: `Boolean`
99
-
100
- Default: `false`
101
-
102
- Trim trailing whitespace from the returned string. This option is included since `.trim()` would also strip the leading indentation from the first line.
103
-
104
- **Example:**
105
-
106
- ```js
107
- wrap(str, {trim: true});
108
- ```
109
-
110
- ### options.cut
111
-
112
- Type: `Boolean`
113
-
114
- Default: `false`
115
-
116
- Break a word between any two letters when the word is longer than the specified width.
117
-
118
- **Example:**
119
-
120
- ```js
121
- wrap(str, {cut: true});
122
- ```
123
-
124
- ## About
125
-
126
- ### Related projects
127
-
128
- * [common-words](https://www.npmjs.com/package/common-words): Updated list (JSON) of the 100 most common words in the English language. Useful for… [more](https://github.com/jonschlinkert/common-words) | [homepage](https://github.com/jonschlinkert/common-words "Updated list (JSON) of the 100 most common words in the English language. Useful for excluding these words from arrays.")
129
- * [shuffle-words](https://www.npmjs.com/package/shuffle-words): Shuffle the words in a string and optionally the letters in each word using the… [more](https://github.com/jonschlinkert/shuffle-words) | [homepage](https://github.com/jonschlinkert/shuffle-words "Shuffle the words in a string and optionally the letters in each word using the Fisher-Yates algorithm. Useful for creating test fixtures, benchmarking samples, etc.")
130
- * [unique-words](https://www.npmjs.com/package/unique-words): Return the unique words in a string or array. | [homepage](https://github.com/jonschlinkert/unique-words "Return the unique words in a string or array.")
131
- * [wordcount](https://www.npmjs.com/package/wordcount): Count the words in a string. Support for english, CJK and Cyrillic. | [homepage](https://github.com/jonschlinkert/wordcount "Count the words in a string. Support for english, CJK and Cyrillic.")
132
-
133
- ### Contributing
134
-
135
- Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
136
-
137
- ### Contributors
138
-
139
- | **Commits** | **Contributor** |
140
- | --- | --- |
141
- | 43 | [jonschlinkert](https://github.com/jonschlinkert) |
142
- | 2 | [lordvlad](https://github.com/lordvlad) |
143
- | 2 | [hildjj](https://github.com/hildjj) |
144
- | 1 | [danilosampaio](https://github.com/danilosampaio) |
145
- | 1 | [2fd](https://github.com/2fd) |
146
- | 1 | [toddself](https://github.com/toddself) |
147
- | 1 | [wolfgang42](https://github.com/wolfgang42) |
148
- | 1 | [zachhale](https://github.com/zachhale) |
149
-
150
- ### Building docs
151
-
152
- _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
153
-
154
- To generate the readme, run the following command:
155
-
156
- ```sh
157
- $ npm install -g verbose/verb#dev verb-generate-readme && verb
158
- ```
159
-
160
- ### Running tests
161
-
162
- Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
163
-
164
- ```sh
165
- $ npm install && npm test
166
- ```
167
-
168
- ### Author
169
-
170
- **Jon Schlinkert**
171
-
172
- * [github/jonschlinkert](https://github.com/jonschlinkert)
173
- * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
174
-
175
- ### License
176
-
177
- Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
178
- Released under the [MIT License](LICENSE).
179
-
180
- ***
181
-
182
- _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 02, 2017._
@@ -1,50 +0,0 @@
1
- /**
2
- * Wrap words to a specified length.
3
- */
4
- export = wrap;
5
-
6
- declare function wrap(str: string, options?: wrap.IOptions): string;
7
-
8
- declare namespace wrap {
9
- export interface IOptions {
10
-
11
- /**
12
- * The width of the text before wrapping to a new line.
13
- * @default ´50´
14
- */
15
- width?: number;
16
-
17
- /**
18
- * The string to use at the beginning of each line.
19
- * @default ´´ (none)
20
- */
21
- indent?: string;
22
-
23
- /**
24
- * The string to use at the end of each line.
25
- * @default ´\n´
26
- */
27
- newline?: string;
28
-
29
- /**
30
- * An escape function to run on each line after splitting them.
31
- * @default (str: string) => string;
32
- */
33
- escape?: (str: string) => string;
34
-
35
- /**
36
- * Trim trailing whitespace from the returned string.
37
- * This option is included since .trim() would also strip
38
- * the leading indentation from the first line.
39
- * @default true
40
- */
41
- trim?: boolean;
42
-
43
- /**
44
- * Break a word between any two letters when the word is longer
45
- * than the specified width.
46
- * @default false
47
- */
48
- cut?: boolean;
49
- }
50
- }
@@ -1,52 +0,0 @@
1
- /*!
2
- * word-wrap <https://github.com/jonschlinkert/word-wrap>
3
- *
4
- * Copyright (c) 2014-2023, Jon Schlinkert.
5
- * Released under the MIT License.
6
- */
7
-
8
- function trimTabAndSpaces(str) {
9
- const lines = str.split('\n');
10
- const trimmedLines = lines.map((line) => line.trimEnd());
11
- return trimmedLines.join('\n');
12
- }
13
-
14
- module.exports = function(str, options) {
15
- options = options || {};
16
- if (str == null) {
17
- return str;
18
- }
19
-
20
- var width = options.width || 50;
21
- var indent = (typeof options.indent === 'string')
22
- ? options.indent
23
- : '';
24
-
25
- var newline = options.newline || '\n' + indent;
26
- var escape = typeof options.escape === 'function'
27
- ? options.escape
28
- : identity;
29
-
30
- var regexString = '.{1,' + width + '}';
31
- if (options.cut !== true) {
32
- regexString += '([\\s\u200B]+|$)|[^\\s\u200B]+?([\\s\u200B]+|$)';
33
- }
34
-
35
- var re = new RegExp(regexString, 'g');
36
- var lines = str.match(re) || [];
37
- var result = indent + lines.map(function(line) {
38
- if (line.slice(-1) === '\n') {
39
- line = line.slice(0, line.length - 1);
40
- }
41
- return escape(line);
42
- }).join(newline);
43
-
44
- if (options.trim === true) {
45
- result = trimTabAndSpaces(result);
46
- }
47
- return result;
48
- };
49
-
50
- function identity(str) {
51
- return str;
52
- }
@@ -1,81 +0,0 @@
1
- {
2
- "name": "@aashutoshrathi/word-wrap",
3
- "description": "Wrap words to a specified length.",
4
- "version": "1.2.6",
5
- "homepage": "https://github.com/aashutoshrathi/word-wrap",
6
- "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7
- "contributors": [
8
- "Aashutosh Rathi <aashutoshrathi@gmail.com>",
9
- "Danilo Sampaio <danilo.sampaio@gmail.com> (localhost:8080)",
10
- "Fede Ramirez <i@2fd.me> (https://2fd.github.io)",
11
- "Joe Hildebrand <joe-github@cursive.net> (https://twitter.com/hildjj)",
12
- "Jon Schlinkert <jon.schlinkert@sellside.com> (http://twitter.com/jonschlinkert)",
13
- "Todd Kennedy (https://tck.io)",
14
- "Waldemar Reusch (https://github.com/lordvlad)",
15
- "Wolfgang Faust (http://www.linestarve.com)",
16
- "Zach Hale <zachhale@gmail.com> (http://zachhale.com)"
17
- ],
18
- "repository": {
19
- "type": "git",
20
- "url": "git+https://github.com/aashutoshrathi/word-wrap.git"
21
- },
22
- "bugs": {
23
- "url": "https://github.com/aashutoshrathi/word-wrap/issues"
24
- },
25
- "license": "MIT",
26
- "files": [
27
- "index.js",
28
- "index.d.ts"
29
- ],
30
- "main": "index.js",
31
- "engines": {
32
- "node": ">=0.10.0"
33
- },
34
- "scripts": {
35
- "test": "mocha"
36
- },
37
- "devDependencies": {
38
- "gulp-format-md": "^0.1.11",
39
- "mocha": "^10.2.0"
40
- },
41
- "keywords": [
42
- "break",
43
- "carriage",
44
- "line",
45
- "new-line",
46
- "newline",
47
- "return",
48
- "soft",
49
- "text",
50
- "word",
51
- "word-wrap",
52
- "words",
53
- "wrap"
54
- ],
55
- "typings": "index.d.ts",
56
- "verb": {
57
- "toc": false,
58
- "layout": "default",
59
- "tasks": [
60
- "readme"
61
- ],
62
- "plugins": [
63
- "gulp-format-md"
64
- ],
65
- "lint": {
66
- "reflinks": true
67
- },
68
- "related": {
69
- "list": [
70
- "common-words",
71
- "shuffle-words",
72
- "unique-words",
73
- "wordcount"
74
- ]
75
- },
76
- "reflinks": [
77
- "verb",
78
- "verb-generate-readme"
79
- ]
80
- }
81
- }
@@ -1 +0,0 @@
1
- # @angular-eslint/bundled-angular-compiler
@@ -1,5 +0,0 @@
1
- export * from '@angular/compiler';
2
- import type { MessageBundle, ParsedTemplate, LocalizedString } from '@angular/compiler';
3
- export type Comment = Required<ParsedTemplate>['commentNodes'][number];
4
- export type Message = ReturnType<MessageBundle['getMessages']>[number];
5
- export type I18nMeta = LocalizedString['metaBlock'];