Skip to content

Commit

Permalink
chore: use mjs (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi authored Jan 24, 2023
1 parent 1900312 commit e9fb466
Show file tree
Hide file tree
Showing 31 changed files with 44 additions and 56 deletions.
4 changes: 4 additions & 0 deletions .c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"include": ["src/**/*.mjs"],
"reporter": ["lcov", "text-summary"]
}
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
},
overrides: [
{
files: ["src/**/*.js", "test/**/*.js"],
files: ["src/**/*.mjs", "test/**/*.mjs"],
extends: ["plugin:@eslint-community/mysticatea/+modules"],
rules: {
"init-declarations": "off",
Expand Down
7 changes: 0 additions & 7 deletions .nycrc.yml

This file was deleted.

6 changes: 0 additions & 6 deletions babel.config.js

This file was deleted.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,22 @@
"format:prettier": "prettier .",
"format:check": "npm run -s format:prettier -- --check",
"lint": "eslint .",
"test": "nyc mocha --reporter dot \"test/*.js\"",
"test": "c8 mocha --reporter dot \"test/*.mjs\"",
"preversion": "npm test && npm run -s build",
"postversion": "git push && git push --tags",
"prewatch": "npm run -s clean",
"watch": "warun \"{src,test}/**/*.js\" -- npm run -s test:mocha"
"watch": "warun \"{src,test}/**/*.mjs\" -- npm run -s test:mocha"
},
"dependencies": {
"eslint-visitor-keys": "^3.3.0"
},
"devDependencies": {
"@babel/core": "^7.20.2",
"@babel/plugin-transform-modules-commonjs": "^7.19.6",
"@babel/register": "^7.18.9",
"@eslint-community/eslint-plugin-mysticatea": "^15.2.0",
"c8": "^7.12.0",
"dot-prop": "^6.0.1",
"eslint": "^8.28.0",
"mocha": "^9.2.2",
"npm-run-all": "^4.1.5",
"nyc": "^15.1.0",
"opener": "^1.5.2",
"prettier": "2.8.3",
"rimraf": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import packageInfo from "./package.json"
*/
function config(ext) {
return {
input: "src/index.js",
input: "src/index.mjs",
output: {
exports: ext === ".mjs" ? undefined : "named",
file: `index${ext}`,
Expand Down
2 changes: 1 addition & 1 deletion src/find-variable.js → src/find-variable.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getInnermostScope } from "./get-innermost-scope"
import { getInnermostScope } from "./get-innermost-scope.mjs"

/**
* Find the variable of a given name.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArrowToken, isOpeningParenToken } from "./token-predicate"
import { isArrowToken, isOpeningParenToken } from "./token-predicate.mjs"

/**
* Get the `(` token of the given function node.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getPropertyName } from "./get-property-name"
import { getPropertyName } from "./get-property-name.mjs"

/**
* Get the name and kind of the given function node.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/get-property-name.js → src/get-property-name.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getStringIfConstant } from "./get-string-if-constant"
import { getStringIfConstant } from "./get-string-if-constant.mjs"

/**
* Get the property name from a MemberExpression node or a Property node.
Expand Down
2 changes: 1 addition & 1 deletion src/get-static-value.js → src/get-static-value.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* globals globalThis, global, self, window */

import { findVariable } from "./find-variable"
import { findVariable } from "./find-variable.mjs"

const globalObject =
typeof globalThis !== "undefined"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getStaticValue } from "./get-static-value"
import { getStaticValue } from "./get-static-value.mjs"

/**
* Get the value of a given node if it's a literal or a template literal.
Expand Down
File renamed without changes.
24 changes: 12 additions & 12 deletions src/index.js → src/index.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { findVariable } from "./find-variable"
import { getFunctionHeadLocation } from "./get-function-head-location"
import { getFunctionNameWithKind } from "./get-function-name-with-kind"
import { getInnermostScope } from "./get-innermost-scope"
import { getPropertyName } from "./get-property-name"
import { getStaticValue } from "./get-static-value"
import { getStringIfConstant } from "./get-string-if-constant"
import { hasSideEffect } from "./has-side-effect"
import { isParenthesized } from "./is-parenthesized"
import { PatternMatcher } from "./pattern-matcher"
import { findVariable } from "./find-variable.mjs"
import { getFunctionHeadLocation } from "./get-function-head-location.mjs"
import { getFunctionNameWithKind } from "./get-function-name-with-kind.mjs"
import { getInnermostScope } from "./get-innermost-scope.mjs"
import { getPropertyName } from "./get-property-name.mjs"
import { getStaticValue } from "./get-static-value.mjs"
import { getStringIfConstant } from "./get-string-if-constant.mjs"
import { hasSideEffect } from "./has-side-effect.mjs"
import { isParenthesized } from "./is-parenthesized.mjs"
import { PatternMatcher } from "./pattern-matcher.mjs"
import {
CALL,
CONSTRUCT,
ESM,
READ,
ReferenceTracker,
} from "./reference-tracker"
} from "./reference-tracker.mjs"
import {
isArrowToken,
isClosingBraceToken,
Expand All @@ -38,7 +38,7 @@ import {
isOpeningBracketToken,
isOpeningParenToken,
isSemicolonToken,
} from "./token-predicate"
} from "./token-predicate.mjs"

export default {
CALL,
Expand Down
2 changes: 1 addition & 1 deletion src/is-parenthesized.js → src/is-parenthesized.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isClosingParenToken, isOpeningParenToken } from "./token-predicate"
import { isClosingParenToken, isOpeningParenToken } from "./token-predicate.mjs"

/**
* Get the left parenthesis of the parent node syntax if it exists.
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions src/reference-tracker.js → src/reference-tracker.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { findVariable } from "./find-variable"
import { getPropertyName } from "./get-property-name"
import { getStringIfConstant } from "./get-string-if-constant"
import { findVariable } from "./find-variable.mjs"
import { getPropertyName } from "./get-property-name.mjs"
import { getStringIfConstant } from "./get-string-if-constant.mjs"

const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u
const has = Function.call.bind(Object.hasOwnProperty)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/find-variable.js → test/find-variable.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "assert"
import eslint from "eslint"
import { findVariable } from "../src/"
import { findVariable } from "../src/index.mjs"

describe("The 'findVariable' function", () => {
function getVariable(code, selector, withString = null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import eslint from "eslint"
import semver from "semver"
import { getFunctionHeadLocation } from "../src/"
import { getFunctionHeadLocation } from "../src/index.mjs"

describe("The 'getFunctionHeadLocation' function", () => {
const expectedResults = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import eslint from "eslint"
import semver from "semver"
import { getFunctionNameWithKind } from "../src/"
import { getFunctionNameWithKind } from "../src/index.mjs"

describe("The 'getFunctionNameWithKind' function", () => {
const expectedResults = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "assert"
import eslint from "eslint"
import { getInnermostScope } from "../src/"
import { getInnermostScope } from "../src/index.mjs"

describe("The 'getInnermostScope' function", () => {
let i = 0
Expand Down
2 changes: 1 addition & 1 deletion test/get-property-name.js → test/get-property-name.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import eslint from "eslint"
import semver from "semver"
import { getPropertyName } from "../src/"
import { getPropertyName } from "../src/index.mjs"

describe("The 'getPropertyName' function", () => {
for (const { code, expected } of [
Expand Down
2 changes: 1 addition & 1 deletion test/get-static-value.js → test/get-static-value.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import eslint from "eslint"
import semver from "semver"
import { getStaticValue } from "../src/"
import { getStaticValue } from "../src/index.mjs"

describe("The 'getStaticValue' function", () => {
for (const { code, expected, noScope = false } of [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "assert"
import eslint from "eslint"
import { getStringIfConstant } from "../src/"
import { getStringIfConstant } from "../src/index.mjs"

describe("The 'getStringIfConstant' function", () => {
for (const { code, expected } of [
Expand Down
4 changes: 2 additions & 2 deletions test/has-side-effect.js → test/has-side-effect.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import assert from "assert"
import dp from "dot-prop"
import eslint from "eslint"
import semver from "semver"
import dp from "dot-prop"
import { hasSideEffect } from "../src/"
import { hasSideEffect } from "../src/index.mjs"

describe("The 'hasSideEffect' function", () => {
for (const { code, key = "body.0.expression", options, expected } of [
Expand Down
2 changes: 1 addition & 1 deletion test/is-parenthesized.js → test/is-parenthesized.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import dotProp from "dot-prop"
import eslint from "eslint"
import { isParenthesized } from "../src/"
import { isParenthesized } from "../src/index.mjs"

describe("The 'isParenthesized' function", () => {
for (const { code, expected } of [
Expand Down
2 changes: 1 addition & 1 deletion test/pattern-matcher.js → test/pattern-matcher.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from "assert"
import { PatternMatcher } from "../src/"
import { PatternMatcher } from "../src/index.mjs"

const NAMED_CAPTURE_GROUP_SUPPORTED = (() => {
try {
Expand Down
2 changes: 1 addition & 1 deletion test/reference-tracker.js → test/reference-tracker.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "assert"
import eslint from "eslint"
import semver from "semver"
import { CALL, CONSTRUCT, ESM, READ, ReferenceTracker } from "../src/"
import { CALL, CONSTRUCT, ESM, READ, ReferenceTracker } from "../src/index.mjs"

const config = {
parserOptions: {
Expand Down
2 changes: 1 addition & 1 deletion test/token-predicate.js → test/token-predicate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
isOpeningBracketToken,
isOpeningParenToken,
isSemicolonToken,
} from "../src/"
} from "../src/index.mjs"

describe("The predicate functions for tokens", () => {
for (const { positive, negative, patterns } of [
Expand Down

0 comments on commit e9fb466

Please sign in to comment.