Skip to content

Commit 421564b

Browse files
authored
Improve documents (#25)
* Improve documents * Improve documents
1 parent 62aa789 commit 421564b

File tree

176 files changed

+3617
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+3617
-537
lines changed

.env-cmdrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"version": {
3+
"IN_VERSION_SCRIPT": "true"
4+
}
5+
}

docs/.vuepress/.eslintrc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict"
2+
3+
module.exports = {
4+
overrides: [
5+
{
6+
files: ["enhanceApp.mjs"],
7+
parserOptions: {
8+
sourceType: "module",
9+
},
10+
globals: {
11+
window: false,
12+
},
13+
},
14+
],
15+
}

docs/.vuepress/components/eslint-playground.vue

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:class="`eslint-playground-${type}`"
88
class="eslint-playground"
99
dark
10-
fix
10+
:fix="fix"
1111
/>
1212
</template>
1313

@@ -20,9 +20,13 @@ export default {
2020
components: { EslintEditor },
2121
2222
props: {
23+
// For no-json-superset
2324
code: {
2425
type: String,
25-
required: true,
26+
default: undefined,
27+
},
28+
fix: {
29+
type: Boolean,
2630
},
2731
type: {
2832
type: String,
@@ -89,16 +93,21 @@ export default {
8993
9094
computed: {
9195
cookedCode() {
92-
return (this.code || "").replace(
93-
/&#x([0-9a-zA-Z]+);/gu,
94-
(_, codePoint) => String.fromCodePoint(parseInt(codePoint, 16)),
95-
)
96+
if (this.code && this.code.trim()) {
97+
return (this.code || "").replace(
98+
/&#x([0-9a-zA-Z]+);/gu,
99+
(_, codePoint) =>
100+
String.fromCodePoint(parseInt(codePoint, 16)),
101+
)
102+
}
103+
104+
return `${computeCodeFromSlot(this.$slots.default).trim()}\n`
96105
},
97106
},
98107
99108
async mounted() {
100109
// Load linter.
101-
const { default: Linter } = await import("eslint4b/dist/linter")
110+
const { Linter } = await import("eslint/lib/linter")
102111
const linter = (this.linter = new Linter())
103112
104113
for (const ruleId of Object.keys(rules)) {
@@ -131,6 +140,19 @@ export default {
131140
},
132141
},
133142
}
143+
144+
/**
145+
* @param {VNode[]} nodes
146+
* @returns {string}
147+
*/
148+
function computeCodeFromSlot(nodes) {
149+
if (!Array.isArray(nodes)) {
150+
return ""
151+
}
152+
return nodes
153+
.map((node) => node.text || computeCodeFromSlot(node.children))
154+
.join("")
155+
}
134156
</script>
135157

136158
<style>

docs/.vuepress/config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
"use strict"
66

7+
const path = require("path")
78
const { categories } = require("../../scripts/rules")
89
require("../../scripts/update-docs-readme")
910

@@ -13,6 +14,27 @@ module.exports = {
1314
description: "ESLint plugin about ECMAScript syntax.",
1415
evergreen: true,
1516

17+
enhanceAppFiles: require.resolve("./enhanceApp.mjs"),
18+
configureWebpack(_config, _isServer) {
19+
return {
20+
externals: {
21+
typescript: "typescript",
22+
},
23+
resolve: {
24+
alias: {
25+
esquery: path.resolve(
26+
__dirname,
27+
"../../node_modules/esquery/dist/esquery.min.js",
28+
),
29+
"@eslint/eslintrc/universal": path.resolve(
30+
__dirname,
31+
"../../node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs",
32+
),
33+
},
34+
},
35+
}
36+
},
37+
1638
themeConfig: {
1739
repo: "ota-meshi/eslint-plugin-es-x",
1840
docsRepo: "ota-meshi/eslint-plugin-es-x",

docs/.vuepress/enhanceApp.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export default ({
2+
_Vue, // the version of Vue being used in the VuePress app
3+
_options, // the options for the root Vue instance
4+
_router, // the router instance for the app
5+
_siteData, // site metadata
6+
}) => {
7+
if (typeof window !== "undefined") {
8+
if (typeof window.global === "undefined") {
9+
window.global = {}
10+
}
11+
if (typeof window.process === "undefined") {
12+
window.process = {
13+
env: {},
14+
cwd: () => undefined,
15+
}
16+
}
17+
}
18+
}

docs/rules/no-accessor-properties.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
---
2+
title: "es-x/no-accessor-properties"
3+
description: "disallow accessor properties"
4+
since: "[eslint-plugin-es] v1.1.0"
5+
---
6+
17
# es-x/no-accessor-properties
28
> disallow accessor properties
39
410
- ✅ The following configurations enable this rule: `plugin:es-x/no-new-in-es5` and `plugin:es-x/restrict-to-es3`
511

612
This rule reports ES5 accessor properties as errors.
713

8-
## Examples
14+
## 💡 Examples
915

1016
⛔ Examples of **incorrect** code for this rule:
1117

12-
<eslint-playground type="bad" code="/*eslint es-x/no-accessor-properties: error */
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-accessor-properties: error */
1322
var a = {
1423
get a() {},
1524
set a(value) {}
@@ -18,7 +27,15 @@ class A {
1827
get a() {}
1928
set a(value) {}
2029
}
21-
" />
30+
```
31+
32+
</eslint-playground>
33+
34+
## 🚀 Version
35+
36+
This rule was introduced in [eslint-plugin-es] v1.1.0.
37+
38+
[eslint-plugin-es]: https://github.com/mysticatea/eslint-plugin-es
2239

2340
## 📚 References
2441

docs/rules/no-arbitrary-module-namespace-names.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1+
---
2+
title: "es-x/no-arbitrary-module-namespace-names"
3+
description: "disallow arbitrary module namespace names"
4+
since: "v5.0.0"
5+
---
6+
17
# es-x/no-arbitrary-module-namespace-names
28
> disallow arbitrary module namespace names
39
410
- ✅ The following configurations enable this rule: `plugin:es-x/no-new-in-es2022`, `plugin:es-x/restrict-to-es3`, `plugin:es-x/restrict-to-es5`, `plugin:es-x/restrict-to-es2015`, `plugin:es-x/restrict-to-es2016`, `plugin:es-x/restrict-to-es2017`, `plugin:es-x/restrict-to-es2018`, `plugin:es-x/restrict-to-es2019`, `plugin:es-x/restrict-to-es2020`, and `plugin:es-x/restrict-to-es2021`
511

612
This rule reports ES2022 arbitrary module namespace names as errors.
713

8-
## Examples
14+
## 💡 Examples
915

1016
⛔ Examples of **incorrect** code for this rule:
1117

12-
<eslint-playground type="bad" code="/*eslint es-x/no-arbitrary-module-namespace-names: error */
13-
export * as &quot;ns&quot; from &quot;mod&quot;
14-
export {foo as &quot;bar&quot;} from &quot;mod&quot;
15-
import {&quot;foo&quot; as bar} from &quot;mod&quot;
16-
" />
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-arbitrary-module-namespace-names: error */
22+
export * as "ns" from "mod"
23+
export {foo as "bar"} from "mod"
24+
import {"foo" as bar} from "mod"
25+
```
26+
27+
</eslint-playground>
28+
29+
## 🚀 Version
30+
31+
This rule was introduced in v5.0.0.
1732

1833
## 📚 References
1934

docs/rules/no-array-from.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1+
---
2+
title: "es-x/no-array-from"
3+
description: "disallow the `Array.from` method"
4+
since: "[eslint-plugin-es] v1.2.0"
5+
---
6+
17
# es-x/no-array-from
28
> disallow the `Array.from` method
39
410
- ✅ The following configurations enable this rule: `plugin:es-x/no-new-in-es2015`, `plugin:es-x/restrict-to-es3`, and `plugin:es-x/restrict-to-es5`
511

612
This rule reports ES2015 `Array.from` method as errors.
713

8-
## Examples
14+
## 💡 Examples
915

1016
⛔ Examples of **incorrect** code for this rule:
1117

12-
<eslint-playground type="bad" code="/*eslint es-x/no-array-from: error */
13-
const array = Array.from(&quot;hello&quot;)
14-
" />
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-array-from: error */
22+
const array = Array.from("hello")
23+
```
24+
25+
</eslint-playground>
26+
27+
## 🚀 Version
28+
29+
This rule was introduced in [eslint-plugin-es] v1.2.0.
30+
31+
[eslint-plugin-es]: https://github.com/mysticatea/eslint-plugin-es
1532

1633
## 📚 References
1734

docs/rules/no-array-isarray.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1+
---
2+
title: "es-x/no-array-isarray"
3+
description: "disallow the `Array.isArray` method"
4+
since: "[eslint-plugin-es] v3.0.0"
5+
---
6+
17
# es-x/no-array-isarray
28
> disallow the `Array.isArray` method
39
410
- ✅ The following configurations enable this rule: `plugin:es-x/no-new-in-es5` and `plugin:es-x/restrict-to-es3`
511

612
This rule reports ES5 `Array.isArray` method as errors.
713

8-
## Examples
14+
## 💡 Examples
915

1016
⛔ Examples of **incorrect** code for this rule:
1117

12-
<eslint-playground type="bad" code="/*eslint es-x/no-array-isarray: error */
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-array-isarray: error */
1322
var array = Array.isArray(obj)
14-
" />
23+
```
24+
25+
</eslint-playground>
26+
27+
## 🚀 Version
28+
29+
This rule was introduced in [eslint-plugin-es] v3.0.0.
30+
31+
[eslint-plugin-es]: https://github.com/mysticatea/eslint-plugin-es
1532

1633
## 📚 References
1734

docs/rules/no-array-of.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1+
---
2+
title: "es-x/no-array-of"
3+
description: "disallow the `Array.of` method"
4+
since: "[eslint-plugin-es] v1.2.0"
5+
---
6+
17
# es-x/no-array-of
28
> disallow the `Array.of` method
39
410
- ✅ The following configurations enable this rule: `plugin:es-x/no-new-in-es2015`, `plugin:es-x/restrict-to-es3`, and `plugin:es-x/restrict-to-es5`
511

612
This rule reports ES2015 `Array.of` method as errors.
713

8-
## Examples
14+
## 💡 Examples
915

1016
⛔ Examples of **incorrect** code for this rule:
1117

12-
<eslint-playground type="bad" code="/*eslint es-x/no-array-of: error */
18+
<eslint-playground type="bad">
19+
20+
```js
21+
/*eslint es-x/no-array-of: error */
1322
const array = Array.of(1, 2, 3)
14-
" />
23+
```
24+
25+
</eslint-playground>
26+
27+
## 🚀 Version
28+
29+
This rule was introduced in [eslint-plugin-es] v1.2.0.
30+
31+
[eslint-plugin-es]: https://github.com/mysticatea/eslint-plugin-es
1532

1633
## 📚 References
1734

0 commit comments

Comments
 (0)