Revision 796991a1aaca3b4c0ea95b308253a1cc58f4ba2a authored by Boris Sekachev on 17 January 2022, 08:13:58 UTC, committed by GitHub on 17 January 2022, 08:13:58 UTC
* Added intelligent paste labels function, added notification when remove labels from raw editor

* Adjusted raw tab behaviour

* Fixed issue with selection

* Updated version and changelog, removed previous implementation

* Removed outdated comment

* Additional checks on the server

* Added check for default boolean attr

* Updated version

* Conditionally show lost labels/attributes

* Remove labels only when create

Co-authored-by: Nikita Manovich <nikita.manovich@intel.com>
1 parent c77d956
Raw File
lint-staged.config.js
// lint-staged.config.js

const micromatch = require('micromatch');

function containsInPath(pattern, list) {
    return list.filter((item) => micromatch.contains(item, pattern));
}

function makePattern(extension) {
    return `**/*.${extension}`;
}

module.exports = (stagedFiles) => {
    const eslintExtensions = ['ts', 'tsx', 'js'].map(makePattern);
    const eslintFiles = micromatch(stagedFiles, eslintExtensions);

    const cvatData = containsInPath('/cvat-data/', eslintFiles);
    const cvatCore = containsInPath('/cvat-core/', eslintFiles);
    const cvatCanvas = containsInPath('/cvat-canvas/', eslintFiles);
    const cvatCanvas3d = containsInPath('/cvat-canvas3d/', eslintFiles);
    const cvatUI = containsInPath('/cvat-ui/', eslintFiles);

    const mapping = {};
    const commands = [];
    mapping['npm run precommit:cvat-ui -- '] = cvatUI.join(' ');
    mapping['npm run precommit:cvat-data -- '] = cvatData.join(' ');
    mapping['npm run precommit:cvat-core -- '] = cvatCore.join(' ');
    mapping['npm run precommit:cvat-canvas -- '] = cvatCanvas.join(' ');
    mapping['npm run precommit:cvat-canvas3d -- '] = cvatCanvas3d.join(' ');

    for (const command of Object.keys(mapping)) {
        const files = mapping[command];
        if (files.length) {
            commands.push(`${command} ${files}`);
        }
    }

    return commands;
};
back to top