Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

es code standards e3 e5 e6 all have warning, many files #6579

Closed
shaynababe opened this issue Apr 11, 2023 · 4 comments
Closed

es code standards e3 e5 e6 all have warning, many files #6579

shaynababe opened this issue Apr 11, 2023 · 4 comments
Labels
invalid duplicate or incorrectly filed source:community Community contribution or request type:maintenance tests, chores, or project maintenance
Milestone

Comments

@shaynababe
Copy link

shaynababe commented Apr 11, 2023

Im having to update the code to bundle it via vite or rollup
here is a example es6, es5, es3 api time TimeContext.js
TimeContext.js.txt
please eslint the code to something to typescript or ES?

es6

74 21 + "an active clock." Misleading line break before '+'; readers may interpret this as an expression boundary.
139 13 || (bounds.end === undefined) Misleading line break before '||'; readers may interpret this as an expression boundary.
140 13 || isNaN(bounds.start) Misleading line break before '||'; readers may interpret this as an expression boundary.
141 13 || isNaN(bounds.end) Misleading line break before '||'; readers may interpret this as an expression boundary.
205 13 || (offsets.end === undefined) Misleading line break before '||'; readers may interpret this as an expression boundary.
206 13 || isNaN(offsets.start) Misleading line break before '||'; readers may interpret this as an expression boundary.
207 13 || isNaN(offsets.end) Misleading line break before '||'; readers may interpret this as an expression boundary.

es5

