mirror of
				https://github.com/Mibew/simple-icons.git
				synced 2025-11-04 04:15:17 +03:00 
			
		
		
		
	Add CI step for ensuring alphabetical order of icons (#2334)
* Add a script for the linting that cannot be accomplished by our other linters Currently this only contains linting for whether our icons are alphabetically sorted * Add our own linting to Travis * Fix Let's Encrypt being incorrectly sorted * Intentionally break sorting to test CI * Revert "Intentionally break sorting to test CI" This reverts commit 55e4070b3c3294cff306fcc138ce247843130c35. * Explain in CONTRIBUTION.md how to sort metadata
This commit is contained in:
		
							parent
							
								
									21b01b56d7
								
							
						
					
					
						commit
						7b69d16efb
					
				@ -8,6 +8,7 @@ jobs:
 | 
			
		||||
        - npm run jsonlint
 | 
			
		||||
        - npm run svglint
 | 
			
		||||
        - npm run wslint
 | 
			
		||||
        - npm run our-lint
 | 
			
		||||
    - name: "Build website"
 | 
			
		||||
      language: ruby
 | 
			
		||||
      rvm: 2.4.1
 | 
			
		||||
 | 
			
		||||
@ -145,6 +145,8 @@ Here is the object for The Movie Database as an example:
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Make sure the icon is added in alphabetical order. If you're in doubt, you can always run `npm run our-lint` - this will tell you if any of the JSON data is in the wrong order.
 | 
			
		||||
 | 
			
		||||
### 7. Create a pull request
 | 
			
		||||
 | 
			
		||||
Once you've completed the previous steps, create a pull request to merge your edits into the *develop* branch.
 | 
			
		||||
 | 
			
		||||
@ -2495,16 +2495,16 @@
 | 
			
		||||
            "hex": "E2231A",
 | 
			
		||||
            "source": "https://www.lenovopartnernetwork.com/us/branding/"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "title": "Letterboxd",
 | 
			
		||||
            "hex": "00D735",
 | 
			
		||||
            "source": "https://letterboxd.com/about/logos/"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "title": "Let’s Encrypt",
 | 
			
		||||
            "hex": "003A70",
 | 
			
		||||
            "source": "https://letsencrypt.org/trademarks/"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "title": "Letterboxd",
 | 
			
		||||
            "hex": "00D735",
 | 
			
		||||
            "source": "https://letterboxd.com/about/logos/"
 | 
			
		||||
        },
 | 
			
		||||
        {
 | 
			
		||||
            "title": "LGTM",
 | 
			
		||||
            "hex": "FFFFFF",
 | 
			
		||||
 | 
			
		||||
@ -28,6 +28,7 @@
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "node scripts/build-package.js",
 | 
			
		||||
    "clean": "rm icons/*.js index.js",
 | 
			
		||||
    "our-lint": "node scripts/lint.js",
 | 
			
		||||
    "jsonlint": "jsonlint _data/simple-icons.json -q -V .jsonlintschema",
 | 
			
		||||
    "svglint": "svglint icons/* --ci",
 | 
			
		||||
    "wslint": "editorconfig-checker -exclude *.svg",
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										43
									
								
								scripts/lint.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								scripts/lint.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,43 @@
 | 
			
		||||
#!/usr/bin/env node
 | 
			
		||||
/**
 | 
			
		||||
 * @fileoverview Lints for the package that can't be implemented in the existing linters (e.g. jsonlint/svglint)
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const { icons } = require("../_data/simple-icons.json");
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Contains our tests so they can be isolated from eachother; I don't think each test is worth its own file
 | 
			
		||||
 * @type {{[k:string]: () => (string|undefined)}}
 | 
			
		||||
 */
 | 
			
		||||
const TESTS = {
 | 
			
		||||
  /** Tests whether our icons are in alphabetical order */
 | 
			
		||||
  alphabetical: function() {
 | 
			
		||||
    const collector = (invalidEntries, icon, index, array) => {
 | 
			
		||||
      if (index > 0) {
 | 
			
		||||
        const prev = array[index - 1];
 | 
			
		||||
        if (icon.title.localeCompare(prev.title) < 0) {
 | 
			
		||||
          invalidEntries.push(icon);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      return invalidEntries;
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const invalids = icons.reduce(collector, []);
 | 
			
		||||
    if (invalids.length) {
 | 
			
		||||
      return `Some icons aren't in alphabetical order:
 | 
			
		||||
        ${invalids.map(icon => icon.title).join(", ")}`;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// execute all tests and log potential errors
 | 
			
		||||
const errors = Object.keys(TESTS)
 | 
			
		||||
  .map(k => TESTS[k]())
 | 
			
		||||
  .filter(Boolean);
 | 
			
		||||
 | 
			
		||||
if (errors.length) {
 | 
			
		||||
  errors.forEach(error => {
 | 
			
		||||
    console.error(`\u001b[31m${error}\u001b[0m`);
 | 
			
		||||
  });
 | 
			
		||||
  process.exit(1);
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user