Skip to content

Commit

Permalink
chor: fix lint & test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed Jul 21, 2024
1 parent a87ac81 commit d880c37
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 23 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,29 @@ jobs:
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}

#-----------------------------------------------------------------------------
# eslint-scope
#-----------------------------------------------------------------------------

- name: Publish eslint-scope package to npm
run: npm publish -w packages/eslint-scope --provenance
if: ${{ steps.release.outputs['packages/eslint-scope--release_created'] }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: Tweet Release Announcement
run: npx @humanwhocodes/tweet "eslint-scope v${{ steps.release.outputs['packages/eslint-scope--major'] }}.${{ steps.release.outputs['packages/eslint-scope--minor'] }}.${{ steps.release.outputs['packages/eslint-scope--patch'] }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/${{ steps.release.outputs['packages/eslint-scope--tag_name'] }}"
if: ${{ steps.release.outputs['packages/eslint-scope--release_created'] }}
env:
TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
TWITTER_ACCESS_TOKEN_KEY: ${{ secrets.TWITTER_ACCESS_TOKEN_KEY }}
TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}

- name: Toot Release Announcement
run: npx @humanwhocodes/toot "eslint-scope v${{ steps.release.outputs['packages/eslint-scope--major'] }}.${{ steps.release.outputs['packages/eslint-scope--minor'] }}.${{ steps.release.outputs['packages/eslint-scope--patch'] }} has been released!\n\n${{ github.event.repository.html_url }}/releases/tag/${{ steps.release.outputs['packages/eslint-scope--tag_name'] }}"
if: ${{ steps.release.outputs['packages/eslint-scope--release_created'] }}
env:
MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }}
MASTODON_HOST: ${{ secrets.MASTODON_HOST }}
28 changes: 27 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import eslintConfigESLint from "eslint-config-eslint";
import eslintConfigESLintFormatting from "eslint-config-eslint/formatting";
import eslintPluginChaiFriendly from "eslint-plugin-chai-friendly";
import globals from "globals";

export default [
Expand All @@ -14,11 +15,36 @@ export default [
...eslintConfigESLint,
eslintConfigESLintFormatting,
{
files: ["**/tests/lib/**"],
files: ["packages/espree/tests/lib/**", "packages/eslint-scope/tests/**"],
languageOptions: {
globals: {
...globals.mocha
}
},
plugins: {
"chai-friendly": eslintPluginChaiFriendly
},
rules: {
"no-unused-expressions": "off",
"chai-friendly/no-unused-expressions": "error"
}
},
{
files: ["packages/eslint-scope/lib/**"],
rules: {
"no-underscore-dangle": "off"
}
},
{
files: ["packages/eslint-scope/Makefile.js"],
languageOptions: {
globals: {
...globals.shelljs,
target: false
}
},
rules: {
"no-console": "off"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"common-tags": "^1.8.2",
"eslint": "^9.4.0",
"eslint-config-eslint": "^11.0.0",
"eslint-plugin-chai-friendly": "^1.0.0",
"globals": "^15.1.0",
"got": "^14.4.1",
"lint-staged": "^15.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/eslint-scope/Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// Requirements
//------------------------------------------------------------------------------

import path from "path";
import { fileURLToPath } from "url";
import path from "node:path";
import { fileURLToPath } from "node:url";

import "shelljs/make.js";
import checker from "npm-license";
Expand All @@ -34,7 +34,7 @@ const OPEN_SOURCE_LICENSES = [
//------------------------------------------------------------------------------

const NODE = "node",
NODE_MODULES = "./node_modules",
NODE_MODULES = "../../node_modules",

// Utilities - intentional extra space at the end of each string
MOCHA = `${NODE_MODULES}/mocha/bin/_mocha `,
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-scope/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* @module escope
*/

import assert from "assert";
import assert from "node:assert";

import ScopeManager from "./scope-manager.js";
import Referencer from "./referencer.js";
Expand Down Expand Up @@ -89,7 +89,7 @@ function updateDeeply(target, override) {
}

for (const key in override) {
if (Object.prototype.hasOwnProperty.call(override, key)) {
if (Object.hasOwn(override, key)) {
const val = override[key];

if (isHashObject(val)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/pattern-visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const { Syntax } = estraverse;
* @returns {any} Last elment
*/
function getLast(xs) {
return xs[xs.length - 1] || null;
return xs.at(-1) || null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/referencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Reference from "./reference.js";
import Variable from "./variable.js";
import PatternVisitor from "./pattern-visitor.js";
import { Definition, ParameterDefinition } from "./definition.js";
import assert from "assert";
import assert from "node:assert";

const { Syntax } = estraverse;

Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/scope-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
SwitchScope,
WithScope
} from "./scope.js";
import assert from "assert";
import assert from "node:assert";

/**
* @constructor ScopeManager
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import estraverse from "estraverse";
import Reference from "./reference.js";
import Variable from "./variable.js";
import { Definition } from "./definition.js";
import assert from "assert";
import assert from "node:assert";

const { Syntax } = estraverse;

Expand Down
4 changes: 0 additions & 4 deletions packages/eslint-scope/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@
"@typescript-eslint/parser": "^7.1.1",
"c8": "^7.7.3",
"chai": "^4.3.4",
"eslint": "^8.57.0",
"eslint-config-eslint": "^9.0.0",
"eslint-plugin-chai-friendly": "^0.7.4",
"eslint-release": "^3.2.0",
"eslint-visitor-keys": "^4.0.0",
"espree": "^10.0.1",
"globals": "^14.0.0",
"mocha": "^9.0.1",
"npm-license": "^0.3.3",
"rollup": "^2.52.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/tests/class-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Toru Nagashima
*/

import assert from "assert";
import assert from "node:assert";
import * as espree from "espree";
import { KEYS } from "eslint-visitor-keys";
import { analyze } from "../lib/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/tests/class-static-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Milos Djermanovic
*/

import assert from "assert";
import assert from "node:assert";
import * as espree from "espree";
import { KEYS } from "eslint-visitor-keys";
import { analyze } from "../lib/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/tests/commonjs.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Requirements
//------------------------------------------------------------------------------

const assert = require("assert");
const assert = require("node:assert");
const eslintScope = require("../dist/eslint-scope.cjs");


Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/tests/es6-default-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ describe("ES6 default parameters:", () => {

expect(reference.from).to.equal(scope);
expect(reference.identifier.name).to.equal("a");
expect(reference.resolved).to.equal(scope.variables[scope.variables.length - 1]);
expect(reference.resolved).to.equal(scope.variables.at(-1));
expect(reference.writeExpr).to.be.undefined;
expect(reference.isWrite()).to.be.false;
expect(reference.isRead()).to.be.true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import assert from "assert";
import assert from "node:assert";
import * as espree from "espree";
import { KEYS } from "eslint-visitor-keys";
import { analyze } from "../lib/index.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-scope/tests/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ describe("References:", () => {

expect(scopeManager.scopes).to.be.length.of.at.least(1);

const scope = scopeManager.scopes[scopeManager.scopes.length - 1];
const scope = scopeManager.scopes.at(-1);

expect(scope.variables).to.have.length.of.at.least(1);
expect(scope.references).to.have.length.of.at.least(1);
Expand Down Expand Up @@ -572,7 +572,7 @@ describe("References:", () => {

expect(scopeManager.scopes).to.be.length.of.at.least(1);

const scope = scopeManager.scopes[scopeManager.scopes.length - 1];
const scope = scopeManager.scopes.at(-1);

expect(scope.variables).to.have.length(1);
expect(scope.references).to.have.length.of.at.least(1);
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/tests/use-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Milos Djermanovic
*/

import assert from "assert";
import assert from "node:assert";
import * as espree from "espree";
import { KEYS } from "eslint-visitor-keys";
import { analyze } from "../lib/index.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-scope/tools/update-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @author Nicholas C. Zakas
*/

import fs from "fs";
import fs from "node:fs";

/*
* IMPORTANT: This must be run *before* Rollup so the built package will have
Expand Down

0 comments on commit d880c37

Please sign in to comment.