Skip to content

Commit

Permalink
fix: eslint 7.0 support (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
aladdin-add committed Jan 2, 2024
1 parent 0ab0f41 commit 2419888
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/CI.yml
Expand Up @@ -31,10 +31,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
eslint: [8.x, 7.x]
eslint: [8.x]
node: [18.x, 20.x]
include:
# run on node lts(ubuntu-latest)
- os: ubuntu-latest
node: "16.0.x"
eslint: "8.x"
Expand All @@ -44,6 +43,9 @@ jobs:
- os: ubuntu-latest
node: "19.x"
eslint: "8.x"
- os: ubuntu-latest
node: "20.x"
eslint: "7.0.x"
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -57,10 +59,7 @@ jobs:
- name: Install Packages
run: npm install
- name: Install ESLint ${{ matrix.eslint }}
# We need to execute this command twice because of npm's bug.
# See also: https://npm.community/t/error-node-modules-staging-eslint-e7cf6846-node-modules-eslint
run: |
npm install --no-save eslint@${{ matrix.eslint }}
npm install --no-save eslint@${{ matrix.eslint }}
npm install --no-save --force eslint@${{ matrix.eslint }}
- name: Test
run: npm run -s test:ci
3 changes: 1 addition & 2 deletions lib/configs/recommended-module.js
Expand Up @@ -7,9 +7,9 @@ const { commonRules } = require("./_commons")
module.exports.eslintrc = {
env: {
node: true,
es2021: true,
},
globals: {
...globals.es2021,
__dirname: "off",
__filename: "off",
exports: "off",
Expand All @@ -36,7 +36,6 @@ module.exports.flat = {
sourceType: "module",
globals: {
...globals.node,
...globals.es2021,
...module.exports.eslintrc.globals,
},
},
Expand Down
3 changes: 1 addition & 2 deletions lib/configs/recommended-script.js
Expand Up @@ -7,9 +7,9 @@ const { commonRules } = require("./_commons")
module.exports.eslintrc = {
env: {
node: true,
es2021: true,
},
globals: {
...globals.es2021,
__dirname: "readonly",
__filename: "readonly",
exports: "writable",
Expand All @@ -33,7 +33,6 @@ module.exports.flat = {
sourceType: "commonjs",
globals: {
...globals.node,
...globals.es2021,
...module.exports.eslintrc.globals,
},
},
Expand Down
5 changes: 4 additions & 1 deletion lib/util/is-typescript.js
Expand Up @@ -12,7 +12,10 @@ const typescriptExtensions = [".ts", ".tsx", ".cts", ".mts"]
*/
module.exports = function isTypescript(context) {
const sourceFileExt = path.extname(
context.physicalFilename ?? context.getPhysicalFilename()
context.physicalFilename ??
context.getPhysicalFilename?.() ??
context.filename ??
context.getFilename?.()
)
return typescriptExtensions.includes(sourceFileExt)
}

0 comments on commit 2419888

Please sign in to comment.