mirror of
https://ghproxy.net/https://github.com/elementor/elementor-icons.git
synced 2025-10-04 21:38:18 +08:00
Add ESLint Support
This commit is contained in:
parent
ecc1989d98
commit
6d52fa684f
7 changed files with 3757 additions and 37 deletions
1
.eslintignore
Normal file
1
.eslintignore
Normal file
|
@ -0,0 +1 @@
|
|||
css
|
20
.eslintrc.js
Normal file
20
.eslintrc.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
module.exports = {
|
||||
extends: [
|
||||
'plugin:@wordpress/eslint-plugin/recommended-with-formatting',
|
||||
],
|
||||
plugins: [],
|
||||
globals: {
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 2017,
|
||||
requireConfigFile: false,
|
||||
sourceType: 'module',
|
||||
},
|
||||
rules: {
|
||||
},
|
||||
settings: {
|
||||
jsdoc: {
|
||||
mode: 'typescript',
|
||||
},
|
||||
},
|
||||
};
|
3696
package-lock.json
generated
3696
package-lock.json
generated
File diff suppressed because it is too large
Load diff
13
package.json
13
package.json
|
@ -5,20 +5,23 @@
|
|||
"author": "Elementor",
|
||||
"homepage": "https://elementor.com/",
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"node": ">=16.0.0"
|
||||
},
|
||||
"files": [
|
||||
"css/**/*"
|
||||
],
|
||||
"css/**/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "npm run sass && npm run postcss && npm run generate-svg-icons-json",
|
||||
"generate-svg-icons-json": "node scripts/svgIconsJsonGenerator.mjs",
|
||||
"postcss": "node scripts/postcss.mjs",
|
||||
"sass": "node scripts/sass.mjs",
|
||||
"prepare": "npm run build"
|
||||
"prepare": "npm run build",
|
||||
"lint": "eslint . --ext js,mjs"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@wordpress/eslint-plugin": "^12.8.0",
|
||||
"cssnano": "^5.1.12",
|
||||
"eslint": "^8.20.0",
|
||||
"postcss": "^8.4.14",
|
||||
"sass": "^1.53.0"
|
||||
}
|
||||
|
|
|
@ -2,14 +2,14 @@ import { promises as fs } from 'fs';
|
|||
import postcss from 'postcss';
|
||||
import cssNano from 'cssnano';
|
||||
|
||||
const postCss = async (cssFilePath, outputFilePath) => {
|
||||
const css = await fs.readFile(cssFilePath);
|
||||
const result = await postcss([cssNano])
|
||||
.process(css, { from: cssFilePath, to: outputFilePath })
|
||||
await fs.writeFile(outputFilePath, result.css);
|
||||
if ( result.map ) {
|
||||
await fs.writeFile(outputFilePath, result.map);
|
||||
}
|
||||
const postCss = async ( cssFilePath, outputFilePath ) => {
|
||||
const css = await fs.readFile( cssFilePath );
|
||||
const result = await postcss( [ cssNano ] )
|
||||
.process( css, { from: cssFilePath, to: outputFilePath } );
|
||||
await fs.writeFile( outputFilePath, result.css );
|
||||
if ( result.map ) {
|
||||
await fs.writeFile( outputFilePath, result.map );
|
||||
}
|
||||
};
|
||||
|
||||
await postCss('css/elementor-icons.css', 'css/elementor-icons.min.css');
|
||||
await postCss( 'css/elementor-icons.css', 'css/elementor-icons.min.css' );
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import { promises as fs, constants } from 'fs';
|
||||
import { promises as fs } from 'fs';
|
||||
import sass from 'sass';
|
||||
|
||||
const compileSass = async (scssFilePath, resultsDir, cssFileName) => {
|
||||
const renderResult = sass.compile(scssFilePath);
|
||||
const compileSass = async ( scssFilePath, resultsDir, cssFileName ) => {
|
||||
const renderResult = sass.compile( scssFilePath );
|
||||
|
||||
try {
|
||||
await fs.access(resultsDir);
|
||||
} catch (e) {
|
||||
await fs.mkdir(resultsDir);
|
||||
}
|
||||
try {
|
||||
await fs.access( resultsDir );
|
||||
} catch ( e ) {
|
||||
await fs.mkdir( resultsDir );
|
||||
}
|
||||
|
||||
await fs.writeFile(`${resultsDir}/${cssFileName}`, renderResult.css);
|
||||
await fs.writeFile( `${ resultsDir }/${ cssFileName }`, renderResult.css );
|
||||
};
|
||||
|
||||
await compileSass('scss/elementor-icons.scss', 'css', 'elementor-icons.css');
|
||||
await compileSass( 'scss/elementor-icons.scss', 'css', 'elementor-icons.css' );
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
import { promises as fs } from 'fs';
|
||||
|
||||
const generateSvgIconsJson = async (configJsonPath, svgIconsJsonPath) => {
|
||||
const configJsonContent = JSON.parse( await fs.readFile( configJsonPath ) ),
|
||||
svgIconsJsonContent = {};
|
||||
const generateSvgIconsJson = async ( configJsonPath, svgIconsJsonPath ) => {
|
||||
const configJsonContent = JSON.parse( await fs.readFile( configJsonPath ) ),
|
||||
svgIconsJsonContent = {};
|
||||
|
||||
configJsonContent.glyphs.forEach( ( obj ) => {
|
||||
// Currently there are no 'height' values in the config file.
|
||||
if ( ! obj.svg.height ) {
|
||||
obj.svg.height = obj.svg.width;
|
||||
}
|
||||
configJsonContent.glyphs.forEach( ( obj ) => {
|
||||
// Currently there are no 'height' values in the config file.
|
||||
if ( ! obj.svg.height ) {
|
||||
obj.svg.height = obj.svg.width;
|
||||
}
|
||||
|
||||
svgIconsJsonContent[ obj.css ] = obj.svg;
|
||||
} );
|
||||
svgIconsJsonContent[ obj.css ] = obj.svg;
|
||||
} );
|
||||
|
||||
fs.writeFile( svgIconsJsonPath, JSON.stringify( svgIconsJsonContent ) );
|
||||
}
|
||||
fs.writeFile( svgIconsJsonPath, JSON.stringify( svgIconsJsonContent ) );
|
||||
};
|
||||
|
||||
await generateSvgIconsJson('config.json', 'eicons.json');
|
||||
await generateSvgIconsJson( 'config.json', 'eicons.json' );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue