ソースを参照

Added an check, if each attribute has a "data-" prefix

Dustin Utecht 4 年 前
コミット
ebb4aa5ea2
1 ファイル変更10 行追加0 行削除
  1. 10 0
      tools/check-api.js

+ 10 - 0
tools/check-api.js

@@ -7,6 +7,7 @@ let errorSum = 0
 const exampleFilesFolder = './bootstrap-table-examples/'
 const exampleFilesFound = fs.existsSync(exampleFilesFolder)
 let exampleFiles = []
+
 if (exampleFilesFound) {
   exampleFiles = [
     ...fs.readdirSync(exampleFilesFolder + 'welcomes'),
@@ -38,6 +39,7 @@ class API {
     const outLines = lines.slice(0, 1)
     const errors = []
     const exampleRegex = /\[.*\]\(.*\/(.*\.html)\)/m
+    const attributeRegex = /\*\*Attribute:\*\*\s`(.*)data-(.*)`/m
 
     for (const item of lines.slice(1)) {
       md[item.split('\n')[0]] = item
@@ -52,6 +54,7 @@ class API {
 
           for (let i = 0; i < this.attributes.length; i++) {
             const name = this.attributes[i]
+
             if (this.ignore && this.ignore[key] && this.ignore[key].includes(name)) {
               continue
             }
@@ -67,6 +70,13 @@ class API {
               if (!exampleFiles.includes(matches[1])) {
                 errors.push(chalk.red(`[${key}] example '${matches[1]}' could not be found`))
               }
+            } else if (name === 'Attribute' && key !== 'columns') {
+              const attributeMatches = attributeRegex.exec(tmpDetails)
+
+              if (!attributeMatches) {
+                errors.push(chalk.red(`[${key}] missing or wrong formatted attribute`, `"${tmpDetails}"`))
+                continue
+              }
             }
 
             if (!tmpDetails || tmpDetails.indexOf(`**${name}:**`) === -1) {