32 Commits
Author SHA1 Message Date
Andrey Sitnik 69d5b399fd Fix Maximum call stack size exceeded error 2026-07-11 19:06:38 +00:00
Sarath FrancisandGitHub aeeb3006c0 Fix Node#rangeBy() ignoring index 0 (#2091)
When calling Node#rangeBy() (and therefore Node#error() and
Node#warn()) with index 0, the resulting range covered the whole node
instead of a single character at offset 0.

The end-of-range branch used a truthy check on opts.index, so an index
of 0 fell through and left the end position at the node's end. This is
the same off-by-zero issue that was previously fixed for endIndex; the
index branches were missed. Switch both index checks to a numeric type
check, matching the existing endIndex handling.

index 0 now produces a single-character range, consistent with every
other index value.
2026-06-27 15:48:04 +02:00
74d18036e9 fix(node): always include offset in positionBy() like rangeBy() (#2099)
positionBy()'s default branch returned this.source.start verbatim, so for
custom syntaxes whose source.start lacks an offset (e.g. postcss-html) it
returned a position without offset, violating the Position type which
declares offset as required. rangeBy()/positionInside() were normalized to
always compute offset via sourceOffset() (#2033, issue #2029) but
positionBy() was left behind. Mirror the rangeBy() pattern.

Co-authored-by: oss69U-prep <prep@local>

Co-authored-by: Hanzo Dev <[email protected]>
2026-06-27 15:31:28 +02:00
Andrey Sitnik 85bf516d71 Move to oxfmt 2026-04-07 16:07:54 +00:00
b38a1162f1 Fix missing offset in Node#positionInside, Node#positionBy and Node#rangeBy (#2033)
* Fix `opts` argument cannot be omitted

* Assign default values to `opts` just in case

- The `opts` argument to `Node#error` is currently omissible, but we'll assign a default value just in case.

* Add test cases

* Add test cases for `Node#rangeBy({start, end})`

* Add test cases for offset

* Fix missing offset in `Node#positionInside`, `Node#positionBy` and `Node#rangeBy`

* Fix conflict resolution mistakes

---------

Co-authored-by: Andrey Sitnik <[email protected]>
2025-03-22 18:07:03 +01:00
mizdraandGitHub a9a4e8849a Fix opts argument of Node#rangeBy() and Node#positionBy() cannot be omitted (#2031)
* Fix `opts` argument cannot be omitted

* Assign default values to `opts` just in case

- The `opts` argument to `Node#error` is currently omissible, but we'll assign a default value just in case.

* Add test cases
2025-03-22 17:13:46 +01:00
Andrey Sitnik d3d4d735df Update ESLint config 2025-02-19 13:43:47 +00:00
Andrey Sitnik 9571f4f00d Fix 80 columns limit 2025-01-13 15:13:59 +00:00
2f3c759a4b Add Input#document (#1996)
* Add `Input#document`

* Update lib/postcss.d.ts

Co-authored-by: Andrey Sitnik <[email protected]>

* apply suggestion from code review

---------

Co-authored-by: Andrey Sitnik <[email protected]>
2025-01-13 16:12:42 +01:00
Romain MenkeandGitHub 97e48f613e Fix position calculations when offset is missing (#1983) 2024-11-11 20:55:58 +01:00
Romain MenkeandGitHub b3f6e2737f fix inconsistent position calculations (#1980) 2024-11-10 22:13:31 +01:00
Andrey Sitnik 89b7f7ac78 Update dependencies and code style 2023-07-06 13:38:48 +02:00
Andrey Kim afe45db6e8 Merge branch 'main' of https://github.com/postcss/postcss into main 2021-11-17 23:55:23 +03:00
Adaline Valentina Simonian 45097948ff feat: Support ranges for errors and warnings
Allows for better diagnostics in linters, language servers, and plugins.
2021-11-16 17:15:01 -08:00
Andrey Kim cd9ec4f200 Move from Jest to uvu 2021-11-15 11:25:34 +03:00
Andrey Sitnik 6176e9ec7a Update dependencies 2021-10-20 17:11:51 +02:00
Andrey SitnikandGitHub 2c6777648a Merge pull request #1582 from hudochenkov/add-document-node-1498
Add Document node and related API (#1498)
2021-05-18 20:46:25 -04:00
Aleks Hudochenkov bd17ae8ec9 Remove Node#document() 2021-05-18 02:01:20 +02:00
Jonathan NealandAndrey Sitnik 6ac398f726 fix: tests
- Fixes the `important` prop of DeclarationProps, which should be optional.
- Adds a test for the `assign` method.
2021-05-17 08:50:29 -04:00
Aleks Hudochenkov 430ee0d902 Add Document node and related API (#1498) 2021-05-16 20:15:56 +02:00
Andrey Sitnik 843ab11b6e Add Prettier 2021-03-11 19:11:37 -05:00
Andrey Sitnik 839e2c0504 Update ESLint config 2021-03-09 17:02:16 -05:00
Niklas Mischkulnig 35ea5fce49 Fixup tests 2021-01-07 12:20:24 +01:00
Andrey Sitnik 6208bd61b6 Clean up tests 2020-12-29 14:35:30 -05:00
Niklas Mischkulnig e22b4711d4 Fix test/don't remove source.end 2020-12-09 12:31:53 +01:00
Andrey Sitnik 0d49399d5d Add Once and OnceExit events 2020-09-25 15:56:19 -04:00
Andrey Sitnik 34a75da74b Remove old test 2020-09-02 22:28:20 -04:00
Andrey Sitnik a539418f45 Use class names in visitor hooks 2020-08-07 12:04:54 -07:00
Andrey Sitnik 15a248c06d Pass postcss & Result to second argument for visitors 2020-08-07 11:46:58 -07:00
Andrey Sitnik 6fbb0d5434 Change plugin API 2020-08-06 16:00:46 -07:00
Andrey Sitnik 389b7b00a9 Export public classes from main entry 2020-07-12 16:31:09 -07:00
Andrey Sitnik 7dc34d61a8 Move Node test to TS 2020-07-10 20:21:53 -07:00