Skip to content

Commit bc3c341

Browse files
committed
Update linter
1 parent b2be58a commit bc3c341

13 files changed

+524
-574
lines changed

lib/container.d.ts

+32-32
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
125125
every(
126126
condition: (node: Child, index: number, nodes: Child[]) => boolean
127127
): boolean
128-
/**
129-
* The container’s first child.
130-
*
131-
* ```js
132-
* rule.first === rules.nodes[0]
133-
* ```
134-
*/
135-
get first(): Child | undefined
136-
137128
/**
138129
* Returns a `child`’s index within the `Container#nodes` array.
139130
*
@@ -145,6 +136,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
145136
* @return Child index.
146137
*/
147138
index(child: Child | number): number
139+
148140
/**
149141
* Insert new node after old node within the container.
150142
*
@@ -156,24 +148,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
156148
oldNode: Child | number,
157149
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
158150
): this
159-
160-
/**
161-
* Traverses the container’s descendant nodes, calling callback
162-
* for each comment node.
163-
*
164-
* Like `Container#each`, this method is safe
165-
* to use if you are mutating arrays during iteration.
166-
*
167-
* ```js
168-
* root.walkComments(comment => {
169-
* comment.remove()
170-
* })
171-
* ```
172-
*
173-
* @param callback Iterator receives each node and index.
174-
* @return Returns `false` if iteration was broke.
175-
*/
176-
177151
/**
178152
* Insert new node before old node within the container.
179153
*
@@ -189,14 +163,23 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
189163
oldNode: Child | number,
190164
newNode: Child | Child[] | ChildProps | ChildProps[] | string | string[]
191165
): this
166+
192167
/**
193-
* The container’s last child.
168+
* Traverses the container’s descendant nodes, calling callback
169+
* for each comment node.
170+
*
171+
* Like `Container#each`, this method is safe
172+
* to use if you are mutating arrays during iteration.
194173
*
195174
* ```js
196-
* rule.last === rule.nodes[rule.nodes.length - 1]
175+
* root.walkComments(comment => {
176+
* comment.remove()
177+
* })
197178
* ```
179+
*
180+
* @param callback Iterator receives each node and index.
181+
* @return Returns `false` if iteration was broke.
198182
*/
199-
get last(): Child | undefined
200183

201184
/**
202185
* Inserts new nodes to the start of the container.
@@ -221,7 +204,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
221204
prepend(
222205
...nodes: (ChildProps | ChildProps[] | Node | Node[] | string | string[])[]
223206
): this
224-
225207
/**
226208
* Add child to the end of the node.
227209
*
@@ -334,6 +316,7 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
334316
walk(
335317
callback: (node: ChildNode, index: number) => false | void
336318
): false | undefined
319+
337320
/**
338321
* Traverses the container’s descendant nodes, calling callback
339322
* for each at-rule node.
@@ -371,7 +354,6 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
371354
walkAtRules(
372355
callback: (atRule: AtRule, index: number) => false | void
373356
): false | undefined
374-
375357
walkComments(
376358
callback: (comment: Comment, indexed: number) => false | void
377359
): false | undefined
@@ -413,9 +395,11 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
413395
propFilter: RegExp | string,
414396
callback: (decl: Declaration, index: number) => false | void
415397
): false | undefined
398+
416399
walkDecls(
417400
callback: (decl: Declaration, index: number) => false | void
418401
): false | undefined
402+
419403
/**
420404
* Traverses the container’s descendant nodes, calling callback
421405
* for each rule node.
@@ -445,6 +429,22 @@ declare abstract class Container_<Child extends Node = ChildNode> extends Node {
445429
walkRules(
446430
callback: (rule: Rule, index: number) => false | void
447431
): false | undefined
432+
/**
433+
* The container’s first child.
434+
*
435+
* ```js
436+
* rule.first === rules.nodes[0]
437+
* ```
438+
*/
439+
get first(): Child | undefined
440+
/**
441+
* The container’s last child.
442+
*
443+
* ```js
444+
* rule.last === rule.nodes[rule.nodes.length - 1]
445+
* ```
446+
*/
447+
get last(): Child | undefined
448448
}
449449

450450
declare class Container<Child extends Node = ChildNode> extends Container_<Child> {}

lib/container.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,6 @@ class Container extends Node {
6464
return this.nodes.every(condition)
6565
}
6666

