djlint 1.30.0 → 1.30.2

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 (368) hide show
  1. package/package.json +3 -2
  2. package/.coveragerc +0 -9
  3. package/.editorconfig +0 -21
  4. package/.flake8 +0 -0
  5. package/.github/FUNDING.yml +0 -2
  6. package/.github/ISSUE_TEMPLATE/config.yml +0 -6
  7. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -19
  8. package/.github/ISSUE_TEMPLATE/formatter_but_report.md +0 -30
  9. package/.github/ISSUE_TEMPLATE/linter_bug_report.md +0 -34
  10. package/.github/ISSUE_TEMPLATE/translation.md +0 -14
  11. package/.github/config.yml +0 -4
  12. package/.github/pull_request_template.md +0 -10
  13. package/.github/workflows/cancel.yml +0 -17
  14. package/.github/workflows/demo.yml +0 -98
  15. package/.github/workflows/issues.yml +0 -23
  16. package/.github/workflows/linkcheck.yaml +0 -21
  17. package/.github/workflows/lint.yml +0 -25
  18. package/.github/workflows/release.yml +0 -57
  19. package/.github/workflows/test.yml +0 -85
  20. package/.pre-commit-config.yaml +0 -45
  21. package/.pre-commit-hooks.yaml +0 -71
  22. package/.prettierignore +0 -7
  23. package/.prettierrc +0 -11
  24. package/.releaserc +0 -16
  25. package/CHANGELOG.md +0 -13
  26. package/MANIFEST.in +0 -2
  27. package/build_demo.sh +0 -17
  28. package/docs/.eleventy.js +0 -425
  29. package/docs/.eleventyignore +0 -2
  30. package/docs/.prettierignore +0 -3
  31. package/docs/.prettierrc +0 -11
  32. package/docs/package.json +0 -73
  33. package/docs/readme.md +0 -17
  34. package/docs/src/_data/configuration.json +0 -646
  35. package/docs/src/_data/eleventyComputed.js +0 -22
  36. package/docs/src/_data/i18n/index.js +0 -159
  37. package/docs/src/_data/js.js +0 -7
  38. package/docs/src/_data/locales.js +0 -17
  39. package/docs/src/_data/site.json +0 -8
  40. package/docs/src/_includes/demo.njk +0 -157
  41. package/docs/src/_includes/docs_layout.njk +0 -34
  42. package/docs/src/_includes/foot.njk +0 -26
  43. package/docs/src/_includes/index.njk +0 -187
  44. package/docs/src/_includes/languages_layout.njk +0 -11
  45. package/docs/src/_includes/layout.njk +0 -111
  46. package/docs/src/_includes/nav.njk +0 -85
  47. package/docs/src/_utils/minify-html.js +0 -14
  48. package/docs/src/_utils/rollupper.js +0 -91
  49. package/docs/src/_utils/scripts.11ty.js +0 -27
  50. package/docs/src/demo.njk +0 -4
  51. package/docs/src/docs/best-practices.md +0 -78
  52. package/docs/src/docs/changelog.md +0 -452
  53. package/docs/src/docs/configuration.md +0 -145
  54. package/docs/src/docs/docs.json +0 -4
  55. package/docs/src/docs/formatter.md +0 -82
  56. package/docs/src/docs/getting-started.md +0 -126
  57. package/docs/src/docs/ignoring-code.md +0 -75
  58. package/docs/src/docs/integrations.md +0 -120
  59. package/docs/src/docs/languages/angular.md +0 -31
  60. package/docs/src/docs/languages/django.md +0 -40
  61. package/docs/src/docs/languages/golang.md +0 -31
  62. package/docs/src/docs/languages/handlebars.md +0 -31
  63. package/docs/src/docs/languages/jinja.md +0 -39
  64. package/docs/src/docs/languages/languages.json +0 -3
  65. package/docs/src/docs/languages/mustache.md +0 -31
  66. package/docs/src/docs/languages/nunjucks.md +0 -39
  67. package/docs/src/docs/languages/twig.md +0 -41
  68. package/docs/src/docs/linter.md +0 -199
  69. package/docs/src/fr/demo.njk +0 -4
  70. package/docs/src/fr/docs/best-practices.md +0 -78
  71. package/docs/src/fr/docs/changelog.md +0 -452
  72. package/docs/src/fr/docs/configuration.md +0 -144
  73. package/docs/src/fr/docs/docs.json +0 -3
  74. package/docs/src/fr/docs/formatter.md +0 -83
  75. package/docs/src/fr/docs/getting-started.md +0 -127
  76. package/docs/src/fr/docs/ignoring-code.md +0 -75
  77. package/docs/src/fr/docs/integrations.md +0 -100
  78. package/docs/src/fr/docs/languages/angular.md +0 -31
  79. package/docs/src/fr/docs/languages/django.md +0 -31
  80. package/docs/src/fr/docs/languages/golang.md +0 -31
  81. package/docs/src/fr/docs/languages/handlebars.md +0 -31
  82. package/docs/src/fr/docs/languages/jinja.md +0 -31
  83. package/docs/src/fr/docs/languages/languages.json +0 -3
  84. package/docs/src/fr/docs/languages/mustache.md +0 -31
  85. package/docs/src/fr/docs/languages/nunjucks.md +0 -31
  86. package/docs/src/fr/docs/languages/twig.md +0 -31
  87. package/docs/src/fr/docs/linter.md +0 -207
  88. package/docs/src/fr/fr.json +0 -4
  89. package/docs/src/fr/index.njk +0 -4
  90. package/docs/src/index.njk +0 -4
  91. package/docs/src/lib/generate-content-hash.js +0 -13
  92. package/docs/src/robots.txt +0 -4
  93. package/docs/src/ru/demo.njk +0 -4
  94. package/docs/src/ru/docs/best-practices.md +0 -78
  95. package/docs/src/ru/docs/changelog.md +0 -453
  96. package/docs/src/ru/docs/configuration.md +0 -142
  97. package/docs/src/ru/docs/docs.json +0 -3
  98. package/docs/src/ru/docs/formatter.md +0 -82
  99. package/docs/src/ru/docs/getting-started.md +0 -127
  100. package/docs/src/ru/docs/ignoring-code.md +0 -75
  101. package/docs/src/ru/docs/integrations.md +0 -100
  102. package/docs/src/ru/docs/languages/angular.md +0 -31
  103. package/docs/src/ru/docs/languages/django.md +0 -31
  104. package/docs/src/ru/docs/languages/golang.md +0 -31
  105. package/docs/src/ru/docs/languages/handlebars.md +0 -31
  106. package/docs/src/ru/docs/languages/jinja.md +0 -31
  107. package/docs/src/ru/docs/languages/languages.json +0 -3
  108. package/docs/src/ru/docs/languages/mustache.md +0 -31
  109. package/docs/src/ru/docs/languages/nunjucks.md +0 -31
  110. package/docs/src/ru/docs/languages/twig.md +0 -31
  111. package/docs/src/ru/docs/linter.md +0 -126
  112. package/docs/src/ru/index.njk +0 -4
  113. package/docs/src/ru/ru.json +0 -4
  114. package/docs/src/sitemap.njk +0 -16
  115. package/docs/src/static/css/site.scss +0 -467
  116. package/docs/src/static/font/fontawesome/stylesheet.scss +0 -78
  117. package/docs/src/static/img/apple-touch-icon.png +0 -0
  118. package/docs/src/static/img/demo-min.gif +0 -0
  119. package/docs/src/static/img/demo.gif +0 -0
  120. package/docs/src/static/img/demo.webm +0 -0
  121. package/docs/src/static/img/favicon-16x16.png +0 -0
  122. package/docs/src/static/img/favicon-32x32.png +0 -0
  123. package/docs/src/static/img/favicon.ico +0 -0
  124. package/docs/src/static/img/icon-square.indd +0 -0
  125. package/docs/src/static/img/icon-square.png +0 -0
  126. package/docs/src/static/img/icon.png +0 -0
  127. package/docs/src/static/img/logo-192x192.png +0 -0
  128. package/docs/src/static/img/logo-512x512.png +0 -0
  129. package/docs/src/static/img/logos/angular.png +0 -0
  130. package/docs/src/static/img/logos/django.png +0 -0
  131. package/docs/src/static/img/logos/golang.png +0 -0
  132. package/docs/src/static/img/logos/handlebars.png +0 -0
  133. package/docs/src/static/img/logos/jinja.png +0 -0
  134. package/docs/src/static/img/logos/mustache.png +0 -0
  135. package/docs/src/static/img/logos/nunjucks.png +0 -0
  136. package/docs/src/static/img/logos/twig.png +0 -0
  137. package/docs/src/static/img/old_demo.gif +0 -0
  138. package/docs/src/static/img/style.css +0 -122
  139. package/docs/src/static/js/animate.js +0 -69
  140. package/docs/src/static/js/editor.js +0 -171
  141. package/docs/src/static/js/hamburger.js +0 -19
  142. package/docs/src/static/js/modal.js +0 -47
  143. package/docs/src/static/js/worker.js +0 -142
  144. package/docs/src/static/py/EditorConfig-99-py3-none-any.whl +0 -0
  145. package/docs/src/static/py/PyYAML-99-py3-none-any.whl +0 -0
  146. package/docs/src/static/py/click-99-py3-none-any.whl +0 -0
  147. package/docs/src/static/py/colorama-99-py3-none-any.whl +0 -0
  148. package/docs/src/static/py/cssbeautifier-99-py3-none-any.whl +0 -0
  149. package/docs/src/static/py/djlint-99-py3-none-any.whl +0 -0
  150. package/docs/src/static/py/html_tag_names-99-py3-none-any.whl +0 -0
  151. package/docs/src/static/py/html_void_elements-99-py3-none-any.whl +0 -0
  152. package/docs/src/static/py/jsbeautifier-99-py3-none-any.whl +0 -0
  153. package/docs/src/static/py/json5-99-py3-none-any.whl +0 -0
  154. package/docs/src/static/py/pathspec-99-py3-none-any.whl +0 -0
  155. package/docs/src/static/py/regex-2023.5.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl +0 -0
  156. package/docs/src/static/py/six-1.16.0-py2.py3-none-any.whl +0 -0
  157. package/docs/src/static/py/tomli-2.0.1-py3-none-any.whl +0 -0
  158. package/docs/src/static/py/tqdm-4.65.0-py3-none-any.whl +0 -0
  159. package/icon.xcf +0 -0
  160. package/poetry.lock +0 -835
  161. package/pyproject.toml +0 -100
  162. package/renovate.json +0 -44
  163. package/scripts/updateVersion.js +0 -16
  164. package/src/djlint/__init__.py +0 -451
  165. package/src/djlint/__main__.py +0 -4
  166. package/src/djlint/formatter/__init__.py +0 -1
  167. package/src/djlint/formatter/attributes.py +0 -212
  168. package/src/djlint/formatter/compress.py +0 -64
  169. package/src/djlint/formatter/condense.py +0 -221
  170. package/src/djlint/formatter/css.py +0 -60
  171. package/src/djlint/formatter/expand.py +0 -111
  172. package/src/djlint/formatter/indent.py +0 -418
  173. package/src/djlint/formatter/js.py +0 -58
  174. package/src/djlint/helpers.py +0 -321
  175. package/src/djlint/lint.py +0 -128
  176. package/src/djlint/output.py +0 -220
  177. package/src/djlint/reformat.py +0 -63
  178. package/src/djlint/rules/H025.py +0 -65
  179. package/src/djlint/rules.yaml +0 -279
  180. package/src/djlint/settings.py +0 -969
  181. package/src/djlint/src.py +0 -91
  182. package/tests/__init__.py +0 -0
  183. package/tests/conftest.py +0 -239
  184. package/tests/test_cli.py +0 -71
  185. package/tests/test_config/__init__.py +0 -0
  186. package/tests/test_config/test_blank_line_after_tag.py +0 -135
  187. package/tests/test_config/test_blank_line_before_tag.py +0 -141
  188. package/tests/test_config/test_close_void_tags.py +0 -31
  189. package/tests/test_config/test_custom_blocks.py +0 -56
  190. package/tests/test_config/test_custom_html.py +0 -45
  191. package/tests/test_config/test_djlintrc/.djlintrc +0 -38
  192. package/tests/test_config/test_djlintrc/__init__.py +0 -0
  193. package/tests/test_config/test_djlintrc/test_config.py +0 -44
  194. package/tests/test_config/test_djlintrc_custom/.djlint-cust +0 -38
  195. package/tests/test_config/test_djlintrc_custom/.djlintrc +0 -2
  196. package/tests/test_config/test_djlintrc_custom/__init__.py +0 -0
  197. package/tests/test_config/test_djlintrc_custom/test_config.py +0 -48
  198. package/tests/test_config/test_excludes/__init__.py +0 -0
  199. package/tests/test_config/test_excludes/excluded.html +0 -1
  200. package/tests/test_config/test_excludes/foo/excluded.html +0 -1
  201. package/tests/test_config/test_excludes/html.html +0 -1
  202. package/tests/test_config/test_excludes/pyproject.toml +0 -3
  203. package/tests/test_config/test_excludes/test_config.py +0 -30
  204. package/tests/test_config/test_extension/__init__.py +0 -0
  205. package/tests/test_config/test_extension/html.test +0 -1
  206. package/tests/test_config/test_extension/pyproject.toml +0 -3
  207. package/tests/test_config/test_extension/test_config.py +0 -27
  208. package/tests/test_config/test_files/.djlintrc_global +0 -9
  209. package/tests/test_config/test_files/test.html +0 -3
  210. package/tests/test_config/test_files/test_config.py +0 -123
  211. package/tests/test_config/test_files/test_two.html +0 -1
  212. package/tests/test_config/test_format_attribute_template_tags.py +0 -280
  213. package/tests/test_config/test_format_css.py +0 -197
  214. package/tests/test_config/test_format_js.py +0 -220
  215. package/tests/test_config/test_gitignore/__init__.py +0 -0
  216. package/tests/test_config/test_gitignore/html_one.html +0 -1
  217. package/tests/test_config/test_gitignore/html_two.html +0 -1
  218. package/tests/test_config/test_gitignore/test_config.py +0 -142
  219. package/tests/test_config/test_ignore/__init__.py +0 -0
  220. package/tests/test_config/test_ignore/html.html +0 -1
  221. package/tests/test_config/test_ignore/html_two.html +0 -12
  222. package/tests/test_config/test_ignore/pyproject.toml +0 -3
  223. package/tests/test_config/test_ignore/test_config.py +0 -32
  224. package/tests/test_config/test_ignore_blocks.py +0 -45
  225. package/tests/test_config/test_ignore_case.py +0 -39
  226. package/tests/test_config/test_indent.py +0 -63
  227. package/tests/test_config/test_linter_output_format/__init__.py +0 -0
  228. package/tests/test_config/test_linter_output_format/html-one.html +0 -1
  229. package/tests/test_config/test_linter_output_format/html-two.html +0 -1
  230. package/tests/test_config/test_linter_output_format/pyproject.toml +0 -3
  231. package/tests/test_config/test_linter_output_format/test_config.py +0 -34
  232. package/tests/test_config/test_max_attribute_length.py +0 -100
  233. package/tests/test_config/test_max_line_length.py +0 -94
  234. package/tests/test_config/test_per_file_ignores/__init__.py +0 -0
  235. package/tests/test_config/test_per_file_ignores/html.html +0 -2
  236. package/tests/test_config/test_per_file_ignores/pyproject.toml +0 -2
  237. package/tests/test_config/test_per_file_ignores/test_config.py +0 -25
  238. package/tests/test_config/test_pragmas/__init__.py +0 -0
  239. package/tests/test_config/test_pragmas/html_five.html +0 -2
  240. package/tests/test_config/test_pragmas/html_four.html +0 -5
  241. package/tests/test_config/test_pragmas/html_one.html +0 -1
  242. package/tests/test_config/test_pragmas/html_six.html +0 -2
  243. package/tests/test_config/test_pragmas/html_three.html +0 -4
  244. package/tests/test_config/test_pragmas/html_two.html +0 -2
  245. package/tests/test_config/test_pragmas/pyproject.toml +0 -3
  246. package/tests/test_config/test_pragmas/test_config.py +0 -142
  247. package/tests/test_config/test_preserve_blank_lines.py +0 -109
  248. package/tests/test_config/test_preserve_leading_space.py +0 -159
  249. package/tests/test_config/test_profile/__init__.py +0 -0
  250. package/tests/test_config/test_profile/html.html +0 -2
  251. package/tests/test_config/test_profile/pyproject.toml +0 -3
  252. package/tests/test_config/test_profile/test_config.py +0 -64
  253. package/tests/test_config/test_pyproject/__init__.py +0 -0
  254. package/tests/test_config/test_pyproject/blank.html +0 -0
  255. package/tests/test_config/test_pyproject/pyproject.toml +0 -36
  256. package/tests/test_config/test_pyproject/test_config.py +0 -44
  257. package/tests/test_django/__init__.py +0 -0
  258. package/tests/test_django/test_asset.py +0 -32
  259. package/tests/test_django/test_autoescape.py +0 -25
  260. package/tests/test_django/test_block.py +0 -29
  261. package/tests/test_django/test_blocktrans.py +0 -236
  262. package/tests/test_django/test_blocktrans_trimmed.py +0 -283
  263. package/tests/test_django/test_comments.py +0 -164
  264. package/tests/test_django/test_filter.py +0 -30
  265. package/tests/test_django/test_for.py +0 -34
  266. package/tests/test_django/test_if.py +0 -34
  267. package/tests/test_django/test_ifchanged.py +0 -37
  268. package/tests/test_django/test_include.py +0 -24
  269. package/tests/test_django/test_load.py +0 -24
  270. package/tests/test_django/test_quoted.py +0 -34
  271. package/tests/test_django/test_spaceless.py +0 -30
  272. package/tests/test_django/test_tag_spaces.py +0 -35
  273. package/tests/test_django/test_templatetag.py +0 -40
  274. package/tests/test_django/test_verbatim.py +0 -24
  275. package/tests/test_django/test_with.py +0 -32
  276. package/tests/test_djlint/-.html +0 -1
  277. package/tests/test_djlint/__init__.py +0 -0
  278. package/tests/test_djlint/bad.html +0 -6
  279. package/tests/test_djlint/bad.html.dj +0 -23
  280. package/tests/test_djlint/bad.html.dj2 +0 -2
  281. package/tests/test_djlint/multiple_files/a/a.html +0 -1
  282. package/tests/test_djlint/multiple_files/b/b1.html +0 -1
  283. package/tests/test_djlint/multiple_files/b/b2.html +0 -1
  284. package/tests/test_djlint/test_djlint.py +0 -242
  285. package/tests/test_golang/__init__.py +0 -0
  286. package/tests/test_golang/test_if.py +0 -24
  287. package/tests/test_golang/test_range.py +0 -24
  288. package/tests/test_handlebars/__init__.py +0 -0
  289. package/tests/test_handlebars/test_each.py +0 -34
  290. package/tests/test_handlebars/test_else.py +0 -24
  291. package/tests/test_handlebars/test_with.py +0 -24
  292. package/tests/test_html/__init__.py +0 -0
  293. package/tests/test_html/test_alpinejs.py +0 -65
  294. package/tests/test_html/test_attributes.py +0 -935
  295. package/tests/test_html/test_aurelia.py +0 -24
  296. package/tests/test_html/test_basics.py +0 -905
  297. package/tests/test_html/test_bracket_same_line.py +0 -177
  298. package/tests/test_html/test_case.py +0 -81
  299. package/tests/test_html/test_cdata.py +0 -34
  300. package/tests/test_html/test_comments.py +0 -333
  301. package/tests/test_html/test_css.py +0 -193
  302. package/tests/test_html/test_doctype_declarations.py +0 -202
  303. package/tests/test_html/test_ignored.py +0 -193
  304. package/tests/test_html/test_interpolation.py +0 -56
  305. package/tests/test_html/test_line_break_after_multiline_tag.py +0 -95
  306. package/tests/test_html/test_next_line_empty.py +0 -53
  307. package/tests/test_html/test_selfclosing.py +0 -55
  308. package/tests/test_html/test_single_attribute_per_line.py +0 -87
  309. package/tests/test_html/test_srcset.py +0 -43
  310. package/tests/test_html/test_svg.py +0 -104
  311. package/tests/test_html/test_symbol_entities.py +0 -34
  312. package/tests/test_html/test_tag_code.py +0 -24
  313. package/tests/test_html/test_tag_dd.py +0 -24
  314. package/tests/test_html/test_tag_details_summary.py +0 -24
  315. package/tests/test_html/test_tag_dt.py +0 -24
  316. package/tests/test_html/test_tag_fig_caption.py +0 -29
  317. package/tests/test_html/test_tag_hr.py +0 -29
  318. package/tests/test_html/test_tag_picture.py +0 -32
  319. package/tests/test_html/test_tag_pre.py +0 -45
  320. package/tests/test_html/test_tag_script.py +0 -516
  321. package/tests/test_html/test_tag_small.py +0 -24
  322. package/tests/test_html/test_tag_span.py +0 -119
  323. package/tests/test_html/test_tag_textarea.py +0 -82
  324. package/tests/test_html/test_tags.py +0 -842
  325. package/tests/test_html/test_text.py +0 -34
  326. package/tests/test_html/test_whitespace.py +0 -477
  327. package/tests/test_html/test_yaml.py +0 -156
  328. package/tests/test_jinja/__init__.py +0 -0
  329. package/tests/test_jinja/test_call.py +0 -34
  330. package/tests/test_jinja/test_parenthesis.py +0 -24
  331. package/tests/test_linter/__init__.py +0 -0
  332. package/tests/test_linter/test_custom_rules/.djlint_rules.yaml +0 -6
  333. package/tests/test_linter/test_custom_rules/__init__.py +0 -0
  334. package/tests/test_linter/test_custom_rules/html.html +0 -1
  335. package/tests/test_linter/test_custom_rules/pyproject.toml +0 -1
  336. package/tests/test_linter/test_custom_rules/test_linter.py +0 -29
  337. package/tests/test_linter/test_custom_rules_bad/.djlint_rules.yaml +0 -24
  338. package/tests/test_linter/test_custom_rules_bad/__init__.py +0 -0
  339. package/tests/test_linter/test_custom_rules_bad/html.html +0 -1
  340. package/tests/test_linter/test_custom_rules_bad/pyproject.toml +0 -1
  341. package/tests/test_linter/test_custom_rules_bad/test_linter.py +0 -29
  342. package/tests/test_linter/test_django_linter.py +0 -476
  343. package/tests/test_linter/test_h005.py +0 -45
  344. package/tests/test_linter/test_h006.py +0 -81
  345. package/tests/test_linter/test_h007.py +0 -45
  346. package/tests/test_linter/test_h008.py +0 -60
  347. package/tests/test_linter/test_h009.py +0 -45
  348. package/tests/test_linter/test_h010.py +0 -44
  349. package/tests/test_linter/test_h037.py +0 -150
  350. package/tests/test_linter/test_ignore_rules.py +0 -45
  351. package/tests/test_linter/test_jinja_linter.py +0 -227
  352. package/tests/test_linter/test_linter.py +0 -691
  353. package/tests/test_linter/test_nunjucks_linter.py +0 -59
  354. package/tests/test_linter/test_python_module_rules/.djlint_rules.yaml +0 -4
  355. package/tests/test_linter/test_python_module_rules/__init__.py +0 -0
  356. package/tests/test_linter/test_python_module_rules/html_bad.html +0 -3
  357. package/tests/test_linter/test_python_module_rules/html_ok.html +0 -3
  358. package/tests/test_linter/test_python_module_rules/my_module.py +0 -32
  359. package/tests/test_linter/test_python_module_rules/pyproject.toml +0 -1
  360. package/tests/test_linter/test_python_module_rules/test_linter.py +0 -26
  361. package/tests/test_nunjucks/__init__.py +0 -0
  362. package/tests/test_nunjucks/test_functions.py +0 -94
  363. package/tests/test_nunjucks/test_macros.py +0 -41
  364. package/tests/test_nunjucks/test_set.py +0 -206
  365. package/tests/test_nunjucks/test_spaceless.py +0 -24
  366. package/tests/test_twig/__init__.py +0 -0
  367. package/tests/test_twig/test_comments.py +0 -51
  368. package/tox.ini +0 -48
