Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 149 additions & 1 deletion etc/eslint/rules/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@
* @default [ 'off', 'starred-block' ]
* @see [multiline-comment-style]{@link https://eslint.org/docs/rules/multiline-comment-style}
*/
rules[ 'multiline-comment-style' ] = [ 'off', 'starred-block' ]; // TODO: enable once non-"aligned" blocks are supported

Check warning on line 879 in etc/eslint/rules/style.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'todo' comment: 'TODO: enable once non-"aligned" blocks...'

/**
* Allow same line or multiline ternary expressions.
Expand Down Expand Up @@ -1223,7 +1223,155 @@
'ImportDeclaration',
'ImportSpecifier',
'ImportDefaultSpecifier',
'ImportNamespaceSpecifier'
'ImportNamespaceSpecifier',

// Enforce stdlib package usage over built-in methods:

// String.prototype.endsWith
{
'selector': 'CallExpression[callee.property.name="endsWith"]',
'message': 'Use `@stdlib/string/ends-with` or `@stdlib/string/base/ends-with` instead of String.prototype.endsWith.'
},

// String.prototype.startsWith
{
'selector': 'CallExpression[callee.property.name="startsWith"]',
'message': 'Use `@stdlib/string/starts-with` or `@stdlib/string/base/starts-with` instead of String.prototype.startsWith.'
},

// String.prototype.toLowerCase
{
'selector': 'CallExpression[callee.property.name="toLowerCase"]',
'message': 'Use `@stdlib/string/lowercase` or `@stdlib/string/base/lowercase` instead of String.prototype.toLowerCase.'
},

// String.prototype.toUpperCase
{
'selector': 'CallExpression[callee.property.name="toUpperCase"]',
'message': 'Use `@stdlib/string/uppercase` or `@stdlib/string/base/uppercase` instead of String.prototype.toUpperCase.'
},

// String.prototype.trim
{
'selector': 'CallExpression[callee.property.name="trim"]',
'message': 'Use `@stdlib/string/trim` or `@stdlib/string/base/trim` instead of String.prototype.trim.'
},

// String.prototype.trimStart / trimLeft
{
'selector': 'CallExpression[callee.property.name="trimStart"]',
'message': 'Use `@stdlib/string/base/left-trim` instead of String.prototype.trimStart.'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to remember to update these messages once we have added the non-base packages.

},
{
'selector': 'CallExpression[callee.property.name="trimLeft"]',
'message': 'Use `@stdlib/string/base/left-trim` instead of String.prototype.trimLeft.'
},

// String.prototype.trimEnd / trimRight
{
'selector': 'CallExpression[callee.property.name="trimEnd"]',
'message': 'Use `@stdlib/string/base/right-trim` instead of String.prototype.trimEnd.'
},
{
'selector': 'CallExpression[callee.property.name="trimRight"]',
'message': 'Use `@stdlib/string/base/right-trim` instead of String.prototype.trimRight.'
},

// Object.keys
{
'selector': 'CallExpression[callee.object.name="Object"][callee.property.name="keys"]',
'message': 'Use `@stdlib/utils/keys` instead of Object.keys.'
},

// Object.values
{
'selector': 'CallExpression[callee.object.name="Object"][callee.property.name="values"]',
'message': 'Use `@stdlib/utils/values` instead of Object.values.'
},

// Object.entries
{
'selector': 'CallExpression[callee.object.name="Object"][callee.property.name="entries"]',
'message': 'Use `@stdlib/utils/entries` instead of Object.entries.'
},

// Object.defineProperty
{
'selector': 'CallExpression[callee.object.name="Object"][callee.property.name="defineProperty"]',
'message': 'Use `@stdlib/utils/define-property` instead of Object.defineProperty.'
},

// fs.readFile
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="readFile"]',
'message': 'Use `@stdlib/fs/read-file` instead of fs.readFile.'
},
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="readFileSync"]',
'message': 'Use `@stdlib/fs/read-file` instead of fs.readFileSync.'
},

// fs.writeFile
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="writeFile"]',
'message': 'Use `@stdlib/fs/write-file` instead of fs.writeFile.'
},
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="writeFileSync"]',
'message': 'Use `@stdlib/fs/write-file` instead of fs.writeFileSync.'
},

// fs.readdir
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="readdir"]',
'message': 'Use `@stdlib/fs/read-dir` instead of fs.readdir.'
},
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="readdirSync"]',
'message': 'Use `@stdlib/fs/read-dir` instead of fs.readdirSync.'
},

// fs.exists
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="exists"]',
'message': 'Use `@stdlib/fs/exists` instead of fs.exists.'
},
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="existsSync"]',
'message': 'Use `@stdlib/fs/exists` instead of fs.existsSync.'
},

// fs.unlink
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="unlink"]',
'message': 'Use `@stdlib/fs/unlink` instead of fs.unlink.'
},
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="unlinkSync"]',
'message': 'Use `@stdlib/fs/unlink` instead of fs.unlinkSync.'
},

// fs.rename
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="rename"]',
'message': 'Use `@stdlib/fs/rename` instead of fs.rename.'
},
{
'selector': 'CallExpression[callee.object.name="fs"][callee.property.name="renameSync"]',
'message': 'Use `@stdlib/fs/rename` instead of fs.renameSync.'
},

// path.dirname
{
'selector': 'CallExpression[callee.object.name="path"][callee.property.name="dirname"]',
'message': 'Use `@stdlib/utils/dirname` instead of path.dirname.'
},

// path.extname
{

Check warning on line 1371 in etc/eslint/rules/style.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

File has too many lines (423). Maximum allowed is 300
'selector': 'CallExpression[callee.object.name="path"][callee.property.name="extname"]',
'message': 'Use `@stdlib/utils/extname` instead of path.extname.'
}
];

/**
Expand Down