Skip to content

Commit a8cb601

Browse files
updated: eslint setup
1 parent a9dab3f commit a8cb601

File tree

11 files changed

+999
-839
lines changed

11 files changed

+999
-839
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.prettierrc.cjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import config from '@riotjs/prettier-config'
2+
export default config

dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { dashToCamelCase } from './strings.js'
33
/**
44
* Get all the element attributes as object
55
* @param {HTMLElement} element - DOM node we want to parse
6-
* @returns {Object} all the attributes found as a key value pairs
6+
* @returns {object} all the attributes found as a key value pairs
77
*/
88
export function DOMattributesToObject(element) {
99
return Array.from(element.attributes).reduce((acc, attribute) => {

eslint.config.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig, globalIgnores } from 'eslint/config'
2+
import riotEslintConfig from 'eslint-config-riot'
3+
4+
export default defineConfig([
5+
globalIgnores(['*.cjs']),
6+
{ extends: [riotEslintConfig] },
7+
{
8+
rules: {
9+
'fp/no-mutating-methods': 0,
10+
},
11+
},
12+
])

functions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export function noop() {
77

88
/**
99
* Autobind the methods of a source object to itself
10-
* @param {Object} source - probably a riot tag instance
10+
* @param {object} source - probably a riot tag instance
1111
* @param {Array<string>} methods - list of the methods to autobind
12-
* @returns {Object} the original object received
12+
* @returns {object} the original object received
1313
*/
1414
export function autobindMethods(source, methods) {
1515
methods.forEach((method) => {

misc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export function memoize(fn) {
3030
/**
3131
* Generate key-value pairs from a list of attributes
3232
* @param {Array} attributes - list of attributes generated by the riot compiler, each containing type, name, and evaluate function
33-
* @param {Object} scope - the scope in which the attribute values will be evaluated
34-
* @returns {Object} An object containing key-value pairs representing the computed attribute values
33+
* @param {object} scope - the scope in which the attribute values will be evaluated
34+
* @returns {object} An object containing key-value pairs representing the computed attribute values
3535
*/
3636
export function generatePropsFromAttributes(attributes, scope) {
3737
return attributes.reduce((acc, { type, name, evaluate }) => {

objects.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,30 @@ import { isObject } from './checks.js'
22

33
/**
44
* Helper function to set an immutable property
5-
* @param {Object} source - object where the new property will be set
5+
* @param {object} source - object where the new property will be set
66
* @param {string} key - object key where the new property will be stored
77
* @param {*} value - value of the new property
8-
* @param {Object} options - set the property overriding the default options
9-
* @returns {Object} - the original object modified
8+
* @param {object} options - set the property overriding the default options
9+
* @returns {object} - the original object modified
1010
*/
1111
export function defineProperty(source, key, value, options = {}) {
12-
/* eslint-disable fp/no-mutating-methods */
1312
Object.defineProperty(source, key, {
1413
value,
1514
enumerable: false,
1615
writable: false,
1716
configurable: true,
1817
...options,
1918
})
20-
/* eslint-enable fp/no-mutating-methods */
2119

2220
return source
2321
}
2422

2523
/**
2624
* Define multiple properties on a target object
27-
* @param {Object} source - object where the new properties will be set
28-
* @param {Object} properties - object containing as key pair the key + value properties
29-
* @param {Object} options - set the property overriding the default options
30-
* @returns {Object} the original object modified
25+
* @param {object} source - object where the new properties will be set
26+
* @param {object} properties - object containing as key pair the key + value properties
27+
* @param {object} options - set the property overriding the default options
28+
* @returns {object} the original object modified
3129
*/
3230
export function defineProperties(source, properties, options) {
3331
Object.entries(properties).forEach(([key, value]) => {
@@ -39,9 +37,9 @@ export function defineProperties(source, properties, options) {
3937

4038
/**
4139
* Define default properties if they don't exist on the source object
42-
* @param {Object} source - object that will receive the default properties
43-
* @param {Object} defaults - object containing additional optional keys
44-
* @returns {Object} the original object received enhanced
40+
* @param {object} source - object that will receive the default properties
41+
* @param {object} defaults - object containing additional optional keys
42+
* @returns {object} the original object received enhanced
4543
*/
4644
export function defineDefaults(source, defaults) {
4745
Object.entries(defaults).forEach(([key, value]) => {
@@ -62,9 +60,9 @@ export function cloneDeep(source) {
6260

6361
/**
6462
* Like Array.prototype.filter but for objects
65-
* @param {Object} source - target object
66-
* @param {Funciton} filter - filter function
67-
* @return {Object} filtered source or the original source received
63+
* @param {object} source - target object
64+
* @param {(key: unknown, value: unknown) => boolean} filter - filter function
65+
* @returns {object} filtered source or the original source received
6866
*/
6967
export function filter(source, filter) {
7068
return isObject(source)
@@ -76,9 +74,9 @@ export function filter(source, filter) {
7674

7775
/**
7876
* Generate a new object picking only the properties from a given array
79-
* @param {Object} source - target object
77+
* @param {object} source - target object
8078
* @param {Array} keys - list of keys that we want to copy over to the new object
81-
* @return {Object} a new object conaining only the keys that we have picked from the keys array list
79+
* @returns {object} a new object conaining only the keys that we have picked from the keys array list
8280
*/
8381
export function pick(source, keys) {
8482
return isObject(source)

0 commit comments

Comments
 (0)