23 1 import EventEmitter from 'EventEmitter'; 'import' is only available in ES6 (use 'esversion: 6').
38 1 class TimeContext extends EventEmitter { 'class' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
74 21 + "an active clock." Misleading line break before '+'; readers may interpret this as an expression boundary.
78 13 let timeSystem; 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
139 13 || (bounds.end === undefined) Misleading line break before '||'; readers may interpret this as an expression boundary.
140 13 || isNaN(bounds.start) Misleading line break before '||'; readers may interpret this as an expression boundary.
141 13 || isNaN(bounds.end) Misleading line break before '||'; readers may interpret this as an expression boundary.
173 13 const validationResult = this.validateBounds(newBounds); 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
205 13 || (offsets.end === undefined) Misleading line break before '||'; readers may interpret this as an expression boundary.
206 13 || isNaN(offsets.start) Misleading line break before '||'; readers may interpret this as an expression boundary.
207 13 || isNaN(offsets.end) Misleading line break before '||'; readers may interpret this as an expression boundary.
258 13 const validationResult = this.validateOffsets(offsets); 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
265 13 const currentValue = this.activeClock.currentValue(); 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
266 13 const newBounds = { 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
311 13 let clock; 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
325 13 const previousClock = this.activeClock; 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
363 9 const newBounds = { 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
385 1 export default TimeContext; 'export' is only available in ES6 (use 'esversion: 6').

es3

23 1 import EventEmitter from 'EventEmitter'; 'import' is only available in ES6 (use 'esversion: 6').
38 1 class TimeContext extends EventEmitter { 'class' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
74 21 + "an active clock." Misleading line break before '+'; readers may interpret this as an expression boundary.
78 13 let timeSystem; 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
139 13 || (bounds.end === undefined) Misleading line break before '||'; readers may interpret this as an expression boundary.
140 13 || isNaN(bounds.start) Misleading line break before '||'; readers may interpret this as an expression boundary.
141 13 || isNaN(bounds.end) Misleading line break before '||'; readers may interpret this as an expression boundary.
173 13 const validationResult = this.validateBounds(newBounds); 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
205 13 || (offsets.end === undefined) Misleading line break before '||'; readers may interpret this as an expression boundary.
206 13 || isNaN(offsets.start) Misleading line break before '||'; readers may interpret this as an expression boundary.
207 13 || isNaN(offsets.end) Misleading line break before '||'; readers may interpret this as an expression boundary.
258 13 const validationResult = this.validateOffsets(offsets); 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
265 13 const currentValue = this.activeClock.currentValue(); 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
266 13 const newBounds = { 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
311 13 let clock; 'let' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
325 13 const previousClock = this.activeClock; 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
363 9 const newBounds = { 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
385 1 export default TimeContext; 'export' is only available in ES6 (use 'esversion: 6').
@shaynababe shaynababe added the type:maintenance tests, chores, or project maintenance label Apr 11, 2023
@shaynababe
Copy link
Author

tsc

type Bounds = {
    start: number;
    end: number;
};
declare class TimeContext {
    timeSystems: Map<any, any>;
    system: any;
    clocks: Map<any, any>;
    boundsVal: {
        start: any;
        end: any;
    };
    activeClock: any;
    offsets: {
        /**
         * A time span relative to the current value of the
         * ticking clock, from which start bounds will be calculated. This value must
         * be < 0. When a clock is active, bounds will be calculated automatically
         * based on the value provided by the clock, and the defined clock offsets.
         */
        start: number;
        /**
         * A time span relative to the current value of the
         * ticking clock, from which end bounds will be calculated. This value must
         * be >= 0.
         */
        end: number;
    };
    /**
     * Update bounds based on provided time and current offsets
     * @param {number} timestamp A time from which bounds will be calculated
     * using current offsets.
     */
    tick(timestamp: number): void;
    /**
     * Get or set the time system of the TimeAPI.
     * @param {TimeSystem | string} timeSystemOrKey
     * @param {module:openmct.TimeAPI~TimeConductorBounds} bounds
     * @fires module:openmct.TimeAPI~timeSystem
     * @returns {TimeSystem} The currently applied time system
     * @memberof module:openmct.TimeAPI#
     * @method timeSystem
     */
    timeSystem(timeSystemOrKey: TimeSystem | string, bounds: any, ...args: any[]): TimeSystem;
    /**
     * Clock offsets are used to calculate temporal bounds when the system is
     * ticking on a clock source.
     *
     * @typedef {object} ValidationResult
     * @property {boolean} valid Result of the validation - true or false.
     * @property {string} message An error message if valid is false.
     */
    /**
     * Validate the given bounds. This can be used for pre-validation of bounds,
     * for example by views validating user inputs.
     * @param {TimeBounds} bounds The start and end time of the conductor.
     * @returns {ValidationResult} A validation error, or true if valid
     * @memberof module:openmct.TimeAPI#
     * @method validateBounds
     */
    validateBounds(bounds: {
        /**
         * The start time displayed by the time conductor
         * in ms since epoch. Epoch determined by currently active time system
         */
        start: number;
        /**
         * The end time displayed by the time conductor in ms
         * since epoch.
         */
        end: number;
    }): {
        /**
         * Result of the validation - true or false.
         */
        valid: boolean;
        /**
         * An error message if valid is false.
         */
        message: string;
    };
    /**
     * Get or set the start and end time of the time conductor. Basic validation
     * of bounds is performed.
     *
     * @param {module:openmct.TimeAPI~TimeConductorBounds} newBounds
     * @throws {Error} Validation error
     * @fires module:openmct.TimeAPI~bounds
     * @returns {module:openmct.TimeAPI~TimeConductorBounds}
     * @memberof module:openmct.TimeAPI#
     * @method bounds
     */
    bounds(newBounds: any, ...args: any[]): any;
    /**
     * Validate the given offsets. This can be used for pre-validation of
     * offsets, for example by views validating user inputs.
     * @param {ClockOffsets} offsets The start and end offsets from a 'now' value.
     * @returns { ValidationResult } A validation error, and true/false if valid or not
     * @memberof module:openmct.TimeAPI#
     * @method validateOffsets
     */
    validateOffsets(offsets: {
        /**
         * A time span relative to the current value of the
         * ticking clock, from which start bounds will be calculated. This value must
         * be < 0. When a clock is active, bounds will be calculated automatically
         * based on the value provided by the clock, and the defined clock offsets.
         */
        start: number;
        /**
         * A time span relative to the current value of the
         * ticking clock, from which end bounds will be calculated. This value must
         * be >= 0.
         */
        end: number;
    }): {
        /**
         * Result of the validation - true or false.
         */
        valid: boolean;
        /**
         * An error message if valid is false.
         */
        message: string;
    };
    /**
     * @typedef {Object} TimeBounds
     * @property {number} start The start time displayed by the time conductor
     * in ms since epoch. Epoch determined by currently active time system
     * @property {number} end The end time displayed by the time conductor in ms
     * since epoch.
     * @memberof module:openmct.TimeAPI~
     */
    /**
     * Clock offsets are used to calculate temporal bounds when the system is
     * ticking on a clock source.
     *
     * @typedef {object} ClockOffsets
     * @property {number} start A time span relative to the current value of the
     * ticking clock, from which start bounds will be calculated. This value must
     * be < 0. When a clock is active, bounds will be calculated automatically
     * based on the value provided by the clock, and the defined clock offsets.
     * @property {number} end A time span relative to the current value of the
     * ticking clock, from which end bounds will be calculated. This value must
     * be >= 0.
     */
    /**
     * Get or set the currently applied clock offsets. If no parameter is provided,
     * the current value will be returned. If provided, the new value will be
     * used as the new clock offsets.
     * @param {ClockOffsets} offsets
     * @returns {ClockOffsets}
     */
    clockOffsets(offsets: {
        /**
         * A time span relative to the current value of the
         * ticking clock, from which start bounds will be calculated. This value must
         * be < 0. When a clock is active, bounds will be calculated automatically
         * based on the value provided by the clock, and the defined clock offsets.
         */
        start: number;
        /**
         * A time span relative to the current value of the
         * ticking clock, from which end bounds will be calculated. This value must
         * be >= 0.
         */
        end: number;
    }, ...args: any[]): {
        /**
         * A time span relative to the current value of the
         * ticking clock, from which start bounds will be calculated. This value must
         * be < 0. When a clock is active, bounds will be calculated automatically
         * based on the value provided by the clock, and the defined clock offsets.
         */
        start: number;
        /**
         * A time span relative to the current value of the
         * ticking clock, from which end bounds will be calculated. This value must
         * be >= 0.
         */
        end: number;
    };
    /**
     * Stop the currently active clock from ticking, and unset it. This will
     * revert all views to showing a static time frame defined by the current
     * bounds.
     */
    stopClock(): void;
    /**
     * Set the active clock. Tick source will be immediately subscribed to
     * and ticking will begin. Offsets from 'now' must also be provided. A clock
     * can be unset by calling {@link stopClock}.
     *
     * @param {Clock || string} keyOrClock The clock to activate, or its key
     * @param {ClockOffsets} offsets on each tick these will be used to calculate
     * the start and end bounds. This maintains a sliding time window of a fixed
     * width that automatically updates.
     * @fires module:openmct.TimeAPI~clock
     * @return {Clock} the currently active clock;
     */
    clock(keyOrClock: any, offsets: {
        /**
         * A time span relative to the current value of the
         * ticking clock, from which start bounds will be calculated. This value must
         * be < 0. When a clock is active, bounds will be calculated automatically
         * based on the value provided by the clock, and the defined clock offsets.
         */
        start: number;
        /**
         * A time span relative to the current value of the
         * ticking clock, from which end bounds will be calculated. This value must
         * be >= 0.
         */
        end: number;
    }, ...args: any[]): Clock;
    /**
     * Checks if this time context is in real-time mode or not.
     * @returns {boolean} true if this context is in real-time mode, false if not
    */
    isRealTime(): boolean;
}

export { Bounds, TimeContext as default };

@shaynababe
Copy link
Author

shaynababe commented Apr 11, 2023

(base) z@spin7:~/es/api$ npx eslint -v
v8.38.0
commonjs how old is this code
move to TS you be happy

✖ 1367 problems (1318 errors, 49 warnings)
386 errors and 0 warnings potentially fixable with the --fix option.

@shaynababe
Copy link
Author

the src tree
fix and => ts
✖ 8336 problems (8168 errors, 168 warnings)
4174 errors and 0 warnings potentially fixable with the --fix option.

eslintsrc.txt

@unlikelyzero
Copy link
Collaborator

Thank you for finding and filing this issue!

The Open MCT team has identified this issue as a duplicate of an existing issue. To follow along with that development (or contribute!), please subscribe to the following: #6591

@unlikelyzero unlikelyzero added invalid duplicate or incorrectly filed source:community Community contribution or request labels Mar 20, 2024
@unlikelyzero unlikelyzero added this to the Wont Fix milestone Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid duplicate or incorrectly filed source:community Community contribution or request type:maintenance tests, chores, or project maintenance
Projects
None yet
Development

No branches or pull requests

2 participants