@@ -1,691 +0,0 @@
1
- """Djlint linter rule tests.
2
-
3
- run::
4
-
5
- pytest tests/test_linter.py --cov=src/djlint --cov-branch \
6
- --cov-report xml:coverage.xml --cov-report term-missing
7
-
8
- # for a single test
9
-
10
- pytest tests/test_linter/test_linter.py::test_random
11
-
12
- Test setup
13
-
14
- (html, (list of codes that should file, plus optional line number))
15
-
16
-
17
- """
18
- # pylint: disable=C0116,C0103,C0302
19
-
20
- from typing import TextIO
21
-
22
- from click.testing import CliRunner
23
-
24
- from src.djlint import main as djlint
25
- from tests.conftest import write_to_file
26
-
27
-
28
- def test_H009(runner: CliRunner, tmp_file: TextIO) -> None:
29
- write_to_file(tmp_file.name, b"<H1>")
30
- result = runner.invoke(djlint, [tmp_file.name])
31
- assert result.exit_code == 1
32
- assert "H009 1:" in result.output
33
-
34
-
35
- def test_H010(runner: CliRunner, tmp_file: TextIO) -> None:
36
- write_to_file(tmp_file.name, b'<img HEIGHT="12">')
37
- result = runner.invoke(djlint, [tmp_file.name])
38
- assert result.exit_code == 1
39
- assert "H010 1:" in result.output
40
-
41
- write_to_file(tmp_file.name, b"<li>ID=username</li>")
42
- result = runner.invoke(djlint, [tmp_file.name])
43
- assert result.exit_code == 0
44
-
45
-
46
- def test_H011(runner: CliRunner, tmp_file: TextIO) -> None:
47
- write_to_file(tmp_file.name, b"<div class=test></div>")
48
- result = runner.invoke(djlint, [tmp_file.name])
49
- assert result.exit_code == 1
50
- assert "H011 1:" in result.output
51
-
52
- # check for no matches inside template tags
53
- write_to_file(tmp_file.name, b" {{ func( id=html_id,) }}")
54
- result = runner.invoke(djlint, [tmp_file.name])
55
- assert result.exit_code == 0
56
- assert "H011 1:" not in result.output
57
-
58
- # check meta tag
59
- write_to_file(
60
- tmp_file.name,
61
- b'<meta name="viewport" content="width=device-width, initial-scale=1">',
62
- )
63
- result = runner.invoke(djlint, [tmp_file.name])
64
- assert "H011 1:" not in result.output
65
-
66
- # check keywords inside template syntax
67
- write_to_file(
68
- tmp_file.name,
69
- b"<a href=\"{{ url_for('connection_bp.one_connection', connection_id=connection.id) }}\">{{ connection }}</a>",
70
- )
71
- result = runner.invoke(djlint, [tmp_file.name])
72
- assert "H011 1:" not in result.output
73
-
74
-
75
- def test_H012(runner: CliRunner, tmp_file: TextIO) -> None:
76
- write_to_file(tmp_file.name, b'<div class = "stuff">')
77
- result = runner.invoke(djlint, [tmp_file.name])
78
- assert result.exit_code == 1
79
- assert "H012 1:" in result.output
80
-
81
- # test for not matching random "=" in text
82
- write_to_file(tmp_file.name, b"<h3>#= title #</h3>")
83
- result = runner.invoke(djlint, [tmp_file.name])
84
- assert result.exit_code == 0
85
- assert "H012 1:" not in result.output
86
-
87
- # test for not matching "=" in template condition
88
- write_to_file(
89
- tmp_file.name,
90
- b"<p>{% if activity.reporting_groups|length <= 0 %}<h3>{% trans 'General' %}</h3>{% endif %}</p>",
91
- )
92
- result = runner.invoke(djlint, [tmp_file.name])
93
- print(result.output)
94
- assert result.exit_code == 0
95
- assert "H012 1:" not in result.output
96
-
97
- # space allowed inside attributes.
98
- write_to_file(
99
- tmp_file.name,
100
- b"""<button x-on:click="myVariable = {{ myObj.id }}" class="text-red-600 hover:text-red-800">
101
- <span x-text="showSource == true ? 'Hide source' : 'Show source'"></span>
102
- <button x-on:click="open = !open" class="flex items-center mt-2">""",
103
- )
104
- result = runner.invoke(djlint, [tmp_file.name])
105
- assert "H012" not in result.output
106
-
107
-
108
- def test_H013(runner: CliRunner, tmp_file: TextIO) -> None:
109
- write_to_file(tmp_file.name, b'<img height="12" width="12"/>')
110
- result = runner.invoke(djlint, [tmp_file.name])
111
- assert result.exit_code == 1
112
- assert "H013 1:" in result.output
113
- print(result.output)
114
- assert "found 1 error" in result.output
115
-
116
-
117
- def test_H014(runner: CliRunner, tmp_file: TextIO) -> None:
118
- write_to_file(tmp_file.name, b"</div>\n\n\n<p>")
119
- result = runner.invoke(djlint, [tmp_file.name])
120
- assert result.exit_code == 1
121
- assert "H014 1:" in result.output
122
-
123
-
124
- def test_H015(runner: CliRunner, tmp_file: TextIO) -> None:
125
- write_to_file(tmp_file.name, b"</h1><p>")
126
- result = runner.invoke(djlint, [tmp_file.name])
127
- assert result.exit_code == 1
128
- assert "H015 1:" in result.output
129
-
130
-
131
- def test_H016(runner: CliRunner, tmp_file: TextIO) -> None:
132
- write_to_file(tmp_file.name, b"<html>\nstuff\n</html>")
133
- result = runner.invoke(djlint, [tmp_file.name])
134
- assert result.exit_code == 1
135
- assert "H016 1:" in result.output
136
-
137
- write_to_file(tmp_file.name, b"<html>\n<title>stuff</title>\n</html>")
138
- result = runner.invoke(djlint, [tmp_file.name])
139
- assert "H016" not in result.output
140
-
141
-
142
- def test_H017(runner: CliRunner, tmp_file: TextIO) -> None:
143
- write_to_file(tmp_file.name, b"<img this >")
144
- result = runner.invoke(djlint, [tmp_file.name])
145
- assert "H017 1:" not in result.output
146
-
147
- write_to_file(tmp_file.name, b"<img this >")
148
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H017"])
149
- assert result.exit_code == 1
150
- assert "H017 1:" in result.output
151
-
152
- write_to_file(tmp_file.name, b"<br>")
153
- result = runner.invoke(djlint, [tmp_file.name])
154
- assert "H017 1:" not in result.output
155
-
156
- write_to_file(tmp_file.name, b"<br>")
157
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H017"])
158
- assert result.exit_code == 1
159
- assert "H017 1:" in result.output
160
-
161
- write_to_file(tmp_file.name, b"<br >")
162
- result = runner.invoke(djlint, [tmp_file.name])
163
- assert "H017 1:" not in result.output
164
-
165
- write_to_file(tmp_file.name, b"<br >")
166
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H017"])
167
- assert result.exit_code == 1
168
- assert "H017 1:" in result.output
169
-
170
- # test colgroup tag
171
- write_to_file(tmp_file.name, b"<colgroup><colgroup asdf></colgroup></colgroup>")
172
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H017"])
173
- print(result.output)
174
- assert "H017 1:" not in result.output
175
-
176
- # test template tags inside html
177
- write_to_file(tmp_file.name, b"<image {{ > }} />")
178
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H017"])
179
- assert "H017" not in result.output
180
-
181
-
182
- def test_DJ018(runner: CliRunner, tmp_file: TextIO) -> None:
183
- write_to_file(
184
- tmp_file.name,
185
- b'<a href="/Collections?handler=RemoveAgreement&id=@a.Id">\n<form action="/Collections"></form></a>',
186
- )
187
-
188
- # test hash urls
189
- write_to_file(
190
- tmp_file.name,
191
- b'<a href="#">\n<form action="#"><a href="#tab">\n<form action="#go"></form></a></form></a>',
192
- )
193
- result = runner.invoke(djlint, [tmp_file.name])
194
- assert result.exit_code == 0
195
-
196
-
197
- def test_H019(runner: CliRunner, tmp_file: TextIO) -> None:
198
- write_to_file(tmp_file.name, b"<a href='javascript:abc()'>asdf</a>")
199
- result = runner.invoke(djlint, [tmp_file.name])
200
- assert result.exit_code == 1
201
- assert "H019 1:" in result.output
202
-
203
- write_to_file(tmp_file.name, b"<form action='javascript:abc()'></form>")
204
- result = runner.invoke(djlint, [tmp_file.name])
205
- assert result.exit_code == 1
206
- assert "H019 1:" in result.output
207
-
208
-
209
- def test_H020(runner: CliRunner, tmp_file: TextIO) -> None:
210
- write_to_file(tmp_file.name, b"<div></div>")
211
- result = runner.invoke(djlint, [tmp_file.name])
212
- assert result.exit_code == 1
213
- assert "H020 1:" in result.output
214
-
215
- write_to_file(tmp_file.name, b"<span>\n </span>")
216
- result = runner.invoke(djlint, [tmp_file.name])
217
- assert result.exit_code == 1
218
- assert "H020 1:" in result.output
219
-
220
- write_to_file(tmp_file.name, b"<td></td>")
221
- result = runner.invoke(djlint, [tmp_file.name])
222
- assert result.exit_code == 0
223
- assert "H020" not in result.output
224
-
225
-
226
- def test_H021(runner: CliRunner, tmp_file: TextIO) -> None:
227
- write_to_file(tmp_file.name, b'<div style="asdf"></div>')
228
- result = runner.invoke(djlint, [tmp_file.name])
229
- assert result.exit_code == 1
230
- assert "H021 1:" in result.output
231
-
232
- write_to_file(
233
- tmp_file.name,
234
- b'<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet" />',
235
- )
236
- result = runner.invoke(djlint, [tmp_file.name])
237
- assert result.exit_code == 0
238
- assert "H021" not in result.output
239
-
240
- write_to_file(
241
- tmp_file.name,
242
- b'<acronym title="Cascading Style Sheets">CSS</acronym>',
243
- )
244
- result = runner.invoke(djlint, [tmp_file.name])
245
- assert result.exit_code == 0
246
- assert "H021" not in result.output
247
-
248
- # allow template syntax inside styles
249
- write_to_file(tmp_file.name, b'<div style="test {%"><div style="test {{">')
250
- result = runner.invoke(djlint, [tmp_file.name])
251
- assert "H021" not in result.output
252
-
253
-
254
- def test_H022(runner: CliRunner, tmp_file: TextIO) -> None:
255
- write_to_file(tmp_file.name, b'<a href="http://">')
256
- result = runner.invoke(djlint, [tmp_file.name])
257
- assert result.exit_code == 1
258
- assert "H022 1:" in result.output
259
-
260
-
261
- def test_H023(runner: CliRunner, tmp_file: TextIO) -> None:
262
- write_to_file(tmp_file.name, b"&mdash;")
263
- result = runner.invoke(djlint, [tmp_file.name])
264
- assert result.exit_code == 1
265
- assert "H023 1:" in result.output
266
-
267
- write_to_file(tmp_file.name, b"&aacute;")
268
- result = runner.invoke(djlint, [tmp_file.name])
269
- assert result.exit_code == 1
270
- assert "H023 1:" in result.output
271
-
272
- write_to_file(tmp_file.name, b"&gt;")
273
- result = runner.invoke(djlint, [tmp_file.name])
274
- assert result.exit_code == 0
275
-
276
- write_to_file(tmp_file.name, b'<a href=" &gt; "></a>')
277
- result = runner.invoke(djlint, [tmp_file.name])
278
- assert result.exit_code == 0
279
-
280
- write_to_file(tmp_file.name, b'<a href=" foo & bar; "></a>')
281
- result = runner.invoke(djlint, [tmp_file.name])
282
- assert result.exit_code == 0
283
-
284
- write_to_file(tmp_file.name, b'<a href=" &aacute; "></a>')
285
- result = runner.invoke(djlint, [tmp_file.name])
286
- assert result.exit_code == 1
287
- assert "H023 1:" in result.output
288
-
289
- write_to_file(tmp_file.name, b"&#63;")
290
- result = runner.invoke(djlint, [tmp_file.name])
291
- assert result.exit_code == 1
292
- assert "H023 1:" in result.output
293
-
294
- write_to_file(tmp_file.name, b"&#x3F;")
295
- result = runner.invoke(djlint, [tmp_file.name])
296
- assert result.exit_code == 1
297
- assert "H023 1:" in result.output
298
-
299
- write_to_file(tmp_file.name, b'<a href=" &#63; "></a>')
300
- result = runner.invoke(djlint, [tmp_file.name])
301
- assert result.exit_code == 1
302
- assert "H023 1:" in result.output
303
-
304
-
305
- def test_H024(runner: CliRunner, tmp_file: TextIO) -> None:
306
- write_to_file(tmp_file.name, b'<script type="hare">')
307
- result = runner.invoke(djlint, [tmp_file.name])
308
- assert result.exit_code == 1
309
- assert "H024" not in result.output
310
-
311
- write_to_file(tmp_file.name, b'<script type="text/javascript">')
312
- result = runner.invoke(djlint, [tmp_file.name])
313
- assert result.exit_code == 1
314
- assert "H024" in result.output
315
-
316
- write_to_file(tmp_file.name, b'<script type="text/css">')
317
- result = runner.invoke(djlint, [tmp_file.name])
318
- assert result.exit_code == 1
319
- assert "H024" in result.output
320
-
321
-
322
- def test_H025(runner: CliRunner, tmp_file: TextIO) -> None:
323
- write_to_file(tmp_file.name, b"<div>")
324
- result = runner.invoke(djlint, [tmp_file.name])
325
- assert result.exit_code == 1
326
- assert "H025 1:" in result.output
327
-
328
- write_to_file(tmp_file.name, b"<!-- comment -->")
329
- result = runner.invoke(djlint, [tmp_file.name])
330
- assert result.exit_code == 0
331
- assert "H025" not in result.output
332
-
333
- write_to_file(tmp_file.name, b"<!DOCTYPE html>")
334
- result = runner.invoke(djlint, [tmp_file.name])
335
- assert result.exit_code == 0
336
- assert "H025" not in result.output
337
-
338
- write_to_file(tmp_file.name, b"<link {% url_for('something') %} />")
339
- result = runner.invoke(djlint, [tmp_file.name])
340
- assert result.exit_code == 0
341
- assert "H025" not in result.output
342
-
343
- write_to_file(tmp_file.name, b"<br>")
344
- result = runner.invoke(djlint, [tmp_file.name])
345
- assert "H025" not in result.output
346
-
347
- write_to_file(tmp_file.name, b"<alpha />")
348
- result = runner.invoke(djlint, [tmp_file.name])
349
- assert "H025" not in result.output
350
-
351
- write_to_file(tmp_file.name, b"<alpha>\n</alpha>")
352
- result = runner.invoke(djlint, [tmp_file.name])
353
- assert "H025" not in result.output
354
-
355
- write_to_file(
356
- tmp_file.name,
357
- b'<script src="{% static \'notifications/notify.js\' %}" type="text/javascript"></script>',
358
- )
359
- result = runner.invoke(djlint, [tmp_file.name])
360
- assert "H025" not in result.output
361
-
362
- write_to_file(
363
- tmp_file.name,
364
- b'<script src="{% static "folder/foo.js" %}?version={% some_version %}"></script>',
365
- )
366
- result = runner.invoke(djlint, [tmp_file.name])
367
- assert "H025" not in result.output
368
-
369
- write_to_file(
370
- tmp_file.name,
371
- b"<script />",
372
- )
373
- result = runner.invoke(djlint, [tmp_file.name])
374
- assert "H025" not in result.output
375
-
376
- write_to_file(tmp_file.name, b"<tr ><td>Foo</td></tr>")
377
- result = runner.invoke(djlint, [tmp_file.name])
378
- assert "H025" not in result.output
379
-
380
- write_to_file(tmp_file.name, b"<p>Foo\n<p>Foo</p>")
381
- result = runner.invoke(djlint, [tmp_file.name])
382
- assert "H025 1:" in result.output
383
- assert "H025 2:" not in result.output
384
-
385
- # test tags inside attributes
386
- write_to_file(tmp_file.name, b'<span title="<p>Bar</p>">Foo</span>')
387
- result = runner.invoke(djlint, [tmp_file.name])
388
- assert "H025" not in result.output
389
-
390
- write_to_file(tmp_file.name, b"<col>")
391
- result = runner.invoke(djlint, [tmp_file.name])
392
- assert "H025" not in result.output
393
-
394
- write_to_file(tmp_file.name, b"<col />")
395
- result = runner.invoke(djlint, [tmp_file.name])
396
- assert "H025" not in result.output
397
-
398
- # fix issue #164
399
- write_to_file(
400
- tmp_file.name,
401
- b"""<th {{ attrs }}>
402
- <a href="{% url %}">{{ content }}</a>
403
- </th>""",
404
- )
405
- result = runner.invoke(djlint, [tmp_file.name])
406
- assert "H025" not in result.output
407
-
408
- # fix issue #169
409
- write_to_file(
410
- tmp_file.name,
411
- b"""<li{% if is_active %} class="active" {% endif %}>
412
- some content
413
- </li>""",
414
- )
415
- result = runner.invoke(djlint, [tmp_file.name])
416
- assert "H025" not in result.output
417
-
418
- # test {# #} inside tag
419
- write_to_file(tmp_file.name, b'<div id="example" {# for #}></div>')
420
- result = runner.invoke(djlint, [tmp_file.name])
421
- assert "H025" not in result.output
422
-
423
- # check closing tag inside a comment
424
- write_to_file(
425
- tmp_file.name,
426
- b'<input {# value="{{ driverId|default(\' asdf \') }}" /> #} value="this">',
427
- )
428
- result = runner.invoke(djlint, [tmp_file.name])
429
- assert "H025" not in result.output
430
-
431
- # issue #447
432
- write_to_file(
433
- tmp_file.name,
434
- b"""<button title="{% trans "text with ONE single ' quote" %}">
435
- </button>""",
436
- )
437
- assert "H025" not in result.output
438
-
439
-
440
- def test_H026(runner: CliRunner, tmp_file: TextIO) -> None:
441
- write_to_file(tmp_file.name, b'<asdf id="" >')
442
- result = runner.invoke(djlint, [tmp_file.name])
443
- assert result.exit_code == 1
444
- assert "H026" in result.output
445
-
446
- write_to_file(tmp_file.name, b"<asdf id >")
447
- result = runner.invoke(djlint, [tmp_file.name])
448
- assert result.exit_code == 1
449
- assert "H026" in result.output
450
-
451
- write_to_file(tmp_file.name, b'<asdf class="" >')
452
- result = runner.invoke(djlint, [tmp_file.name])
453
- assert result.exit_code == 1
454
- assert "H026" in result.output
455
-
456
- write_to_file(tmp_file.name, b'<asdf {% class="" %}></asdf>')
457
- result = runner.invoke(djlint, [tmp_file.name])
458
- assert result.exit_code == 0
459
- assert "H026" not in result.output
460
-
461
- write_to_file(tmp_file.name, b"<div x-id-y><div id-y><div x-id>")
462
- result = runner.invoke(djlint, [tmp_file.name])
463
- assert "H026" not in result.output
464
-
465
-
466
- def test_T027(runner: CliRunner, tmp_file: TextIO) -> None:
467
- write_to_file(tmp_file.name, b"<a href=\"{{- blah 'asdf' }}\">")
468
- result = runner.invoke(djlint, [tmp_file.name])
469
- assert "T028" not in result.output
470
-
471
-
472
- def test_H029(runner: CliRunner, tmp_file: TextIO) -> None:
473
- write_to_file(tmp_file.name, b'<forM method="Post">')
474
- result = runner.invoke(djlint, [tmp_file.name])
475
- assert result.exit_code == 1
476
- assert "H029" in result.output
477
-
478
- write_to_file(tmp_file.name, b'<forM method="post">')
479
- result = runner.invoke(djlint, [tmp_file.name])
480
- assert "H029" not in result.output
481
-
482
- write_to_file(tmp_file.name, b'<a method="post">')
483
- result = runner.invoke(djlint, [tmp_file.name])
484
- assert "H029" not in result.output
485
-
486
-
487
- def test_H030(runner: CliRunner, tmp_file: TextIO) -> None:
488
- write_to_file(tmp_file.name, b"<html>\nstuff\n</html>")
489
- result = runner.invoke(djlint, [tmp_file.name])
490
- assert result.exit_code == 1
491
- assert "H030 1:" in result.output
492
-
493
- write_to_file(
494
- tmp_file.name, b'<html>\n<meta name="description" content="nice"/>\n</html>'
495
- )
496
- result = runner.invoke(djlint, [tmp_file.name])
497
- assert "H030" not in result.output
498
-
499
-
500
- def test_H031(runner: CliRunner, tmp_file: TextIO) -> None:
501
- write_to_file(tmp_file.name, b"<html>\nstuff\n</html>")
502
- result = runner.invoke(djlint, [tmp_file.name])
503
- assert result.exit_code == 1
504
- assert "H031 1:" in result.output
505
-
506
- write_to_file(
507
- tmp_file.name, b'<html>\n<meta name="keywords" content="nice"/>\n</html>'
508
- )
509
- result = runner.invoke(djlint, [tmp_file.name])
510
- assert "H031" not in result.output
511
-
512
-
513
- def test_H033(runner: CliRunner, tmp_file: TextIO) -> None:
514
- write_to_file(
515
- tmp_file.name, b"<form action=\" {% url 'foo:bar' %} \" ...>...</form>"
516
- )
517
- result = runner.invoke(djlint, [tmp_file.name])
518
- assert "H033" in result.output
519
-
520
- write_to_file(
521
- tmp_file.name,
522
- b"<form action=\" {% url 'foo:bar' %} {{ asdf}} \" ...>...</form>",
523
- )
524
- result = runner.invoke(djlint, [tmp_file.name])
525
- assert "H033" in result.output
526
-
527
- write_to_file(
528
- tmp_file.name, b"<form action=\" {% url 'foo:bar' %} \" ...>...</form>"
529
- )
530
- result = runner.invoke(djlint, [tmp_file.name])
531
- assert "H033" in result.output
532
-
533
- write_to_file(tmp_file.name, b'<form action=" {{ asdf}} " ...>...</form>')
534
- result = runner.invoke(djlint, [tmp_file.name])
535
- assert "H033" in result.output
536
-
537
- write_to_file(
538
- tmp_file.name, b"<form action=\"{% url 'foo:bar' %} \" ...>...</form>"
539
- )
540
- result = runner.invoke(djlint, [tmp_file.name])
541
- assert "H033" in result.output
542
-
543
- write_to_file(tmp_file.name, b'<form action="asdf " ...>...</form>')
544
- result = runner.invoke(djlint, [tmp_file.name])
545
- assert "H033" in result.output
546
-
547
- write_to_file(tmp_file.name, b'<form action=" asdf " ...>...</form>')
548
- result = runner.invoke(djlint, [tmp_file.name])
549
- assert "H033" in result.output
550
-
551
-
552
- def test_H035(runner: CliRunner, tmp_file: TextIO) -> None:
553
- write_to_file(tmp_file.name, b"<meta this >")
554
- result = runner.invoke(djlint, [tmp_file.name])
555
- assert result.exit_code == 0
556
- assert "H035 1:" not in result.output
557
-
558
- write_to_file(tmp_file.name, b"<meta this >")
559
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H035"])
560
- assert result.exit_code == 1
561
- assert "H035 1:" in result.output
562
-
563
- write_to_file(tmp_file.name, b"<meta>")
564
- result = runner.invoke(djlint, [tmp_file.name])
565
- assert result.exit_code == 0
566
- assert "H035 1:" not in result.output
567
-
568
- write_to_file(tmp_file.name, b"<meta>")
569
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H035"])
570
- assert result.exit_code == 1
571
- assert "H035 1:" in result.output
572
-
573
-
574
- def test_H036(runner: CliRunner, tmp_file: TextIO) -> None:
575
- write_to_file(tmp_file.name, b"<br><br ><br />")
576
- result = runner.invoke(djlint, [tmp_file.name])
577
- assert "H036" not in result.output
578
-
579
- write_to_file(tmp_file.name, b"<br>")
580
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H036"])
581
- assert result.exit_code == 1
582
- assert "H036" in result.output
583
-
584
- write_to_file(tmp_file.name, b"<br />")
585
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H036"])
586
- assert result.exit_code == 1
587
- assert "H036" in result.output
588
-
589
- write_to_file(tmp_file.name, b"<br/>")
590
- result = runner.invoke(djlint, [tmp_file.name, "--include", "H036"])
591
- assert result.exit_code == 1
592
- assert "H036" in result.output
593
-
594
-
595
- def test_rules_not_matched_in_ignored_block(
596
- runner: CliRunner, tmp_file: TextIO
597
- ) -> None:
598
- write_to_file(tmp_file.name, b"<script><div class=test></script>")
599
- result = runner.invoke(djlint, [tmp_file.name])
600
-
601
- assert result.exit_code == 0
602
- assert "H011 1:" not in result.output
603
-
604
-
605
- def test_output_for_no_linebreaks(runner: CliRunner, tmp_file: TextIO) -> None:
606
- write_to_file(tmp_file.name, b"<a\n class='asdf'></a>")
607
- result = runner.invoke(djlint, [tmp_file.name])
608
- assert result.exit_code == 1
609
- assert "<a\n" not in result.output
610
-
611
- write_to_file(tmp_file.name, b"<h1>asdf</h1>\n <h2>asdf</h2>")
612
- result = runner.invoke(djlint, [tmp_file.name])
613
- assert result.exit_code == 1
614
-
615
- assert "</h1>\n" not in result.output
616
-
617
-
618
- def test_output_order(runner: CliRunner, tmp_file: TextIO) -> None:
619
- write_to_file(tmp_file.name, b"<h1>asdf</h2>\n <h3>asdf</h4>")
620
- result = runner.invoke(djlint, [tmp_file.name])
621
- assert result.exit_code == 1
622
-
623
- assert (
624
- """H025 1:0 Tag seems to be an orphan. <h1>
625
- H015 1:8 Follow h tags with a line break. </h2> <h3
626
- H025 1:8 Tag seems to be an orphan. </h2>
627
- H025 2:4 Tag seems to be an orphan. <h3>
628
- H025 2:12 Tag seems to be an orphan. </h4>"""
629
- in result.output
630
- )
631
-
632
-
633
- def test_ignoring_rules(runner: CliRunner, tmp_file: TextIO) -> None:
634
- write_to_file(
635
- tmp_file.name,
636
- b"""{# djlint:off H025,H026 #}
637
- <p>
638
- {# djlint:on #}
639
-
640
- <!-- djlint:off H025-->
641
- <p>
642
- <!-- djlint:on -->
643
-
644
- {% comment %} djlint:off H025 {% endcomment %}
645
- <p>
646
- {% comment %} djlint:on {% endcomment %}
647
-
648
- {{!-- djlint:off H025 --}}
649
- <p style="color:red">
650
- {{!-- djlint:on --}}
651
-
652
- {{ /* djlint:off H025 */ }}
653
- <p>
654
- {{ /* djlint:on */ }}
655
-
656
- """,
657
- )
658
- result = runner.invoke(djlint, [tmp_file.name])
659
- assert "H025" not in result.output
660
- assert "H021" in result.output # other codes should still show
661
-
662
- # using tabs
663
- write_to_file(
664
- tmp_file.name,
665
- b"""<div>
666
-
667
- \t\t{# djlint:off H006 #}
668
-
669
- \t\t<img src="{{ variable }}.webp" alt="stuff" />
670
-
671
- \t\t{# djlint:on #}
672
-
673
- </div>
674
- """,
675
- )
676
- result = runner.invoke(djlint, [tmp_file.name])
677
- assert "H006" not in result.output
678
-
679
-
680
- def test_statistics_empty(runner: CliRunner, tmp_file: TextIO) -> None:
681
- write_to_file(tmp_file.name, b"")
682
- result = runner.invoke(djlint, [tmp_file.name, "--statistics"])
683
-
684
- assert result.exit_code == 0
685
-
686
-
687
- def test_statistics_with_results(runner: CliRunner, tmp_file: TextIO) -> None:
688
- write_to_file(tmp_file.name, b"<div>")
689
- result = runner.invoke(djlint, [tmp_file.name, "--statistics"])
690
-
691
- assert result.exit_code == 1