Skip to content

Commit

Permalink
fix: resolve bug and change npm config
Browse files Browse the repository at this point in the history
  • Loading branch information
iChenLei committed Oct 20, 2021
1 parent 4c1ff7f commit e82fff6
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 30 deletions.
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ tests
.eslintignore
.eslintrc.js
.gitignore
CODE_OF_CONDUCT.md
package-lock.json
CODE_OF_CONDUCT.md
CHANGELOG.md
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.0] - 2021-10-19
## [0.0.4] - 2021-10-20
### Added
- Add base wxml eslint support
- Add basic feature
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ module.exports = {
"no-duplicate-attributes": require("./rules/no-duplicate-attributes"),
"no-index-in-wx-key": require("./rules/no-index-in-wx-key"),
"no-unexpected-string-bool": require("./rules/no-unexpected-string-bool"),
'no-vue-directive"': require("./rules/no-vue-directive"),
"no-vue-directive": require("./rules/no-vue-directive"),
"required-attributes": require("./rules/required-attributes"),
"report-wxs-syntax-error": require("./rules/report-wxs-syntax-error"),
"report-wxml-syntax-error": require("./rules/report-wxml-syntax-error"),
},
configs: {},
processors: {
Expand Down
51 changes: 28 additions & 23 deletions lib/rules/required-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,38 @@ module.exports = {
messages: {
missingAttributes: "<{{tag}}> missing these attributes -> [{{attrs}}]",
},
schema: [
{
type: "object",
properties: {
tag: { type: "string" },
attrs: {
type: "array",
items: {
anyOf: [
{ type: "string" },
{
type: "object",
properties: {
key: { type: "string" },
value: { type: "string" },
},
required: ["key"],
additionalProperties: false,
schema: {
type: "array",
items: {
anyOf: [
{
type: "object",
properties: {
tag: { type: "string" },
attrs: {
type: "array",
items: {
anyOf: [
{ type: "string" },
{
type: "object",
properties: {
key: { type: "string" },
value: { type: "string" },
},
required: ["key"],
additionalProperties: false,
},
],
},
],
},
},
required: ["tag", "attrs"],
additionalProperties: false,
},
},
required: ["tag", "attrs"],
additionalProperties: false,
],
},
],
},
},

/** @param {import('eslint').Rule.RuleContext} context */
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-wxml",
"version": "0.0.2",
"version": "0.0.4",
"description": "eslint plugin for wxml",
"main": "lib/index.js",
"type": "commonjs",
Expand Down
17 changes: 16 additions & 1 deletion tests/rules/required-attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ tester.run("required-attributes", rule, {
tag: "popup",
attrs: [{ key: "wx:if", value: "{{$popupVisiable}}" }],
},
{
tag: "modal",
attrs: ["showMask"],
},
],
},
],
Expand Down Expand Up @@ -51,7 +55,7 @@ tester.run("required-attributes", rule, {
],
},
{
code: `<mall a b="config" c="entry" b="trouble" />`,
code: `<mall a b="config" c="entry" b="trouble" /> <modal />`,
options: [
{
tag: "mall",
Expand All @@ -61,6 +65,10 @@ tester.run("required-attributes", rule, {
{ key: "b", value: "config" },
],
},
{
tag: "modal",
attrs: ["showMask"],
},
],
errors: [
{
Expand All @@ -70,6 +78,13 @@ tester.run("required-attributes", rule, {
attrs: '"d","a=you"',
},
},
{
messageId: "missingAttributes",
data: {
tag: "modal",
attrs: '"showMask"',
},
},
],
},
],
Expand Down

0 comments on commit e82fff6

Please sign in to comment.