Skip to content

Commit

Permalink
Merge pull request #28 from joshuajaco/maintenance
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
joshuajaco authored Nov 19, 2023
2 parents 1aeac3b + 2296a5e commit 85a78aa
Show file tree
Hide file tree
Showing 11 changed files with 455 additions and 398 deletions.
36 changes: 14 additions & 22 deletions .eslintrc.js → .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
"use strict";

module.exports = {
env: {
node: 1,
mocha: 1,
},
parserOptions: {
ecmaVersion: 2021,
},
plugins: ["node", "eslint-plugin", "prettier"],
extends: [
{
"root": true,
"reportUnusedDisableDirectives": true,
"env": { "node": true, "mocha": true },
"plugins": ["node", "eslint-plugin"],
"extends": [
"eslint:recommended",
"plugin:node/recommended",
"plugin:eslint-plugin/all",
"prettier"
],
rules: {
"rules": {
"arrow-body-style": "error",
"no-use-before-define": "error",
strict: "error",
"strict": "error",
"node/prefer-global/buffer": "error",
"node/prefer-global/console": "error",
"node/prefer-global/process": "error",
Expand All @@ -27,10 +21,8 @@ module.exports = {
"eslint-plugin/require-meta-docs-url": [
"error",
{
pattern:
"https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/{{name}}.md",
},
],
"prettier/prettier": "error",
},
};
"pattern": "https://github.com/joshuajaco/eslint-plugin-workspaces/blob/main/docs/rules/{{name}}.md"
}
]
}
}
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
Loading

0 comments on commit 85a78aa

Please sign in to comment.