-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
precompile stylelint-config-swissquote with esm
- Loading branch information
Showing
26 changed files
with
296 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { getExternals } from "../../utils/externals.js"; | ||
|
||
const commonExternals = { | ||
// Provided by other Crafty packages | ||
...getExternals(), | ||
|
||
stylelint: "../../shims/stylelint.js", | ||
"stylelint/lib/utils/optionsMatches": | ||
"../stylelint-utils/stylelint-optionsMatches.js", | ||
}; | ||
|
||
const FAKE_PRETTIER_PARSER = "../../shims/prettier-parser.js"; | ||
|
||
export default [ | ||
(builder) => | ||
builder("stylelint-prettier") | ||
.esm() | ||
.package() | ||
.externals({ | ||
...commonExternals, | ||
|
||
// We don't need most prettier parsers | ||
"./parser-angular.js": FAKE_PRETTIER_PARSER, | ||
"./parser-babel.js": FAKE_PRETTIER_PARSER, | ||
"./parser-espree.js": FAKE_PRETTIER_PARSER, | ||
"./parser-flow.js": FAKE_PRETTIER_PARSER, | ||
"./parser-glimmer.js": FAKE_PRETTIER_PARSER, | ||
"./parser-graphql.js": FAKE_PRETTIER_PARSER, | ||
"./parser-html.js": FAKE_PRETTIER_PARSER, | ||
"./parser-markdown.js": FAKE_PRETTIER_PARSER, | ||
"./parser-meriyah.js": FAKE_PRETTIER_PARSER, | ||
"./parser-typescript.js": FAKE_PRETTIER_PARSER, | ||
"./parser-yaml.js": FAKE_PRETTIER_PARSER, | ||
}), | ||
(builder) => builder("postcss-selector-parser").esm().package(), | ||
(builder) => builder("postcss-resolve-nested-selector").esm().package(), | ||
(builder) => builder("postcss-value-parser").esm().package(), | ||
(builder) => | ||
builder("stylelint-scss") | ||
.esm() | ||
.package() | ||
.externals({ | ||
...commonExternals, | ||
|
||
// We use other packages created here | ||
"postcss-selector-parser": "../postcss-selector-parser/index.mjs", | ||
"postcss-value-parser": "../postcss-value-parser/index.mjs", | ||
"postcss-resolve-nested-selector": | ||
"../postcss-resolve-nested-selector/index.mjs", | ||
|
||
// We mock the few lodash functions really used | ||
lodash: "../../shims/lodash.js", | ||
}), | ||
(builder) => | ||
builder("stylelint-no-unsupported-browser-features") | ||
.esm() | ||
.externals({ | ||
...commonExternals, | ||
|
||
postcss: "postcss", | ||
"postcss/lib/result": "postcss/lib/result", | ||
"postcss/lib/list": "postcss/lib/list", | ||
|
||
// We keep postcss-scss external so we can have it in common with preset-postcss | ||
"postcss-scss": "postcss-scss", | ||
|
||
// Used by stylelint-no-unsupported-browser-features | ||
"caniuse-lite": "caniuse-lite", | ||
"/caniuse-lite(/.*)/": "caniuse-lite$1", | ||
|
||
// We mock the few lodash functions really used | ||
lodash: "../../shims/lodash.js", | ||
}) | ||
.package(), | ||
(builder) => | ||
builder("stylelint-utils") | ||
.esm() | ||
.packages((pkg) => | ||
pkg | ||
.package( | ||
"stylelint/lib/utils/declarationValueIndex.mjs", | ||
"declarationValueIndex", | ||
"dist/stylelint-utils/stylelint-declarationValueIndex.js" | ||
) | ||
.package( | ||
"stylelint/lib/utils/isStandardSyntaxFunction.mjs", | ||
"isStandardSyntaxFunction", | ||
"dist/stylelint-utils/stylelint-isStandardSyntaxFunction.js" | ||
) | ||
.package( | ||
"stylelint/lib/utils/isStandardSyntaxRule.mjs", | ||
"isStandardSyntaxRule", | ||
"dist/stylelint-utils/stylelint-isStandardSyntaxRule.js" | ||
) | ||
.package( | ||
"stylelint/lib/utils/isStandardSyntaxSelector.mjs", | ||
"isStandardSyntaxSelector", | ||
"dist/stylelint-utils/stylelint-isStandardSyntaxSelector.js" | ||
) | ||
.package( | ||
"stylelint/lib/utils/isKeyframeSelector.mjs", | ||
"isKeyframeSelector", | ||
"dist/stylelint-utils/stylelint-isKeyframeSelector.js" | ||
) | ||
.package( | ||
"stylelint/lib/utils/optionsMatches.mjs", | ||
"optionMatches", | ||
"dist/stylelint-utils/stylelint-optionsMatches.js" | ||
) | ||
) | ||
.externals({ | ||
"../reference/keywordSets": "../../shims/stylelint-keywordSets.js", | ||
}) | ||
.options({ | ||
sourceMap: false, | ||
}), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/stylelint-config-swissquote/packages/postcss-resolve-nested-selector.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "../dist/postcss-resolve-nested-selector/index.mjs"; |
1 change: 1 addition & 0 deletions
1
packages/stylelint-config-swissquote/packages/postcss-selector-parser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "../dist/postcss-selector-parser/index.mjs"; |
1 change: 1 addition & 0 deletions
1
packages/stylelint-config-swissquote/packages/postcss-value-parser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "../dist/postcss-value-parser/index.mjs"; |
1 change: 1 addition & 0 deletions
1
packages/stylelint-config-swissquote/packages/stylelint-no-unsupported-browser-features.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "../dist/stylelint-no-unsupported-browser-features/index.mjs"; |
1 change: 1 addition & 0 deletions
1
packages/stylelint-config-swissquote/packages/stylelint-prettier.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "../dist/stylelint-prettier/index.mjs"; |
1 change: 1 addition & 0 deletions
1
packages/stylelint-config-swissquote/packages/stylelint-scss.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "../dist/stylelint-scss/index.mjs"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Since the used modules only use a tiny fraction of lodash we don't want that huge module | ||
// Reimplement them here waiting for https://github.com/stylelint-scss/stylelint-scss/pull/554 to be finished | ||
|
||
export function isBoolean(value) { | ||
return typeof value === "boolean" || value instanceof Boolean; | ||
} | ||
|
||
export function isNumber(value) { | ||
return typeof value === "number" || value instanceof Number; | ||
} | ||
|
||
export function isRegExp(value) { | ||
return value instanceof RegExp; | ||
} | ||
|
||
export function isString(value) { | ||
return typeof value === "string" || value instanceof String; | ||
} | ||
|
||
/** | ||
* All credits go to https://github.com/developit/dlv | ||
*/ | ||
/* eslint-disable no-param-reassign */ | ||
export function get(obj, key, def, p, undef) { | ||
key = key.split ? key.split(".") : key; | ||
for (p = 0; p < key.length; p++) { | ||
obj = obj ? obj[key[p]] : undef; | ||
} | ||
return obj === undef ? def : obj; | ||
} | ||
|
||
export function pick(obj, keys) { | ||
return Object.fromEntries( | ||
Object.entries(obj).filter((entry) => keys.indexOf(entry[0]) > -1) | ||
); | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/stylelint-config-swissquote/shims/prettier-parser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
parsers: new Proxy( | ||
{}, | ||
{ | ||
get: function (target, prop, receiver) { | ||
return {}; | ||
}, | ||
} | ||
), | ||
}; |
6 changes: 6 additions & 0 deletions
6
packages/stylelint-config-swissquote/shims/stylelint-keywordSets.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const keywordSets = {}; | ||
|
||
// Include only these keywords | ||
keywordSets.keyframeSelectorKeywords = new Set(['from', 'to']); | ||
|
||
export default keywordSets; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Stylelint is bundled with Crafty | ||
// If this package is used within Crafty, we need to use it from "@swissquote/crafty-preset-stylelint" | ||
// Otherwise we fallback in loading stylelint directly | ||
|
||
let imported; | ||
|
||
try { | ||
imported = await import("@swissquote/crafty-preset-stylelint/packages/stylelint.js"); | ||
} catch (e) { | ||
imported = await import("stylelint"); | ||
} | ||
|
||
export const postcss= true; | ||
export const lint = imported.default.lint; | ||
export const rules = imported.default.rules; | ||
export const formatters = imported.default.formatters; | ||
export const createPlugin = imported.default.createPlugin; | ||
export const resolveConfig = imported.default.resolveConfig; | ||
export const utils = imported.default.utils; | ||
export const reference = imported.default.reference; | ||
|
||
export default imported.default; | ||
|
6 changes: 3 additions & 3 deletions
6
packages/stylelint-config-swissquote/src/rules/no-block-inside-block.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/stylelint-config-swissquote/src/rules/no-hack-reassignment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/stylelint-config-swissquote/src/rules/no-negative-var.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/stylelint-config-swissquote/src/rules/no-state-without-component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/stylelint-config-swissquote/src/rules/no-type-outside-scope.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/stylelint-config-swissquote/src/rules/no-utility-reassignment.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/stylelint-config-swissquote/src/rules/no-variable-in-transpiled-function.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
packages/stylelint-config-swissquote/src/utils/__tests__/resolveNestedSelector.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/stylelint-config-swissquote/src/utils/parseSelector.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.