67-
get first() {
68-
if (!this.proxyOf.nodes) return undefined
69-
return this.proxyOf.nodes[0]
70-
}
71-
7267
getIterator() {
7368
if (!this.lastEach) this.lastEach = 0
7469
if (!this.indexes) this.indexes = {}
@@ -175,11 +170,6 @@ class Container extends Node {
175170
return this
176171
}
177172

178-
get last() {
179-
if (!this.proxyOf.nodes) return undefined
180-
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
181-
}
182-
183173
normalize(nodes, sample) {
184174
if (typeof nodes === 'string') {
185175
nodes = cleanSource(parse(nodes).nodes)
@@ -393,6 +383,16 @@ class Container extends Node {
393383
}
394384
})
395385
}
386+
387+
get first() {
388+
if (!this.proxyOf.nodes) return undefined
389+
return this.proxyOf.nodes[0]
390+
}
391+
392+
get last() {
393+
if (!this.proxyOf.nodes) return undefined
394+
return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
395+
}
396396
}
397397

398398
Container.registerParse = dependant => {

lib/input.d.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -143,19 +143,6 @@ declare class Input_ {
143143
opts?: { plugin?: CssSyntaxError['plugin'] }
144144
): CssSyntaxError
145145

146-
/**
147-
* The CSS source identifier. Contains `Input#file` if the user
148-
* set the `from` option, or `Input#id` if they did not.
149-
*
150-
* ```js
151-
* const root = postcss.parse(css, { from: 'a.css' })
152-
* root.source.input.from //=> "/home/ai/a.css"
153-
*
154-
* const root = postcss.parse(css)
155-
* root.source.input.from //=> "<input css 1>"
156-
* ```
157-
*/
158-
get from(): string
159146
/**
160147
* Converts source offset to line and column.
161148
*
@@ -187,6 +174,19 @@ declare class Input_ {
187174
endLine?: number,
188175
endColumn?: number
189176
): false | Input.FilePosition
177+
/**
178+
* The CSS source identifier. Contains `Input#file` if the user
179+
* set the `from` option, or `Input#id` if they did not.
180+
*
181+
* ```js
182+
* const root = postcss.parse(css, { from: 'a.css' })
183+
* root.source.input.from //=> "/home/ai/a.css"
184+
*
185+
* const root = postcss.parse(css)
186+
* root.source.input.from //=> "<input css 1>"
187+
* ```
188+
*/
189+
get from(): string
190190
}
191191

192192
declare class Input extends Input_ {}

lib/input.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ class Input {
124124
return result
125125
}
126126

127-
get from() {
128-
return this.file || this.id
129-
}
130-
131127
fromOffset(offset) {
132128
let lastLine, lineToIndex
133129
if (!this[fromOffsetCache]) {
@@ -238,6 +234,10 @@ class Input {
238234
}
239235
return json
240236
}
237+
238+
get from() {
239+
return this.file || this.id
240+
}
241241
}
242242

243243
module.exports = Input

lib/lazy-result.d.ts

+26-26
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,32 @@ declare class LazyResult_<RootNode = Document | Root>
8181
*/
8282
async(): Promise<Result<RootNode>>
8383

84+
/**
85+
* Run plugin in sync way and return `Result`.
86+
*
87+
* @return Result with output content.
88+
*/
89+
sync(): Result<RootNode>
90+
91+
/**
92+
* Alias for the `LazyResult#css` property.
93+
*
94+
* ```js
95+
* lazy + '' === lazy.css
96+
* ```
97+
*
98+
* @return Output CSS.
99+
*/
100+
toString(): string
101+
102+
/**
103+
* Processes input CSS through synchronous plugins
104+
* and calls `Result#warnings`.
105+
*
106+
* @return Warnings from plugins.
107+
*/
108+
warnings(): Warning[]
109+
84110
/**
85111
* An alias for the `css` property. Use it with syntaxes
86112
* that generate non-CSS output.
@@ -155,32 +181,6 @@ declare class LazyResult_<RootNode = Document | Root>
155181
* Required to implement the Promise interface.
156182
*/
157183
get [Symbol.toStringTag](): string
158-
159-
/**
160-
* Run plugin in sync way and return `Result`.
161-
*
162-
* @return Result with output content.
163-
*/
164-
sync(): Result<RootNode>
165-
166-
/**
167-
* Alias for the `LazyResult#css` property.
168-
*
169-
* ```js
170-
* lazy + '' === lazy.css
171-
* ```
172-
*
173-
* @return Output CSS.
174-
*/
175-
toString(): string
176-
177-
/**
178-
* Processes input CSS through synchronous plugins
179-
* and calls `Result#warnings`.
180-
*
181-
* @return Warnings from plugins.
182-
*/
183-
warnings(): Warning[]
184184
}
185185

186186
declare class LazyResult<

0 commit comments

Comments
 (0)