forked from tidev/titanium-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lint-staged.config.js
38 lines (34 loc) · 969 Bytes
/
lint-staged.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const { ESLint } = require('eslint');
const eslint = new ESLint();
const asyncFilter = async (arr, predicate) => {
return arr.reduce(async (acc, value) => {
const result = await predicate(value);
return [ ...await acc, ...(result ? [ value ] : []) ];
}, []);
};
module.exports = {
'android/**/*.java': filenames => {
return `node ./build/scons gradlew checkJavaStyle --args --console plain -PchangedFiles='${filenames.join(',')}'`;
},
'iphone/**/*.{m,h}': [
'npx clang-format -style=file -i'
],
'iphone/Classes/**/*.swift': [
'swiftlint autocorrect'
],
'iphone/TitaniumKit/TitaniumKit/Sources/API/TopTiModule.m': [
'npm run ios-sanity-check --'
],
'*.js': async files => {
const filtered = await asyncFilter(files, async file => {
try {
return !await eslint.isPathIgnored(file);
} catch (e) {
return false;
}
});
return `eslint ${filtered.join(' ')}`;
},
'package-lock.json': 'npm run lint:lockfile'
};