From cc9a3cd49e08358bad66f6dd40851f3190443393 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Tue, 18 Oct 2016 10:03:58 +0200 Subject: [PATCH] Refactor project * Replace eslint, jscs with xo; * Remove `index.js`; * Remove coverage tests; * Remove superfluous files; * Remove unneeded Node targets from Travis; * Update dev-dependencies. --- .editorconfig | 8 +---- .eslintignore | 4 --- .eslintrc | 6 ---- .gitignore | 1 - .jscs.json | 35 ------------------ .remarkrc | 13 ------- .travis.yml | 5 +-- example.js | 8 ----- history.md | 6 ---- index.js | 17 --------- package.json | 53 +++++++++++++-------------- readme.md | 32 +++-------------- script/build.js | 95 +++++++++++++++++++------------------------------ test.js | 56 +++++++++++------------------ 14 files changed, 88 insertions(+), 251 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc delete mode 100644 .jscs.json delete mode 100644 .remarkrc delete mode 100644 example.js delete mode 100644 history.md delete mode 100644 index.js diff --git a/.editorconfig b/.editorconfig index ad211fb..c6c8b36 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,14 +2,8 @@ root = true [*] indent_style = space -indent_size = 4 +indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true - -[*.{json,remarkrc,eslintrc,sh}] -indent_size = 2 - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index d8e09e8..0000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -coverage/ -example.js -iso-639-3.js -iso-639-3.min.js diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 4426f37..0000000 --- a/.eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "eslint:recommended", - "rules": { - "quotes": [2, "single"] - } -} diff --git a/.gitignore b/.gitignore index 0760894..cbcf9aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .DS_Store *.log -coverage/ node_modules/ iso-639-3.js iso-639-3.min.js diff --git a/.jscs.json b/.jscs.json deleted file mode 100644 index f9e96c9..0000000 --- a/.jscs.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "excludeFiles": [ - "coverage/", - "node_modules/", - "iso-639-3.js", - "iso-639-3.min.js" - ], - "preset": "yandex", - "requireQuotedKeysInObjects": true, - "disallowQuotedKeysInObjects": false, - "maximumLineLength": { - "value": 79, - "allExcept": [ - "regex", - "urlComments" - ] - }, - "jsDoc": { - "checkAnnotations": "jsdoc3", - "checkParamExistence": true, - "checkParamNames": true, - "checkRedundantAccess": true, - "checkRedundantParams": true, - "checkRedundantReturns": true, - "checkReturnTypes": true, - "checkTypes": "strictNativeCase", - "enforceExistence": true, - "requireHyphenBeforeDescription": true, - "requireNewlineAfterDescription": true, - "requireParamDescription": true, - "requireParamTypes": true, - "requireReturnDescription": true, - "requireReturnTypes": true - } -} diff --git a/.remarkrc b/.remarkrc deleted file mode 100644 index ddb54b6..0000000 --- a/.remarkrc +++ /dev/null @@ -1,13 +0,0 @@ -{ - "output": true, - "plugins": [ - "lint", - "github", - "comment-config", - "usage", - "validate-links" - ], - "settings": { - "bullet": "*" - } -} diff --git a/.travis.yml b/.travis.yml index 914b3bf..dd629ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,9 @@ language: node_js node_js: -- '0.10' -- '0.11' -- '0.12' - '4.0' - '5.0' +- '6.0' sudo: false -after_script: npm install codecov.io && cat ./coverage/lcov.info | codecov deploy: - provider: npm email: tituswormer@gmail.com diff --git a/example.js b/example.js deleted file mode 100644 index d83d8eb..0000000 --- a/example.js +++ /dev/null @@ -1,8 +0,0 @@ -// Dependencies: -var iso6393 = require('./index.js'); - -// Inspecting some values yields: -console.log('js', require('util').inspect(iso6393.slice(1820, 1825))); - -// And the `length` computes to: -console.log('js', String(iso6393.length)); diff --git a/history.md b/history.md deleted file mode 100644 index 62d69f8..0000000 --- a/history.md +++ /dev/null @@ -1,6 +0,0 @@ - - - - -1.0.0 / 2016-03-05 -================== diff --git a/index.js b/index.js deleted file mode 100644 index 9ec2afc..0000000 --- a/index.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @author Titus Wormer - * @copyright 2016 Titus Wormer - * @license MIT - * @module iso-639-3 - * @fileoverview ISO-639-3 codes in an accessible format. - */ - -'use strict'; - -/* eslint-env commonjs */ - -/* - * Expose. - */ - -module.exports = require('./index.json'); diff --git a/package.json b/package.json index e983c03..463be1b 100644 --- a/package.json +++ b/package.json @@ -13,49 +13,46 @@ "name", "information" ], - "dependencies": {}, - "files": [ - "index.js", - "index.json" - ], - "repository": { - "type": "git", - "url": "https://github.com/wooorm/iso-639-3.git" - }, + "repository": "https://github.com/wooorm/iso-639-3", "bugs": "https://github.com/wooorm/iso-639-3/issues", "author": "Titus Wormer (http://wooorm.com)", "contributors": [ "Titus Wormer (http://wooorm.com)" ], + "main": "index.json", + "files": [ + "index.json" + ], + "dependencies": {}, "devDependencies": { "browserify": "^13.0.0", "concat-stream": "^1.5.1", - "d3-dsv": "^0.3.0", - "eslint": "^2.0.0", + "d3-dsv": "^1.0.0", "esmangle": "^1.0.1", - "istanbul": "^0.4.0", - "jscs": "^2.0.0", - "jscs-jsdoc": "^1.0.0", - "remark": "^4.0.0", - "remark-comment-config": "^3.0.0", - "remark-github": "^4.0.1", - "remark-lint": "^3.0.0", - "remark-usage": "^3.0.0", - "remark-validate-links": "^3.0.0", + "remark-cli": "^2.0.0", + "remark-preset-wooorm": "^1.0.0", "tape": "^4.4.0", - "unzip": "^0.1.11" + "unzip": "^0.1.11", + "xo": "^0.17.0" }, "scripts": { - "build-crawl": "./script/build.js", + "build-crawl": "node script/build.js", "build-md": "remark . --quiet --frail", - "build-bundle": "browserify index.js --bare -s iso6393 > iso-639-3.js", + "build-bundle": "browserify index.json --bare -s iso6393 > iso-639-3.js", "build-mangle": "esmangle iso-639-3.js > iso-639-3.min.js", "build": "npm run build-crawl && npm run build-md && npm run build-bundle && npm run build-mangle", - "lint-api": "eslint .", - "lint-style": "jscs --reporter inline .", - "lint": "npm run lint-api && npm run lint-style", + "lint": "xo", "test-api": "node test.js", - "test-coverage": "istanbul cover test.js", - "test": "npm run build && npm run lint && npm run test-coverage" + "test": "npm run build && npm run lint && npm run test-api" + }, + "xo": { + "space": true, + "ignores": [ + "iso-639-3.js" + ] + }, + "remarkConfig": { + "output": true, + "presets": "wooorm" } } diff --git a/readme.md b/readme.md index 3fba054..dda7f05 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# iso-639-3 [![Build Status][build-badge]][build-page] [![Coverage Status][coverage-badge]][coverage-page] +# iso-639-3 [![Build Status][build-badge]][build-page] [ISO 639-3][iso] codes in an accessible format, all of them. @@ -10,20 +10,17 @@ npm install iso-639-3 ``` -**iso-639-3** is also available as an AMD, CommonJS, and globals -module, [uncompressed and compressed][releases]. - ## Usage -Dependencies: - ```javascript var iso6393 = require('iso-639-3'); + +var subset = iso6393.slice(1820, 1825)); ``` -Inspecting some values yields: +Yields: -```js +```javascript [ { name: 'Ende', type: 'living', scope: 'individual', @@ -61,12 +58,6 @@ Inspecting some values yields: iso6391: null } ] ``` -And the `length` computes to: - -```js -7847 -``` - ## API ### `iso6393` @@ -91,23 +82,18 @@ And the `length` computes to: * `'living'` — Still spoken languages, for example, `Zacatlán-Ahuacatlán-Tepetzintla Nahuatl` (`nhi`); - * `'historical'` — Distinct from any modern languages that are descended from it, for example, `Old Frisian` (`ofs`); - * `'extinct'` — Language which went extinct in recent time, for example, `Barababaraba` (`rbp`); - * `'ancient'` — Language which went extinct in ancient times, for example, `Gothic` (`got`); - * `'constructed'` — Artificial languages (but not programming languages), for example, `Esperanto` (`epo`); - * `'special'` — Non-language codes, for example, `Undetermined` (`und`). @@ -117,11 +103,9 @@ And the `length` computes to: * `'special'` — Non-language codes, for example, `Undetermined` (`und`); - * `'macrolanguage'` — One-to-many grouping of languages, because older ISO 639s, included them, for example, `Arabic` (`ara`); - * `'language'` — Normal, single language, for example, `English` (`eng`). @@ -135,14 +119,8 @@ And the `length` computes to: [build-page]: https://travis-ci.org/wooorm/iso-639-3 -[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/iso-639-3.svg - -[coverage-page]: https://codecov.io/github/wooorm/iso-639-3?branch=master - [npm]: https://docs.npmjs.com/cli/install -[releases]: https://github.com/wooorm/iso-639-3/releases - [license]: LICENSE [author]: http://wooorm.com diff --git a/script/build.js b/script/build.js index 027b164..d87d150 100755 --- a/script/build.js +++ b/script/build.js @@ -1,20 +1,6 @@ -#!/usr/bin/env node -/** - * @author Titus Wormer - * @copyright 2016 Titus Wormer - * @license MIT - * @module html-encodings:script - * @fileoverview Crawl the list of encodings. - */ - 'use strict'; -/* eslint-env node */ - -/* - * Dependencies. - */ - +/* Dependencies. */ var fs = require('fs'); var path = require('path'); var http = require('http'); @@ -22,61 +8,52 @@ var concat = require('concat-stream'); var unzip = require('unzip'); var dsv = require('d3-dsv'); -/* - * Constants. - */ - +/* Constants. */ var ID = '20160115'; var INPUT = 'http://www-01.sil.org/iso639-3/' + 'iso-639-3_Code_Tables_' + ID + '.zip'; var ENTRY = 'iso-639-3_' + ID + '.tab'; var OUTPUT = path.join(__dirname, '..', 'index.json'); -/* - * Constants. - */ - +/* Constants. */ var SCOPES = { - 'I': 'individual', - 'M': 'macrolanguage', - 'S': 'special' + I: 'individual', + M: 'macrolanguage', + S: 'special' }; var TYPES = { - 'A': 'ancient', - 'C': 'constructed', - 'E': 'extinct', - 'H': 'historical', - 'L': 'living', - 'S': 'special' + A: 'ancient', + C: 'constructed', + E: 'extinct', + H: 'historical', + L: 'living', + S: 'special' }; -/* - * Core. - */ - +/* Core. */ http.request(INPUT, function (response) { - response.pipe(unzip.Parse()).on('entry', function (entry) { - if (path.basename(entry.path) !== ENTRY) { - entry.autodrain(); - return; - } - - entry.pipe(concat(function (body) { - var data = dsv.tsvParse(body.toString()).map(function (language) { - return { - 'name': language.Ref_Name || null, - 'type': TYPES[language.Language_Type], - 'scope': SCOPES[language.Scope], - 'iso6393': language['Id'], // There’s a `` - // in there, I don’t know why, but meh. - 'iso6392B': language.Part2B || null, - 'iso6392T': language.Part2T || null, - 'iso6391': language.Part1 || null - }; - }); - - fs.writeFile(OUTPUT, JSON.stringify(data, 0, 2) + '\n'); - })); - }); + response.pipe(new unzip.Parse()).on('entry', function (entry) { + if (path.basename(entry.path) !== ENTRY) { + entry.autodrain(); + return; + } + + entry.pipe(concat(function (body) { + var data = dsv.tsvParse(body.toString()).map(function (language) { + return { + name: language.Ref_Name || null, + type: TYPES[language.Language_Type], + scope: SCOPES[language.Scope], + iso6393: language['Id'], // There’s a `` + // in there, I don’t know why, but meh. + iso6392B: language.Part2B || null, + iso6392T: language.Part2T || null, + iso6391: language.Part1 || null + }; + }); + + fs.writeFile(OUTPUT, JSON.stringify(data, 0, 2) + '\n'); + })); + }); }).end(); diff --git a/test.js b/test.js index cdc87e0..eaa4018 100644 --- a/test.js +++ b/test.js @@ -1,42 +1,26 @@ -/** - * @author Titus Wormer - * @copyright 2016 Titus Wormer - * @license MIT - * @module iso-639-3 - * @fileoverview Test suite for `iso-639-3`. - */ - 'use strict'; -/* eslint-env node */ - -/* - * Module dependencies. - */ - +/* dependencies. */ var test = require('tape'); -var iso6393 = require('./index.js'); - -/* - * Tests. - */ +var iso6393 = require('./'); +/* Tests. */ test('iso6393', function (t) { - t.plan(8); - - t.ok(Array.isArray(iso6393), 'should be an `array`'); - - iso6393.forEach(function (language) { - if (language.iso6393 !== 'eng') { - return; - } - - t.equal(language.iso6393, 'eng', 'should have a 639-3 code'); - t.equal(language.iso6392B, 'eng', 'should have a 639-2B code'); - t.equal(language.iso6392T, 'eng', 'should have a 639-2T code'); - t.equal(language.iso6391, 'en', 'should have a 639-1 code'); - t.equal(language.scope, 'individual', 'should have a scope'); - t.equal(language.type, 'living', 'should have a type'); - t.equal(language.name, 'English', 'should have a name'); - }); + t.plan(8); + + t.ok(Array.isArray(iso6393), 'should be an `array`'); + + iso6393.forEach(function (language) { + if (language.iso6393 !== 'eng') { + return; + } + + t.equal(language.iso6393, 'eng', 'should have a 639-3 code'); + t.equal(language.iso6392B, 'eng', 'should have a 639-2B code'); + t.equal(language.iso6392T, 'eng', 'should have a 639-2T code'); + t.equal(language.iso6391, 'en', 'should have a 639-1 code'); + t.equal(language.scope, 'individual', 'should have a scope'); + t.equal(language.type, 'living', 'should have a type'); + t.equal(language.name, 'English', 'should have a name'); + }); });