-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b150d9
commit 45f42bc
Showing
21 changed files
with
1,992 additions
and
158 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,20 @@ | ||
{ | ||
"extends": ["stylelint-config-recommended-scss", "stylelint-prettier/recommended"], | ||
"rules": { | ||
"selector-pseudo-class-no-unknown": [ | ||
true, | ||
{ | ||
"ignorePseudoClasses": [ | ||
"global" | ||
] | ||
} | ||
], | ||
"@cloudscape-design/license-headers": [ | ||
true, | ||
{ | ||
"header": "\n Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n SPDX-License-Identifier: Apache-2.0\n" | ||
} | ||
] | ||
}, | ||
"plugins": ["./build-tools/stylelint"] | ||
} |
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,5 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import licenseHeaders from "./license-headers.js"; | ||
|
||
export default [licenseHeaders]; |
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,56 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import stylelint from "stylelint"; | ||
|
||
const ruleName = "@cloudscape-design/license-headers"; | ||
const messages = stylelint.utils.ruleMessages(ruleName, { | ||
rejected: "Missing license header", | ||
}); | ||
|
||
function licenseHeadersPlugin(enabled, { header }, context) { | ||
if (!enabled) { | ||
return; | ||
} | ||
|
||
if (!header) { | ||
throw new Error(`stylelint ${ruleName} rule requires a header option.`); | ||
} | ||
|
||
const trimmedHeader = header.trim(); | ||
|
||
return (root, result) => { | ||
let foundComment = false; | ||
let firstComment = null; | ||
|
||
root.walkComments(function (comment) { | ||
if (comment.parent.type === "root" && comment === comment.parent.first) { | ||
if (!firstComment) { | ||
firstComment = comment; | ||
} | ||
|
||
if (comment.text.trim() === trimmedHeader) { | ||
foundComment = true; | ||
} | ||
} | ||
}); | ||
|
||
if (!foundComment) { | ||
if (context.fix) { | ||
const newComment = `/*${header}*/\n\n`; | ||
root.prepend(newComment); | ||
} else { | ||
stylelint.utils.report({ | ||
message: messages.rejected, | ||
node: firstComment || root, | ||
result, | ||
ruleName, | ||
}); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
licenseHeadersPlugin.ruleName = ruleName; | ||
licenseHeadersPlugin.messages = messages; | ||
|
||
export default stylelint.createPlugin(ruleName, licenseHeadersPlugin); |
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,3 @@ | ||
{ | ||
"type": "module" | ||
} |
Oops, something went wrong.