Lint changes

This commit is contained in:
Bahadir Sofuoglu 2022-09-14 17:26:41 +03:00
parent eb2de5460c
commit 4d3a071e66
291 changed files with 28450 additions and 26621 deletions

View file

@ -1,37 +1,37 @@
const fs = require("fs");
const path = require("path");
const fs = require('fs');
const path = require('path');
const rootDir = path.resolve(__dirname, "../");
const distDir = path.resolve(rootDir, "dist");
const componentPath = path.join(__dirname, "./components");
const rootDir = path.resolve(__dirname, '../');
const distDir = path.resolve(rootDir, 'dist');
const componentPath = path.join(__dirname, './components');
// Import project `package.json`
const pkg = require(path.resolve(rootDir, "package.json"));
const libraryName = "PrimeVue";
const pkg = require(path.resolve(rootDir, 'package.json'));
const libraryName = 'PrimeVue';
const libraryVersion = pkg.version;
const showcaseURL = "https://primefaces.org/primevue/showcase/#/";
const showcaseURL = 'https://primefaces.org/primevue/showcase/#/';
const fileModules = {},
veturTags = {},
veturAttributes = {};
const files = fs.readdirSync(componentPath);
files.forEach(file => {
files.forEach((file) => {
const { name } = path.parse(file);
fileModules[name] = require(`./components//${name}`);
});
const webTypes = {
$schema: "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
framework: "vue",
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
framework: 'vue',
name: libraryName,
version: libraryVersion,
contributions: {
html: {
"types-syntax": "typescript",
"description-markup": "markdown",
'types-syntax': 'typescript',
'description-markup': 'markdown',
tags: [],
attributes: []
}
@ -41,12 +41,12 @@ const webTypes = {
const addURL = (attr, url, value) => {
const newArray = [];
attr.forEach(att => {
attr.forEach((att) => {
const newObj = {};
Object.keys(att).forEach(key => {
Object.keys(att).forEach((key) => {
newObj[key] = att[key];
if (key === value) newObj["doc-url"] = url;
if (key === value) newObj['doc-url'] = url;
});
newArray.push(newObj);
@ -55,8 +55,8 @@ const addURL = (attr, url, value) => {
return newArray;
};
const createWebTypes = component => {
const url = showcaseURL + `${component["doc-url"] ? component["doc-url"] : component.name.toLowerCase()}`;
const createWebTypes = (component) => {
const url = showcaseURL + `${component['doc-url'] ? component['doc-url'] : component.name.toLowerCase()}`;
// components
const tag = {
@ -65,7 +65,7 @@ const createWebTypes = component => {
module: libraryName,
symbol: component.name
},
"doc-url": url,
'doc-url': url,
description: component.description
};
@ -77,44 +77,43 @@ const createWebTypes = component => {
symbol: component.name
},
description: component.description,
"doc-url": url,
'doc-url': url,
value: {
kind: "expression",
type: "function"
kind: 'expression',
type: 'function'
}
};
if (component.props) {
tag.attributes = addURL(component.props, url, "default");
tag.attributes.forEach(k => {
k["value"] = {
kind: "expression",
type: k["type"]
tag.attributes = addURL(component.props, url, 'default');
tag.attributes.forEach((k) => {
k['value'] = {
kind: 'expression',
type: k['type']
};
delete k["type"];
delete k['type'];
});
}
if (component.events) {
tag.events = addURL(component.events, url, "name");
tag.events.forEach(k => {
tag.events = addURL(component.events, url, 'name');
tag.events.forEach((k) => {
if (k.arguments) {
k.arguments = addURL(k.arguments, url, "name");
k.arguments = addURL(k.arguments, url, 'name');
}
});
}
if (component.slots) {
tag.slots = addURL(component.slots, url, "name");
tag.slots = addURL(component.slots, url, 'name');
}
if (component["vue-modifiers"]) {
if (component['vue-modifiers']) {
attribute.required = false;
attribute["vue-modifiers"] = addURL(component["vue-modifiers"], url, "name");
attribute['vue-modifiers'] = addURL(component['vue-modifiers'], url, 'name');
if (attribute["vue-modifiers"].length < 1)
delete attribute["vue-modifiers"];
if (attribute['vue-modifiers'].length < 1) delete attribute['vue-modifiers'];
webTypes.contributions.html.attributes.push(attribute);
}
@ -122,10 +121,10 @@ const createWebTypes = component => {
webTypes.contributions.html.tags.push(tag);
};
const createVeturTags = component => {
const createVeturTags = (component) => {
const attributes = [];
if (component.props) {
component.props.forEach(comp => {
component.props.forEach((comp) => {
attributes.push(comp.name);
});
}
@ -137,9 +136,9 @@ const createVeturTags = component => {
}
};
const createVeturAttributes = component => {
const createVeturAttributes = (component) => {
if (component.props) {
component.props.forEach(comp => {
component.props.forEach((comp) => {
veturAttributes[component.name.toLowerCase() + `/${comp.name}`] = {
description: comp.description,
type: comp.type
@ -148,17 +147,17 @@ const createVeturAttributes = component => {
}
};
Object.keys(fileModules).forEach(p => {
Object.keys(fileModules).forEach((p) => {
createWebTypes(fileModules[p][p]);
createVeturTags(fileModules[p][p]);
createVeturAttributes(fileModules[p][p]);
});
const webTypesJson = JSON.stringify(webTypes, null, 2);
fs.writeFileSync(path.resolve(distDir, "web-types.json"), webTypesJson);
fs.writeFileSync(path.resolve(distDir, 'web-types.json'), webTypesJson);
const veturTagsJson = JSON.stringify(veturTags, null, 2);
fs.writeFileSync(path.resolve(distDir, "vetur-tags.json"), veturTagsJson);
fs.writeFileSync(path.resolve(distDir, 'vetur-tags.json'), veturTagsJson);
const veturAttributesJson = JSON.stringify(veturAttributes, null, 2);
fs.writeFileSync(path.resolve(distDir, "vetur-attributes.json"), veturAttributesJson);
fs.writeFileSync(path.resolve(distDir, 'vetur-attributes.json'), veturAttributesJson);