ilib-lint-apple
raw JSON → 1.0.1 verified Fri May 01 auth: no javascript
A plugin for ilib-lint that validates Apple platform string parameters, specifically ensuring Swift string interpolation placeholders like \(name) are correctly preserved in translated targets. Version 1.0.1 is current, with node.js 14+ and ESM support required. Unlike generic string linters, it targets Apple ecosystem files and provides a dedicated 'resource-swift-params' rule along with an 'apple' ruleset for easy integration into XLIFF file type checking.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/ilib-lint-apple/index.js from /path/to/project/ilib-lint-config.json not supported. ↓
cause Using require() on an ESM-only module; ilib-lint-apple is ESM, but project may use CommonJS.
fix
Change project to ESM (type: 'module' in package.json) or use dynamic import(). Ensure node version >=14.
error Parsing error: The 'resource-swift-params' rule is not configured. ↓
cause Plugin loaded but rule set not enabled for the file type.
fix
Add 'ruleset': ['apple'] under the appropriate filetype in ilib-lint-config.json.
error TypeError: Cannot read properties of undefined (reading 'swiftParams') ↓
cause Corrupted or mismatched plugin version. Possibly the plugin not properly loaded or incompatible with ilib-lint version.
fix
Reinstall ilib-lint-apple and ensure ilib-lint is up-to-date. Run npm install --save-dev ilib-lint-apple@latest.
error Error: Plugin 'ilib-lint-apple' not found. Did you install it? ↓
cause Plugin missing from node_modules or not listed in plugins array.
fix
Run npm install --save-dev ilib-lint-apple and verify the package is in package.json devDependencies.
Warnings
gotcha Plugin requires node.js 14+ and ESM module system. CJS require() will not work. ↓
fix Use import syntax or set type: 'module' in package.json. Alternatively, upgrade to Node 14+.
gotcha The rule 'resource-swift-params' only checks for Swift-style interpolation \(param). Other placeholders (e.g., %@) are not validated. ↓
fix For Objective-C format specifiers, use additional rules from other plugins or configure ilib-lint's built-in format checking.
gotcha Plugin may produce false positives for strings containing literal \(... ) that are not Swift interpolation (e.g., in code comments). ↓
fix Ignore false positives via ilib-lint's inline suppression comments like // eslint-disable-next-line or resource-level ignore flags.
Install
npm install ilib-lint-apple yarn add ilib-lint-apple pnpm add ilib-lint-apple Imports
- plugin
import plugin from 'ilib-lint-apple' - ResourceSwiftParamsRule wrong
import ResourceSwiftParamsRule from 'ilib-lint-apple'correctimport { ResourceSwiftParamsRule } from 'ilib-lint-apple' - AppleRuleSet
import { AppleRuleSet } from 'ilib-lint-apple'
Quickstart
// Install: npm install --save-dev ilib-lint-apple
// In ilib-lint-config.json:
{
"plugins": ["ilib-lint-apple"],
"filetypes": {
"xliff": {
"ruleset": ["apple"]
}
}
}
// Run: npx ilib-lint check -f xliff translations.xliff