{"size": 969, "ext": "js", "max_stars_repo_path": "lint-staged.config.js", "max_stars_repo_name": "wonedays/titanium_mobile", "max_stars_repo_stars_event_min_datetime": "2015-01-02T09:17:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-03T16:38:01.000Z", "max_issues_repo_path": "lint-staged.config.js", "max_issues_repo_name": "wonedays/titanium_mobile", "max_issues_repo_issues_event_min_datetime": "2015-01-05T04:14:17.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-03T15:30:26.000Z", "max_forks_repo_path": "lint-staged.config.js", "max_forks_repo_name": "miniman42/titanium_mobile", "max_forks_repo_forks_event_min_datetime": "2015-01-02T08:16:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-25T14:16:12.000Z"}
{"max_stars_count": 1191, "max_issues_count": 5813, "max_forks_count": 615, "avg_line_length": 24.8461538462, "max_line_length": 116, "alphanum_fraction": 0.6099071207}
'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'
};
