Skip to content

Commit

Permalink
feat(extras): add lint setup #17678
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoenescu committed Dec 5, 2024
1 parent 2d05cff commit 9780300
Show file tree
Hide file tree
Showing 37 changed files with 639 additions and 591 deletions.
16 changes: 16 additions & 0 deletions extras/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
root: true,

parserOptions: {
sourceType: 'commonjs'
},

extends: [
'eslint:recommended',
'quasar/base'
],

rules: {
'no-unused-vars': [ 'error', { ignoreRestSiblings: true, argsIgnorePattern: '^_' } ]
}
}
1 change: 0 additions & 1 deletion extras/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
/node_modules
.vscode
.postcssrc.js
6 changes: 3 additions & 3 deletions extras/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ roboto-font/update.sh
roboto-font-latin-ext/update.sh
build/
.vscode
.postcssrc.js
postcss.config.cjs
.prettierrc
.prettierrc.json
.eslintrc.cjs
.eslintignore
6 changes: 3 additions & 3 deletions extras/.prettierrc → extras/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"singleQuote": true,
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"bracketSameLine": true,
"singleQuote": true,
"printWidth": 120,
"trailingComma": "none"
}
}
1 change: 0 additions & 1 deletion extras/animate/animate-list.common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module.exports.generalAnimations = [
'bounce',
'flash',
Expand Down
1 change: 0 additions & 1 deletion extras/animate/animate-list.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

module.exports.generalAnimations = [
'bounce',
'flash',
Expand Down
2 changes: 1 addition & 1 deletion extras/bootstrap-icons/index.js

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

121 changes: 62 additions & 59 deletions extras/build/animate.js
Original file line number Diff line number Diff line change
@@ -1,90 +1,93 @@
const packageName = "animate.css";
const packageName = 'animate.css'

// ------------

const { globSync } = require("tinyglobby");
const { copySync } = require("fs-extra");
const { writeFileSync } = require("fs");
const { join, resolve, basename } = require("path");
const { globSync } = require('tinyglobby')
const { copySync } = require('fs-extra')
const { writeFileSync } = require('fs')
const { join, resolve, basename } = require('path')

const dist = resolve(__dirname, "../animate");
const dist = resolve(__dirname, '../animate')

const pkgFolder = resolve(__dirname, `../node_modules/${packageName}/`);
const cssFiles = globSync(pkgFolder + "/source/*/*.css");
const cssNames = new Set();
const pkgFolder = resolve(__dirname, `../node_modules/${ packageName }/`)
const cssFiles = globSync(pkgFolder + '/source/*/*.css')
const cssNames = new Set()

const inAnimations = [];
const outAnimations = [];
const generalAnimations = [];
const inAnimations = []
const outAnimations = []
const generalAnimations = []

function extract(file) {
const name = basename(file).match(/(.*)\.css/)[1];
function extract (file) {
const name = basename(file).match(/(.*)\.css/)[ 1 ]

if (cssNames.has(name)) {
return;
return
}

copySync(file, join(dist, name + ".css"));
cssNames.add(name);
copySync(file, join(dist, name + '.css'))
cssNames.add(name)

if (name.indexOf("In") > -1) {
inAnimations.push(name);
} else if (name.indexOf("Out") > -1) {
outAnimations.push(name);
} else {
generalAnimations.push(name);
if (name.indexOf('In') > -1) {
inAnimations.push(name)
}
else if (name.indexOf('Out') > -1) {
outAnimations.push(name)
}
else {
generalAnimations.push(name)
}
}

function getList(prefix) {
function getList (prefix) {
return `
${prefix}generalAnimations = ${JSON.stringify(generalAnimations, null, 2)}
${ prefix }generalAnimations = ${ JSON.stringify(generalAnimations, null, 2) }
${prefix}inAnimations = ${JSON.stringify(inAnimations, null, 2)}
${ prefix }inAnimations = ${ JSON.stringify(inAnimations, null, 2) }
${prefix}outAnimations = ${JSON.stringify(outAnimations, null, 2)}
`.replace(/"/g, "'");
${ prefix }outAnimations = ${ JSON.stringify(outAnimations, null, 2) }
`.replace(/"/g, "'")
}

if (cssFiles.length === 0) {
console.log("WARNING. Animate.css skipped completely");
} else {
console.log('WARNING. Animate.css skipped completely')
}
else {
cssFiles.forEach((file) => {
extract(file);
});
extract(file)
})

generalAnimations.sort();
inAnimations.sort();
outAnimations.sort();
generalAnimations.sort()
inAnimations.sort()
outAnimations.sort()

copySync(join(pkgFolder, "LICENSE"), join(dist, "LICENSE"));
copySync(join(pkgFolder, 'LICENSE'), join(dist, 'LICENSE'))

const common = getList("module.exports.");
const common = getList('module.exports.')

writeFileSync(join(dist, "animate-list.js"), common, "utf-8");
writeFileSync(join(dist, 'animate-list.js'), common, 'utf-8')
writeFileSync(
join(dist, "animate-list.mjs"),
getList("export const "),
"utf-8",
);
writeFileSync(join(dist, "animate-list.common.js"), common, "utf-8");
join(dist, 'animate-list.mjs'),
getList('export const '),
'utf-8'
)
writeFileSync(join(dist, 'animate-list.common.js'), common, 'utf-8')

writeFileSync(
join(dist, "animate-list.d.ts"),
getList("export type ")
.replace(/\[/g, "")
.replace(/\]/g, ";")
.replace(/\ {2}'/g, " | '")
.replace(/,/g, ""),
"utf-8",
);
join(dist, 'animate-list.d.ts'),
getList('export type ')
.replace(/\[/g, '')
.replace(/\]/g, ';')
.replace(/ {2}'/g, " | '")
.replace(/,/g, ''),
'utf-8'
)
writeFileSync(
join(dist, "animate-list.common.d.ts"),
getList("export type ")
.replace(/\[/g, "")
.replace(/\]/g, ";")
.replace(/\ {2}'/g, " | '")
.replace(/,/g, ""),
"utf-8",
);
join(dist, 'animate-list.common.d.ts'),
getList('export type ')
.replace(/\[/g, '')
.replace(/\]/g, ';')
.replace(/ {2}'/g, " | '")
.replace(/,/g, ''),
'utf-8'
)
}
109 changes: 55 additions & 54 deletions extras/build/bootstrap-icons.js
Original file line number Diff line number Diff line change
@@ -1,102 +1,103 @@
const packageName = "bootstrap-icons";
const distName = "bootstrap-icons";
const iconSetName = "Bootstrap";
const prefix = "bi";
const packageName = 'bootstrap-icons'
const distName = 'bootstrap-icons'
const iconSetName = 'Bootstrap'
const prefix = 'bi'

// ------------

const { globSync } = require("tinyglobby");
const { copySync } = require("fs-extra");
const { writeFileSync } = require("fs");
const { resolve, join } = require("path");
const { globSync } = require('tinyglobby')
const { copySync } = require('fs-extra')
const { writeFileSync } = require('fs')
const { resolve, join } = require('path')

const skipped = [];
const distFolder = resolve(__dirname, "../bootstrap-icons");
const skipped = []
const distFolder = resolve(__dirname, '../bootstrap-icons')
const {
defaultNameMapper,
extract,
writeExports,
copyCssFile,
} = require("./utils");
copyCssFile
} = require('./utils')

const svgFolder = resolve(__dirname, `../node_modules/${packageName}/icons/`);
const svgFiles = globSync(svgFolder + "/*.svg");
let iconNames = new Set();
const svgFolder = resolve(__dirname, `../node_modules/${ packageName }/icons/`)
const svgFiles = globSync(svgFolder + '/*.svg')
let iconNames = new Set()

const svgExports = [];
const typeExports = [];
const svgExports = []
const typeExports = []

svgFiles.forEach((file) => {
const name = defaultNameMapper(file, prefix);
const name = defaultNameMapper(file, prefix)

if (iconNames.has(name)) {
return;
return
}

try {
const { svgDef, typeDef } = extract(file, name);
svgExports.push(svgDef);
typeExports.push(typeDef);

iconNames.add(name);
} catch (err) {
console.error(err);
skipped.push(name);
const { svgDef, typeDef } = extract(file, name)
svgExports.push(svgDef)
typeExports.push(typeDef)

iconNames.add(name)
}
catch (err) {
console.error(err)
skipped.push(name)
}
});
})

iconNames = [...iconNames];
iconNames = [ ...iconNames ]
svgExports.sort((a, b) => {
return ("" + a).localeCompare(b);
});
return ('' + a).localeCompare(b)
})
typeExports.sort((a, b) => {
return ("" + a).localeCompare(b);
});
return ('' + a).localeCompare(b)
})
iconNames.sort((a, b) => {
return ("" + a).localeCompare(b);
});
return ('' + a).localeCompare(b)
})

writeExports(
iconSetName,
packageName,
distFolder,
svgExports,
typeExports,
skipped,
);
skipped
)

// then update webfont files

const webfont = ["bootstrap-icons.woff", "bootstrap-icons.woff2"];
const webfont = [ 'bootstrap-icons.woff', 'bootstrap-icons.woff2' ]

webfont.forEach((file) => {
copySync(
resolve(__dirname, `../node_modules/${packageName}/font/fonts/${file}`),
resolve(__dirname, `../bootstrap-icons/${file}`),
);
});
resolve(__dirname, `../node_modules/${ packageName }/font/fonts/${ file }`),
resolve(__dirname, `../bootstrap-icons/${ file }`)
)
})

copyCssFile({
from: resolve(
__dirname,
`../node_modules/${packageName}/font/bootstrap-icons.css`,
`../node_modules/${ packageName }/font/bootstrap-icons.css`
),
to: resolve(__dirname, "../bootstrap-icons/bootstrap-icons.css"),
to: resolve(__dirname, '../bootstrap-icons/bootstrap-icons.css'),
replaceFn: (content) => {
return content.replace(
/src:[^;]+;/,
'src: url("./bootstrap-icons.woff2") format("woff2"), url("./bootstrap-icons.woff") format("woff");',
);
},
});
'src: url("./bootstrap-icons.woff2") format("woff2"), url("./bootstrap-icons.woff") format("woff");'
)
}
})

copySync(
resolve(__dirname, `../node_modules/${packageName}/LICENSE`),
resolve(__dirname, "../bootstrap-icons/LICENSE"),
);
resolve(__dirname, `../node_modules/${ packageName }/LICENSE`),
resolve(__dirname, '../bootstrap-icons/LICENSE')
)

// write the JSON file
const file = resolve(__dirname, join("..", distName, "icons.json"));
writeFileSync(file, JSON.stringify([...iconNames].sort(), null, 2), "utf-8");
const file = resolve(__dirname, join('..', distName, 'icons.json'))
writeFileSync(file, JSON.stringify([ ...iconNames ].sort(), null, 2), 'utf-8')

console.log(`${distName} done with ${iconNames.length} icons`);
console.log(`${ distName } done with ${ iconNames.length } icons`)
Loading

0 comments on commit 9780300

Please sign in to comment.