Skip to content

Commit

Permalink
3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Igorkowalski94 committed Oct 3, 2024
1 parent bf236ae commit 859a100
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 120 deletions.
125 changes: 63 additions & 62 deletions fileComposition.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,82 +5,83 @@ import { createFileComposition } from "eslint-plugin-project-structure";
export const fileCompositionConfig = createFileComposition({
filesRules: [
{ filePattern: "**/(index|parser|tsup.config|jest.config).(ts|js)" },

{
filePattern: "**/*consts.ts",
fileRootRules: {
allowOnlySpecifiedSelectors: true,
rules: [
{
selector: ["variable", "variableExpression"],
format: "{SNAKE_CASE}",
},
],
},
allowOnlySpecifiedSelectors: true,
rules: [
{
selector: ["variable", "variableExpression"],
format: "{SNAKE_CASE}",
},
],
},

{
filePattern: "**/*types.ts",
fileRootRules: {
allowOnlySpecifiedSelectors: true,
rules: [
{
selector: ["interface", "type"],
format: "{PascalCase}",
},
{
selector: "enum",
format: "{SNAKE_CASE}",
},
],
},
allowOnlySpecifiedSelectors: true,
rules: [
{
selector: ["interface", "type"],
format: "{PascalCase}",
},
{
selector: "enum",
format: "{SNAKE_CASE}",
},
],
},

{
filePattern: "src/rules/*/*.ts",
fileRootRules: {
allowOnlySpecifiedSelectors: true,
rules: [
{
selector: { type: "variableExpression", limitTo: "ESLintUtils" },
format: "{fileName}",
},
],
},
allowOnlySpecifiedSelectors: true,
rules: [
{
selector: { type: "variableExpression", limitTo: "ESLintUtils" },
format: "{fileName}",
},
],
},

{
filePattern: "**/*.ts",
fileRootRules: {
allowOnlySpecifiedSelectors: true,
rules: [
{
selector: "class",
format: "{FileName}",
},
{
selector: "arrowFunction",
format: "{fileName}",
},
{
selector: ["interface", "type"],
format: ["{FileName}Props", "{FileName}Return"],
},
],
},
fileRules: {
allowOnlySpecifiedSelectors: true,
rules: [
{
selector: [
"arrowFunction",
"function",
"variable",
"variableExpression",
],
format: "{camelCase}",
},
],
},
allowOnlySpecifiedSelectors: true,
rootSelectorsLimits: [{ selector: ["arrowFunction", "class"], limit: 1 }],
rules: [
{
selector: "interface",
positionIndex: 0,
scope: "fileRoot",
format: "{FileName}Props",
},
{
selector: "interface",
positionIndex: 1,
scope: "fileRoot",
format: "{FileName}Return",
},
{
selector: "class",
positionIndex: 2,
scope: "fileRoot",
format: "{FileName}",
},
{
selector: "arrowFunction",
positionIndex: 2,
scope: "fileRoot",
format: "{fileName}",
},
{
selector: [
"arrowFunction",
"function",
"variable",
"variableExpression",
],
format: "{camelCase}",
},
],
},
],
});
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Igor Kowalski (Igorkowalski94)",
"name": "eslint-plugin-project-structure",
"version": "3.0.1",
"version": "3.1.0",
"license": "MIT",
"description": "Powerful ESLint plugin with rules to help you achieve a scalable, consistent, and well-structured project. Create your own framework! Define your folder structure, file composition, advanced naming conventions, and create independent modules. Take your project to the next level and save time by automating the review of key principles of a healthy project! react folder structure react file structure react project structure react conventions architecture react next.js angular node solid vue svelte",
"keywords": [
Expand Down Expand Up @@ -65,7 +65,7 @@
"husky:prepare": "husky install"
},
"dependencies": {
"@typescript-eslint/utils": "^8.7.0",
"@typescript-eslint/utils": "^8.8.0",
"comment-json": "^4.2.5",
"js-yaml": "^4.1.0",
"jsonschema": "^1.4.1",
Expand All @@ -78,12 +78,12 @@
"@types/jest": "^29.5.13",
"@types/js-yaml": "^4.0.9",
"@types/micromatch": "^4.0.9",
"@types/node": "^22.7.2",
"@types/node": "^22.7.4",
"eslint": "^9.11.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-project-structure": "2.7.3",
"eslint-plugin-project-structure": "3.0.1",
"husky": "^9.1.6",
"jest": "^29.7.0",
"prettier": "^3.3.3",
Expand All @@ -92,7 +92,7 @@
"ts-prune": "^0.10.3",
"tsup": "^8.3.0",
"typescript": "^5.6.2",
"typescript-eslint": "^8.7.0"
"typescript-eslint": "^8.8.0"
},
"resolutions": {
"micromatch": "^4.0.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ describe("getCustomError", () => {
},
expected: "\n\nerrorFile\n\n",
},
{
allowOnlySpecifiedSelectors: {
error: { function: "errorGlobal" },
file: { function: "errorFile" },
},
expected: "",
},
{
allowOnlySpecifiedSelectors: {
file: { arrowFunction: "errorFile" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ export const getCustomError = ({
}: GetCustomErrorProps): string => {
if (allowOnlySpecifiedSelectors === true) return "";

if (
typeof allowOnlySpecifiedSelectors[scope] === "object" &&
allowOnlySpecifiedSelectors[scope][selectorType]
)
return `\n\n${allowOnlySpecifiedSelectors[scope][selectorType]}\n\n`;
if (typeof allowOnlySpecifiedSelectors[scope] === "object") {
const scopeErrors = {
...allowOnlySpecifiedSelectors.error,
...allowOnlySpecifiedSelectors[scope],
};

if (!scopeErrors[selectorType]) return "";

return `\n\n${scopeErrors[selectorType]}\n\n`;
}

if (allowOnlySpecifiedSelectors.error?.[selectorType])
return `\n\n${allowOnlySpecifiedSelectors.error[selectorType]}\n\n`;
Expand Down
Loading

0 comments on commit 859a100

Please sign in to comment.