Skip to content

Commit

Permalink
Merge 739f3c8 into 1aeac3b
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuajaco committed Nov 19, 2023
2 parents 1aeac3b + 739f3c8 commit fa1e92a
Show file tree
Hide file tree
Showing 11 changed files with 440 additions and 376 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
"use strict";

module.exports = {
root: true,
reportUnusedDisableDirectives: true,
env: {
node: 1,
mocha: 1,
},
parserOptions: {
ecmaVersion: 2021,
},
plugins: ["node", "eslint-plugin", "prettier"],
plugins: ["node", "eslint-plugin"],
extends: [
"eslint:recommended",
"plugin:node/recommended",
"plugin:eslint-plugin/all",
"prettier",
],
rules: {
"arrow-body-style": "error",
Expand All @@ -31,6 +34,5 @@ module.exports = {
"https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/{{name}}.md",
},
],
"prettier/prettier": "error",
},
};
11 changes: 6 additions & 5 deletions .github/workflows/node.js.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Node.js CI
name: CI
on:
push:
branches: ["main"]
Expand All @@ -10,21 +10,22 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [18.16.0, 20.2.0]
node-version: [18.18.2, 20.9.0]
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
- run: npm ci
- run: npm run format:check
- run: npm run lint
- run: npm test
- run: npm run coverage
- name: Coveralls
uses: coverallsapp/github-action@master
with:
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 20.2.0
nodejs 20.9.0
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ Or add the "recommended" preset:

| | | Name | Description |
| --- | --- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| | 🔧 | [no-absolute-imports](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/no-absolute-imports.md) | disallow absolute imports for files that are within the current package |
|| 🔧 | [no-absolute-imports](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/no-absolute-imports.md) | disallow absolute imports for files that are within the current package |
| | | [no-cross-imports](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/no-cross-imports.md) | disallow imports of files that are inside another package |
| | 🔧 | [no-relative-imports](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/no-relative-imports.md) | disallow relative imports of files that are outside of the current package |
| | | [require-dependency](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/require-dependency.md) | disallow importing from packages that are not listed as a dependency |
|| 🔧 | [no-relative-imports](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/no-relative-imports.md) | disallow relative imports of files that are outside of the current package |
|| | [require-dependency](https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/require-dependency.md) | disallow importing from packages that are not listed as a dependency |

## Presets

Expand Down
4 changes: 2 additions & 2 deletions lib/rules/no-absolute-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ module.exports.create = (context) => {
fixer.replaceTextRange(
[start + 1, end - 1],
pathToImport(
relative(dirname(filename), path.replace(name, location))
)
relative(dirname(filename), path.replace(name, location)),
),
),
});
}
Expand Down
8 changes: 4 additions & 4 deletions lib/rules/no-cross-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ module.exports.create = (context) => {
if (!workspaces) return {};

const forbidden = workspaces.filter(
({ package: { name } }) => !allowed.includes(name)
({ package: { name } }) => !allowed.includes(name),
);

return getImport(
Expand All @@ -83,8 +83,8 @@ module.exports.create = (context) => {
filterSharedPackagesInCurrentScope(
currentWorkspace,
scopedEnabled,
scopedSharingFolderName
)
scopedSharingFolderName,
),
)
.forEach(({ package: { name }, location }) => {
if (
Expand All @@ -98,6 +98,6 @@ module.exports.create = (context) => {
});
}
});
}
},
);
};
4 changes: 2 additions & 2 deletions lib/rules/no-relative-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ module.exports.create = (context) => {
fix: (fixer) =>
fixer.replaceTextRange(
[start + 1, end - 1],
path.replace(location, name)
path.replace(location, name),
),
});
}
});
}
},
);
};
2 changes: 1 addition & 1 deletion lib/rules/require-dependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ module.exports.create = (context) => {
});
}
});
}
},
);
};
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const getImport = (workspaces, filename, callback) => {
if (!workspaces) return {};

const currentWorkspace = workspaces.find(({ location }) =>
isSubPath(location, filename)
isSubPath(location, filename),
);

if (!currentWorkspace) return {};
Expand All @@ -59,7 +59,7 @@ const getImport = (workspaces, filename, callback) => {
(node.callee.type === "Identifier" && node.callee.name === "require"))
) {
callback(
resolveImport(filename, node, node.arguments[0], currentWorkspace)
resolveImport(filename, node, node.arguments[0], currentWorkspace),
);
}
},
Expand Down

0 comments on commit fa1e92a

Please sign in to comment.