Skip to content

Commit

Permalink
v1.0.71
Browse files Browse the repository at this point in the history
Allow custom groups
  • Loading branch information
eliottvincent committed Jan 12, 2024
1 parent 0bbb2ae commit 8fcdf90
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-crisp",
"version": "1.0.70",
"version": "1.0.71",
"description": "Custom ESLint Rules for Crisp",
"author": "Crisp IM SAS",
"main": "index.js",
Expand Down
17 changes: 17 additions & 0 deletions rules/import-group-comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,20 @@ module.exports = {
category: "Best Practices",
recommended: false,
},
schema: [
{
type: "object",
additionalProperties: {
type: "string",
},
},
],
fixable: null, // This rule is not auto-fixable
},

create(context) {
const customGroups = context.options[0] || {}; // Get custom groups from options

let currentGroupComment = null;

// Extract the directory name from the file path
Expand All @@ -19,6 +29,13 @@ module.exports = {
}

function extractGroupFromPath(path, filePath) {
// Check custom regexes first
for (const regexStr in customGroups) {
if (new RegExp(regexStr).test(path)) {
return customGroups[regexStr];
}
}

// Relative path import?
if (path.startsWith("./")) {
return getDirectoryName(filePath);
Expand Down

0 comments on commit 8fcdf90

Please sign in to comment.