stylehacks 5.0.1 → 5.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.
- package/README.md +5 -8
- package/package.json +8 -11
- package/src/dictionary/browsers.js +9 -0
- package/src/dictionary/identifiers.js +7 -0
- package/src/dictionary/postcss.js +6 -0
- package/src/dictionary/tags.js +5 -0
- package/src/exists.js +13 -0
- package/src/index.js +60 -0
- package/src/isMixin.js +15 -0
- package/src/plugin.js +108 -0
- package/src/plugins/bodyEmpty.js +49 -0
- package/src/plugins/htmlCombinatorCommentBody.js +54 -0
- package/src/plugins/htmlFirstChild.js +50 -0
- package/src/plugins/important.js +25 -0
- package/src/plugins/index.js +28 -0
- package/src/plugins/leadingStar.js +55 -0
- package/src/plugins/leadingUnderscore.js +51 -0
- package/src/plugins/mediaSlash0.js +26 -0
- package/src/plugins/mediaSlash0Slash9.js +27 -0
- package/src/plugins/mediaSlash9.js +27 -0
- package/src/plugins/slash9.js +26 -0
- package/src/plugins/starHtml.js +50 -0
- package/src/plugins/trailingSlashComma.js +36 -0
- package/types/dictionary/browsers.d.ts +6 -0
- package/types/dictionary/identifiers.d.ts +4 -0
- package/types/dictionary/postcss.d.ts +3 -0
- package/types/dictionary/tags.d.ts +2 -0
- package/types/exists.d.ts +2 -0
- package/types/index.d.ts +16 -0
- package/types/isMixin.d.ts +2 -0
- package/types/plugin.d.ts +60 -0
- package/types/plugins/bodyEmpty.d.ts +17 -0
- package/types/plugins/htmlCombinatorCommentBody.d.ts +16 -0
- package/types/plugins/htmlFirstChild.d.ts +17 -0
- package/types/plugins/important.d.ts +11 -0
- package/types/plugins/index.d.ts +365 -0
- package/types/plugins/leadingStar.d.ts +11 -0
- package/types/plugins/leadingUnderscore.d.ts +11 -0
- package/types/plugins/mediaSlash0.d.ts +11 -0
- package/types/plugins/mediaSlash0Slash9.d.ts +11 -0
- package/types/plugins/mediaSlash9.d.ts +11 -0
- package/types/plugins/slash9.d.ts +11 -0
- package/types/plugins/starHtml.d.ts +17 -0
- package/types/plugins/trailingSlashComma.d.ts +11 -0
- package/CHANGELOG.md +0 -81
- package/dist/dictionary/browsers.js +0 -18
- package/dist/dictionary/identifiers.js +0 -14
- package/dist/dictionary/postcss.js +0 -12
- package/dist/dictionary/tags.js +0 -10
- package/dist/exists.js +0 -13
- package/dist/index.js +0 -69
- package/dist/isMixin.js +0 -20
- package/dist/plugin.js +0 -71
- package/dist/plugins/bodyEmpty.js +0 -48
- package/dist/plugins/htmlCombinatorCommentBody.js +0 -50
- package/dist/plugins/htmlFirstChild.js +0 -48
- package/dist/plugins/important.js +0 -29
- package/dist/plugins/index.js +0 -36
- package/dist/plugins/leadingStar.js +0 -67
- package/dist/plugins/leadingUnderscore.js +0 -49
- package/dist/plugins/mediaSlash0.js +0 -30
- package/dist/plugins/mediaSlash0Slash9.js +0 -30
- package/dist/plugins/mediaSlash9.js +0 -30
- package/dist/plugins/slash9.js +0 -30
- package/dist/plugins/starHtml.js +0 -48
- package/dist/plugins/trailingSlashComma.js +0 -39
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const BasePlugin = require('../plugin');
|
|
3
|
+
const { IE_5_5, IE_6, IE_7 } = require('../dictionary/browsers');
|
|
4
|
+
const { MEDIA_QUERY } = require('../dictionary/identifiers');
|
|
5
|
+
const { ATRULE } = require('../dictionary/postcss');
|
|
6
|
+
|
|
7
|
+
module.exports = class MediaSlash9 extends BasePlugin {
|
|
8
|
+
/** @param {import('postcss').Result} result */
|
|
9
|
+
constructor(result) {
|
|
10
|
+
super([IE_5_5, IE_6, IE_7], [ATRULE], result);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {import('postcss').AtRule} rule
|
|
15
|
+
* @return {void}
|
|
16
|
+
*/
|
|
17
|
+
detect(rule) {
|
|
18
|
+
const params = rule.params.trim();
|
|
19
|
+
|
|
20
|
+
if (params.toLowerCase() === 'screen\\9') {
|
|
21
|
+
this.push(rule, {
|
|
22
|
+
identifier: MEDIA_QUERY,
|
|
23
|
+
hack: params,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const BasePlugin = require('../plugin.js');
|
|
3
|
+
const { IE_6, IE_7, IE_8 } = require('../dictionary/browsers');
|
|
4
|
+
const { VALUE } = require('../dictionary/identifiers');
|
|
5
|
+
const { DECL } = require('../dictionary/postcss');
|
|
6
|
+
|
|
7
|
+
module.exports = class Slash9 extends BasePlugin {
|
|
8
|
+
/** @param {import('postcss').Result=} result */
|
|
9
|
+
constructor(result) {
|
|
10
|
+
super([IE_6, IE_7, IE_8], [DECL], result);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @param {import('postcss').Declaration} decl
|
|
15
|
+
* @return {void}
|
|
16
|
+
*/
|
|
17
|
+
detect(decl) {
|
|
18
|
+
let v = decl.value;
|
|
19
|
+
if (v && v.length > 2 && v.indexOf('\\9') === v.length - 2) {
|
|
20
|
+
this.push(decl, {
|
|
21
|
+
identifier: VALUE,
|
|
22
|
+
hack: v,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const parser = require('postcss-selector-parser');
|
|
3
|
+
const exists = require('../exists');
|
|
4
|
+
const isMixin = require('../isMixin');
|
|
5
|
+
const BasePlugin = require('../plugin');
|
|
6
|
+
const { IE_5_5, IE_6 } = require('../dictionary/browsers');
|
|
7
|
+
const { SELECTOR } = require('../dictionary/identifiers');
|
|
8
|
+
const { RULE } = require('../dictionary/postcss');
|
|
9
|
+
const { HTML } = require('../dictionary/tags');
|
|
10
|
+
|
|
11
|
+
module.exports = class StarHtml extends BasePlugin {
|
|
12
|
+
/** @param {import('postcss').Result=} result */
|
|
13
|
+
constructor(result) {
|
|
14
|
+
super([IE_5_5, IE_6], [RULE], result);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {import('postcss').Rule} rule
|
|
19
|
+
* @return {void}
|
|
20
|
+
*/
|
|
21
|
+
detect(rule) {
|
|
22
|
+
if (isMixin(rule)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
parser(this.analyse(rule)).processSync(rule.selector);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @param {import('postcss').Rule} rule
|
|
30
|
+
* @return {parser.SyncProcessor<void>}
|
|
31
|
+
*/
|
|
32
|
+
analyse(rule) {
|
|
33
|
+
return (selectors) => {
|
|
34
|
+
selectors.each((selector) => {
|
|
35
|
+
if (
|
|
36
|
+
exists(selector, 0, '*') &&
|
|
37
|
+
exists(selector, 1, ' ') &&
|
|
38
|
+
exists(selector, 2, HTML) &&
|
|
39
|
+
exists(selector, 3, ' ') &&
|
|
40
|
+
selector.at(4)
|
|
41
|
+
) {
|
|
42
|
+
this.push(rule, {
|
|
43
|
+
identifier: SELECTOR,
|
|
44
|
+
hack: selector.toString(),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const BasePlugin = require('../plugin');
|
|
3
|
+
const isMixin = require('../isMixin');
|
|
4
|
+
const { IE_5_5, IE_6, IE_7 } = require('../dictionary/browsers');
|
|
5
|
+
const { SELECTOR } = require('../dictionary/identifiers');
|
|
6
|
+
const { RULE } = require('../dictionary/postcss');
|
|
7
|
+
|
|
8
|
+
module.exports = class TrailingSlashComma extends BasePlugin {
|
|
9
|
+
/** @param {import('postcss').Result=} result */
|
|
10
|
+
constructor(result) {
|
|
11
|
+
super([IE_5_5, IE_6, IE_7], [RULE], result);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {import('postcss').Rule} rule
|
|
16
|
+
* @return {void}
|
|
17
|
+
*/
|
|
18
|
+
detect(rule) {
|
|
19
|
+
if (isMixin(rule)) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const { selector } = rule;
|
|
24
|
+
const trim = selector.trim();
|
|
25
|
+
|
|
26
|
+
if (
|
|
27
|
+
trim.lastIndexOf(',') === selector.length - 1 ||
|
|
28
|
+
trim.lastIndexOf('\\') === selector.length - 1
|
|
29
|
+
) {
|
|
30
|
+
this.push(rule, {
|
|
31
|
+
identifier: SELECTOR,
|
|
32
|
+
hack: selector,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export = pluginCreator;
|
|
2
|
+
/** @typedef {{lint?: boolean}} Options */
|
|
3
|
+
/**
|
|
4
|
+
* @type {import('postcss').PluginCreator<Options>}
|
|
5
|
+
* @param {Options} opts
|
|
6
|
+
* @return {import('postcss').Plugin}
|
|
7
|
+
*/
|
|
8
|
+
declare function pluginCreator(opts?: Options): import('postcss').Plugin;
|
|
9
|
+
declare namespace pluginCreator {
|
|
10
|
+
export { detect, postcss, Options };
|
|
11
|
+
}
|
|
12
|
+
type Options = {
|
|
13
|
+
lint?: boolean;
|
|
14
|
+
};
|
|
15
|
+
declare function detect(node: import('postcss').Node): boolean;
|
|
16
|
+
declare var postcss: true;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export = BasePlugin;
|
|
2
|
+
declare class BasePlugin {
|
|
3
|
+
/**
|
|
4
|
+
* @param {string[]} targets
|
|
5
|
+
* @param {string[]} nodeTypes
|
|
6
|
+
* @param {import('postcss').Result=} result
|
|
7
|
+
*/
|
|
8
|
+
constructor(targets: string[], nodeTypes: string[], result?: import('postcss').Result | undefined);
|
|
9
|
+
/** @type {NodeWithInfo[]} */
|
|
10
|
+
nodes: NodeWithInfo[];
|
|
11
|
+
targets: Set<string>;
|
|
12
|
+
nodeTypes: Set<string>;
|
|
13
|
+
result: import("postcss").Result | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* @param {import('postcss').Node} node
|
|
16
|
+
* @param {{identifier: string, hack: string}} metadata
|
|
17
|
+
* @return {void}
|
|
18
|
+
*/
|
|
19
|
+
push(node: import('postcss').Node, metadata: {
|
|
20
|
+
identifier: string;
|
|
21
|
+
hack: string;
|
|
22
|
+
}): void;
|
|
23
|
+
/**
|
|
24
|
+
* @param {import('postcss').Node} node
|
|
25
|
+
* @return {boolean}
|
|
26
|
+
*/
|
|
27
|
+
any(node: import('postcss').Node): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @param {import('postcss').Node} node
|
|
30
|
+
* @return {void}
|
|
31
|
+
*/
|
|
32
|
+
detectAndResolve(node: import('postcss').Node): void;
|
|
33
|
+
/**
|
|
34
|
+
* @param {import('postcss').Node} node
|
|
35
|
+
* @return {void}
|
|
36
|
+
*/
|
|
37
|
+
detectAndWarn(node: import('postcss').Node): void;
|
|
38
|
+
/** @param {import('postcss').Node} node */
|
|
39
|
+
detect(node: import('postcss').Node): void;
|
|
40
|
+
/** @return {void} */
|
|
41
|
+
resolve(): void;
|
|
42
|
+
warn(): void;
|
|
43
|
+
}
|
|
44
|
+
declare namespace BasePlugin {
|
|
45
|
+
export { Plugin, NodeWithInfo };
|
|
46
|
+
}
|
|
47
|
+
type NodeWithInfo = import('postcss').Node & {
|
|
48
|
+
_stylehacks: {
|
|
49
|
+
message: string;
|
|
50
|
+
browsers: Set<string>;
|
|
51
|
+
identifier: string;
|
|
52
|
+
hack: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type Plugin = {
|
|
56
|
+
targets: Set<string>;
|
|
57
|
+
nodeTypes: Set<string>;
|
|
58
|
+
detectAndResolve: (node: import('postcss').Node) => void;
|
|
59
|
+
detectAndWarn: (node: import('postcss').Node) => void;
|
|
60
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export = BodyEmpty;
|
|
2
|
+
declare class BodyEmpty extends BasePlugin {
|
|
3
|
+
/** @param {import('postcss').Result} result */
|
|
4
|
+
constructor(result: import('postcss').Result);
|
|
5
|
+
/**
|
|
6
|
+
* @param {import('postcss').Rule} rule
|
|
7
|
+
* @return {void}
|
|
8
|
+
*/
|
|
9
|
+
detect(rule: import('postcss').Rule): void;
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('postcss').Rule} rule
|
|
12
|
+
* @return {parser.SyncProcessor<void>}
|
|
13
|
+
*/
|
|
14
|
+
analyse(rule: import('postcss').Rule): parser.SyncProcessor<void>;
|
|
15
|
+
}
|
|
16
|
+
import BasePlugin = require("../plugin");
|
|
17
|
+
import parser = require("postcss-selector-parser");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export = HtmlCombinatorCommentBody;
|
|
2
|
+
declare class HtmlCombinatorCommentBody extends BasePlugin {
|
|
3
|
+
/** @param {import('postcss').Result} result */
|
|
4
|
+
constructor(result: import('postcss').Result);
|
|
5
|
+
/**
|
|
6
|
+
* @param {import('postcss').Rule} rule
|
|
7
|
+
* @return {void}
|
|
8
|
+
*/
|
|
9
|
+
detect(rule: import('postcss').Rule): void;
|
|
10
|
+
/** @param {import('postcss').Rule} rule
|
|
11
|
+
* @return {parser.SyncProcessor<void>}
|
|
12
|
+
*/
|
|
13
|
+
analyse(rule: import('postcss').Rule): parser.SyncProcessor<void>;
|
|
14
|
+
}
|
|
15
|
+
import BasePlugin = require("../plugin");
|
|
16
|
+
import parser = require("postcss-selector-parser");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export = HtmlFirstChild;
|
|
2
|
+
declare class HtmlFirstChild extends BasePlugin {
|
|
3
|
+
/** @param {import('postcss').Result} result */
|
|
4
|
+
constructor(result: import('postcss').Result);
|
|
5
|
+
/**
|
|
6
|
+
* @param {import('postcss').Rule} rule
|
|
7
|
+
* @return {void}
|
|
8
|
+
*/
|
|
9
|
+
detect(rule: import('postcss').Rule): void;
|
|
10
|
+
/**
|
|
11
|
+
* @param {import('postcss').Rule} rule
|
|
12
|
+
* @return {parser.SyncProcessor<void>}
|
|
13
|
+
*/
|
|
14
|
+
analyse(rule: import('postcss').Rule): parser.SyncProcessor<void>;
|
|
15
|
+
}
|
|
16
|
+
import BasePlugin = require("../plugin");
|
|
17
|
+
import parser = require("postcss-selector-parser");
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export = Important;
|
|
2
|
+
declare class Important extends BasePlugin {
|
|
3
|
+
/** @param {import('postcss').Result=} result */
|
|
4
|
+
constructor(result?: import('postcss').Result | undefined);
|
|
5
|
+
/**
|
|
6
|
+
* @param {import('postcss').Declaration} decl
|
|
7
|
+
* @return {void}
|
|
8
|
+
*/
|
|
9
|
+
detect(decl: import('postcss').Declaration): void;
|
|
10
|
+
}
|
|
11
|
+
import BasePlugin = require("../plugin");
|