JSPM

textlint-rule-use-si-units

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 369
  • Score
    100M100P100Q101438F
  • License ISC

Textlint rule to always use International System of Units (SI).

Package Exports

  • textlint-rule-use-si-units
  • textlint-rule-use-si-units/lib/use-si-units.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (textlint-rule-use-si-units) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

textlint-rule-use-si-units npm

Use SI Units

sample texts

  1. SI単位系の単位以外の使用を禁止します
  2. SI単位系の単位とは以下のいずれかの単位、またはそれらの組み合わせ(組立単位)を指します
    • SI基本単位(s, m, kg, A, K, mol, cd)
    • 固有の名称をもつSI組立単位(rad, sr, Hz, N, Pa, Jなど22種)
  3. 以下の文字は単体では単位となることができませんが、単位と組み合わせて使用できます
    • SI接頭語(M, G, k, mなど20種)
    • SI単位を組み合わせる際に使用される記号(, ^, -, ·, ・, ・, (, ))
    • 次元を表すための数字(e.g. m^2)
  4. 以下のSI併用単位も許容します
    • SIに属さないが、SIと併用される単位(min, h, d, au, °, ′, ″など16種)
    • これらはrestrictNonSIUnitsオプションで禁止できます

指摘の対象とする文字列

  • 数値 + 単位の組み合わせを検出します
    • e.g.「10 m」「273 K」「123 kgm^2/s^3」
    • 数値と単位の間には半角スペースが入っている必要があります
      • IDや型番のような、単位と関係ない文字列を誤検出するのを防ぐためです

指摘の対象としない文字列

  • 日本語の単位や助数詞
    • e.g.「枚」「本」「糎」「㌢㍍」
  • 小数点や記号入りの数値
    • e.g.「2.56 m/s」「1.1e-10 m」
    • ただし、小数点・記号より後にも数字があればその部分を検出します
  • LaTeX等で数値と単位の間に半角スペース以外を使用しているもの
    • e.g.「10\,m」「\SI{123}{kgm^2/s^3}」「$123\ \mathrm{kgm^2/s^3}$

Install

Install with npm:

npm install textlint-rule-use-si-units

Usage

Via .textlintrc(Recommended)

{
    "rules": {
        "use-si-units": true
    }
}

Via CLI

textlint --rule use-si-units README.md

Options

  • allowedUnits
    • この配列にある文字列には、SI単位系に従っていなくとも警告を出しません
  • restrictNonSIUnits
    • false (default): SI併用単位も使用できます
    • true: SI併用単位の使用を禁止し、SIに属する単位のみ認めます
{
    "rules": {
        "use-si-units": {
            "allowedUnits": ["Å"],
            "restrictNonSIUnits": true
        }
    }
}

Build

Builds source codes for publish to the lib folder. You can write ES2015+ source codes in src/ folder.

npm run build

Tests

Run test code in test folder. Test textlint rule by textlint-tester.

npm test

License

ISC © kn1cht