Skip to content

Commit

Permalink
Use arrow functions in docs (#6081)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous committed Jun 6, 2022
1 parent 9d045d9 commit 1c386a6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions docs/developer-guide/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const meta = {

module.exports = stylelint.createPlugin(
ruleName,
function (primaryOption, secondaryOptionObject) {
return function (postcssRoot, postcssResult) {
(primaryOption, secondaryOptionObject) => {
return (postcssRoot, postcssResult) => {
const validOptions = stylelint.utils.validateOptions(
postcssResult,
ruleName,
Expand Down Expand Up @@ -91,8 +91,8 @@ const meta = {

module.exports = stylelint.createPlugin(
ruleName,
function (primaryOption, secondaryOptionObject) {
return function (postcssRoot, postcssResult) {
(primaryOption, secondaryOptionObject) => {
return (postcssRoot, postcssResult) => {
const validOptions = stylelint.utils.validateOptions(
postcssResult,
ruleName,
Expand All @@ -105,9 +105,9 @@ module.exports = stylelint.createPlugin(
return;
}

return new Promise(function (resolve) {
return new Promise((resolve) => {
// some async operation
setTimeout(function () {
setTimeout(() => {
// ... some logic ...
stylelint.utils.report({
/* .. */
Expand Down Expand Up @@ -250,7 +250,7 @@ const allowableAtRules = [
];

function myPluginRule(primaryOption, secondaryOptionObject) {
return function (postcssRoot, postcssResult) {
return (postcssRoot, postcssResult) => {
const defaultedOptions = Object.assign({}, secondaryOptionObject, {
ignoreAtRules: allowableAtRules.concat(options.ignoreAtRules || [])
});
Expand Down Expand Up @@ -289,7 +289,7 @@ All rules share a common signature. They are a function that accepts two argumen
Here's an example of a plugin that runs `declaration-no-important` only if there is a special directive `@@check-declaration-no-important` somewhere in the stylesheet:

```js
module.exports = stylelint.createPlugin(ruleName, function (expectation) {
module.exports = stylelint.createPlugin(ruleName, (expectation) => {
const runDeclarationNoImportant =
stylelint.rules["declaration-no-important"](expectation);

Expand Down
6 changes: 3 additions & 3 deletions docs/developer-guide/processors.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ Processor modules are functions that accept an options object and return an obje

```js
// my-processor.js
module.exports = function (options) {
module.exports = function myProcessor(options) {
return {
code: function (input, filepath) {
code: (input, filepath) => {
// ...
return transformedCode;
},
result: function (stylelintResult, filepath) {
result: (stylelintResult, filepath) => {
// ...
return transformedResult;
}
Expand Down
18 changes: 9 additions & 9 deletions docs/user-guide/usage/node-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The Stylelint module includes a `lint()` function that provides the Node.js API.

```js
stylelint.lint(options).then(function (resultObject) {
stylelint.lint(options).then((resultObject) => {
/* .. */
});
```
Expand Down Expand Up @@ -90,11 +90,11 @@ stylelint
config: { rules: "color-no-invalid-hex" },
files: "all/my/stylesheets/*.css"
})
.then(function (data) {
.then((data) => {
// do things with data.output, data.errored,
// and data.results
})
.catch(function (err) {
.catch((err) => {
// do things with err e.g.
console.error(err.stack);
});
Expand All @@ -111,7 +111,7 @@ stylelint
configBasedir: path.join(__dirname, "configs"),
files: "all/my/stylesheets/*.css"
})
.then(function () {
.then(() => {
/* .. */
});
```
Expand All @@ -127,7 +127,7 @@ stylelint
config: myConfig,
formatter: "verbose"
})
.then(function () {
.then(() => {
/* .. */
});
```
Expand All @@ -141,11 +141,11 @@ stylelint
.lint({
config: myConfig,
files: "all/my/stylesheets/*.scss",
formatter: function (stylelintResults) {
formatter: (stylelintResults) => {
/* .. */
}
})
.then(function () {
.then(() => {
/* .. */
});
```
Expand All @@ -168,7 +168,7 @@ stylelint
}
}
})
.then(function () {
.then(() => {
/* .. */
});
```
Expand All @@ -186,7 +186,7 @@ stylelint
config: { rules: { "hue-degree-notation": "angle" } },
fix: true
})
.then(function () {
.then(() => {
/* .. */
});
```
Expand Down

0 comments on commit 1c386a6

Please sign in to comment.