Skip to content

Commit

Permalink
chore: Convert internal build to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
mskelton committed Nov 6, 2024
1 parent 4c61256 commit 0f4b7b2
Show file tree
Hide file tree
Showing 109 changed files with 305 additions and 299 deletions.
File renamed without changes.
2 changes: 2 additions & 0 deletions index.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line @typescript-eslint/no-require-imports
module.exports = require('./dist/index.cjs')
File renamed without changes.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import plugin from './dist/index.cjs'

export default plugin
3 changes: 0 additions & 3 deletions index.mjs

This file was deleted.

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@
"engines": {
"node": ">=16.6.0"
},
"type": "commonjs",
"types": "./index.d.mts",
"type": "module",
"types": "./index.d.ts",
"exports": {
".": {
"types": "./index.d.mts",
"import": "./index.mjs",
"require": "./dist/index.js"
"types": "./index.d.ts",
"import": "./index.js",
"require": "./index.cjs"
}
},
"files": [
"dist",
"index.mjs",
"index.d.mts"
"index.js",
"index.cjs",
"index.d.ts"
],
"scripts": {
"build": "tsup src/index.ts --format cjs --out-dir dist",
Expand Down
98 changes: 50 additions & 48 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
import globals from 'globals'
import expectExpect from './rules/expect-expect'
import maxExpects from './rules/max-expects'
import maxNestedDescribe from './rules/max-nested-describe'
import missingPlaywrightAwait from './rules/missing-playwright-await'
import noCommentedOutTests from './rules/no-commented-out-tests'
import noConditionalExpect from './rules/no-conditional-expect'
import noConditionalInTest from './rules/no-conditional-in-test'
import noDuplicateHooks from './rules/no-duplicate-hooks'
import noElementHandle from './rules/no-element-handle'
import noEval from './rules/no-eval'
import noFocusedTest from './rules/no-focused-test'
import noForceOption from './rules/no-force-option'
import noGetByTitle from './rules/no-get-by-title'
import noHooks from './rules/no-hooks'
import noNestedStep from './rules/no-nested-step'
import noNetworkidle from './rules/no-networkidle'
import noNthMethods from './rules/no-nth-methods'
import noPagePause from './rules/no-page-pause'
import noRawLocators from './rules/no-raw-locators'
import noRestrictedMatchers from './rules/no-restricted-matchers'
import noSkippedTest from './rules/no-skipped-test'
import noStandaloneExpect from './rules/no-standalone-expect'
import noUnsafeReferences from './rules/no-unsafe-references'
import noUselessAwait from './rules/no-useless-await'
import noUselessNot from './rules/no-useless-not'
import noWaitForSelector from './rules/no-wait-for-selector'
import noWaitForTimeout from './rules/no-wait-for-timeout'
import preferComparisonMatcher from './rules/prefer-comparison-matcher'
import preferEqualityMatcher from './rules/prefer-equality-matcher'
import preferHooksInOrder from './rules/prefer-hooks-in-order'
import preferHooksOnTop from './rules/prefer-hooks-on-top'
import preferLocator from './rules/prefer-locator'
import preferLowercaseTitle from './rules/prefer-lowercase-title'
import preferNativeLocators from './rules/prefer-native-locators'
import preferStrictEqual from './rules/prefer-strict-equal'
import preferToBe from './rules/prefer-to-be'
import preferToContain from './rules/prefer-to-contain'
import preferToHaveCount from './rules/prefer-to-have-count'
import preferToHaveLength from './rules/prefer-to-have-length'
import preferWebFirstAssertions from './rules/prefer-web-first-assertions'
import requireHook from './rules/require-hook'
import requireSoftAssertions from './rules/require-soft-assertions'
import requireToThrowMessage from './rules/require-to-throw-message'
import requireTopLevelDescribe from './rules/require-top-level-describe'
import validDescribeCallback from './rules/valid-describe-callback'
import validExpect from './rules/valid-expect'
import validExpectInPromise from './rules/valid-expect-in-promise'
import validTitle from './rules/valid-title'
import expectExpect from './rules/expect-expect.js'
import maxExpects from './rules/max-expects.js'
import maxNestedDescribe from './rules/max-nested-describe.js'
import missingPlaywrightAwait from './rules/missing-playwright-await.js'
import noCommentedOutTests from './rules/no-commented-out-tests.js'
import noConditionalExpect from './rules/no-conditional-expect.js'
import noConditionalInTest from './rules/no-conditional-in-test.js'
import noDuplicateHooks from './rules/no-duplicate-hooks.js'
import noElementHandle from './rules/no-element-handle.js'
import noEval from './rules/no-eval.js'
import noFocusedTest from './rules/no-focused-test.js'
import noForceOption from './rules/no-force-option.js'
import noGetByTitle from './rules/no-get-by-title.js'
import noHooks from './rules/no-hooks.js'
import noNestedStep from './rules/no-nested-step.js'
import noNetworkidle from './rules/no-networkidle.js'
import noNthMethods from './rules/no-nth-methods.js'
import noPagePause from './rules/no-page-pause.js'
import noRawLocators from './rules/no-raw-locators.js'
import noRestrictedMatchers from './rules/no-restricted-matchers.js'
import noSkippedTest from './rules/no-skipped-test.js'
import noStandaloneExpect from './rules/no-standalone-expect.js'
import noUnsafeReferences from './rules/no-unsafe-references.js'
import noUselessAwait from './rules/no-useless-await.js'
import noUselessNot from './rules/no-useless-not.js'
import noWaitForSelector from './rules/no-wait-for-selector.js'
import noWaitForTimeout from './rules/no-wait-for-timeout.js'
import preferComparisonMatcher from './rules/prefer-comparison-matcher.js'
import preferEqualityMatcher from './rules/prefer-equality-matcher.js'
import preferHooksInOrder from './rules/prefer-hooks-in-order.js'
import preferHooksOnTop from './rules/prefer-hooks-on-top.js'
import preferLocator from './rules/prefer-locator.js'
import preferLowercaseTitle from './rules/prefer-lowercase-title.js'
import preferNativeLocators from './rules/prefer-native-locators.js'
import preferStrictEqual from './rules/prefer-strict-equal.js'
import preferToBe from './rules/prefer-to-be.js'
import preferToContain from './rules/prefer-to-contain.js'
import preferToHaveCount from './rules/prefer-to-have-count.js'
import preferToHaveLength from './rules/prefer-to-have-length.js'
import preferWebFirstAssertions from './rules/prefer-web-first-assertions.js'
import requireHook from './rules/require-hook.js'
import requireSoftAssertions from './rules/require-soft-assertions.js'
import requireToThrowMessage from './rules/require-to-throw-message.js'
import requireTopLevelDescribe from './rules/require-top-level-describe.js'
import validDescribeCallback from './rules/valid-describe-callback.js'
import validExpect from './rules/valid-expect.js'
import validExpectInPromise from './rules/valid-expect-in-promise.js'
import validTitle from './rules/valid-title.js'

const index = {
configs: {},
Expand Down Expand Up @@ -150,6 +150,8 @@ const flatConfig = {
},
}

// @ts-expect-error We author this plugin in ESM, but export as CJS for
// compatibility with ESLint<9. Long term, this will be changed to `export default`.
export = {
...index,
configs: {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/expect-expect.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/expect-expect'
import { javascript, runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/expect-expect.js'
import { javascript, runRuleTester } from '../utils/rule-tester.js'

runRuleTester('expect-expect', rule, {
invalid: [
Expand Down
6 changes: 3 additions & 3 deletions src/rules/expect-expect.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ESTree from 'estree'
import { dig } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { parseFnCall } from '../utils/parseFnCall'
import { dig } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'
import { parseFnCall } from '../utils/parseFnCall.js'

export default createRule({
create(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/max-expects.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/max-expects'
import { javascript, runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/max-expects.js'
import { javascript, runRuleTester } from '../utils/rule-tester.js'

runRuleTester('max-expects', rule, {
invalid: [
Expand Down
6 changes: 3 additions & 3 deletions src/rules/max-expects.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ESTree from 'estree'
import { getParent } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { isTypeOfFnCall, parseFnCall } from '../utils/parseFnCall'
import { getParent } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'
import { isTypeOfFnCall, parseFnCall } from '../utils/parseFnCall.js'

export default createRule({
create(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/max-nested-describe.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/max-nested-describe'
import { javascript, runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/max-nested-describe.js'
import { javascript, runRuleTester } from '../utils/rule-tester.js'

const messageId = 'exceededMaxDepth'

Expand Down
4 changes: 2 additions & 2 deletions src/rules/max-nested-describe.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ESTree from 'estree'
import { createRule } from '../utils/createRule'
import { isTypeOfFnCall } from '../utils/parseFnCall'
import { createRule } from '../utils/createRule.js'
import { isTypeOfFnCall } from '../utils/parseFnCall.js'

export default createRule({
create(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/missing-playwright-await.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import dedent from 'dedent'
import rule from '../../src/rules/missing-playwright-await'
import { javascript, runRuleTester, test } from '../utils/rule-tester'
import rule from '../../src/rules/missing-playwright-await.js'
import { javascript, runRuleTester, test } from '../utils/rule-tester.js'

runRuleTester('missing-playwright-await', rule, {
invalid: [
Expand Down
6 changes: 3 additions & 3 deletions src/rules/missing-playwright-await.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Rule } from 'eslint'
import ESTree from 'estree'
import { getParent, getStringValue, isIdentifier } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { ParsedFnCall, parseFnCall } from '../utils/parseFnCall'
import { getParent, getStringValue, isIdentifier } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'
import { ParsedFnCall, parseFnCall } from '../utils/parseFnCall.js'

const validTypes = new Set([
'AwaitExpression',
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-commented-out-tests.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-commented-out-tests'
import { javascript, runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/no-commented-out-tests.js'
import { javascript, runRuleTester } from '../utils/rule-tester.js'

const messageId = 'commentedTests'

Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-commented-out-tests.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rule } from 'eslint'
import * as ESTree from 'estree'
import { createRule } from '../utils/createRule'
import { createRule } from '../utils/createRule.js'

function getTestNames(context: Rule.RuleContext) {
const aliases = context.settings.playwright?.globalAliases?.test ?? []
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-conditional-expect.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-conditional-expect'
import { javascript, runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/no-conditional-expect.js'
import { javascript, runRuleTester } from '../utils/rule-tester.js'

const messageId = 'conditionalExpect'

Expand Down
8 changes: 4 additions & 4 deletions src/rules/no-conditional-expect.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Rule, Scope } from 'eslint'
import * as ESTree from 'estree'
import { getParent, isPropertyAccessor } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { isTypeOfFnCall, parseFnCall } from '../utils/parseFnCall'
import { KnownCallExpression } from '../utils/types'
import { getParent, isPropertyAccessor } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'
import { isTypeOfFnCall, parseFnCall } from '../utils/parseFnCall.js'
import { KnownCallExpression } from '../utils/types.js'

const isCatchCall = (
node: ESTree.CallExpression,
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-conditional-in-test.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-conditional-in-test'
import { javascript, runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/no-conditional-in-test.js'
import { javascript, runRuleTester } from '../utils/rule-tester.js'

const messageId = 'conditionalInTest'

Expand Down
6 changes: 3 additions & 3 deletions src/rules/no-conditional-in-test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Rule } from 'eslint'
import { findParent } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { isTypeOfFnCall } from '../utils/parseFnCall'
import { findParent } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'
import { isTypeOfFnCall } from '../utils/parseFnCall.js'

export default createRule({
create(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-duplicate-hooks.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-duplicate-hooks'
import { javascript, runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/no-duplicate-hooks.js'
import { javascript, runRuleTester } from '../utils/rule-tester.js'

runRuleTester('basic describe block', rule, {
invalid: [
Expand Down
6 changes: 3 additions & 3 deletions src/rules/no-duplicate-hooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getStringValue } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { isTypeOfFnCall, parseFnCall } from '../utils/parseFnCall'
import { getStringValue } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'
import { isTypeOfFnCall, parseFnCall } from '../utils/parseFnCall.js'

export default createRule({
create(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-element-handle.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-element-handle'
import { runRuleTester, test } from '../utils/rule-tester'
import rule from '../../src/rules/no-element-handle.js'
import { runRuleTester, test } from '../utils/rule-tester.js'

runRuleTester('no-element-handle', rule, {
invalid: [
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-element-handle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AST } from 'eslint'
import ESTree from 'estree'
import { isPageMethod } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { isPageMethod } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'

function getPropertyRange(node: ESTree.Node): AST.Range {
return node.type === 'Identifier'
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-eval.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-eval'
import { javascript, runRuleTester, test } from '../utils/rule-tester'
import rule from '../../src/rules/no-eval.js'
import { javascript, runRuleTester, test } from '../utils/rule-tester.js'

runRuleTester('no-eval', rule, {
invalid: [
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-eval.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isPageMethod } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { isPageMethod } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'

export default createRule({
create(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-focused-test.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-focused-test'
import { runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/no-focused-test.js'
import { runRuleTester } from '../utils/rule-tester.js'

const messageId = 'noFocusedTest'

Expand Down
6 changes: 3 additions & 3 deletions src/rules/no-focused-test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getStringValue } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { parseFnCall } from '../utils/parseFnCall'
import { getStringValue } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'
import { parseFnCall } from '../utils/parseFnCall.js'

export default createRule({
create(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-force-option.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-force-option'
import { runRuleTester, test } from '../utils/rule-tester'
import rule from '../../src/rules/no-force-option.js'
import { runRuleTester, test } from '../utils/rule-tester.js'

const messageId = 'noForceOption'

Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-force-option.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ESTree from 'estree'
import { getStringValue, isBooleanLiteral } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { getStringValue, isBooleanLiteral } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'

function isForceOptionEnabled(node: ESTree.CallExpression) {
const arg = node.arguments.at(-1)
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-get-by-title.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-get-by-title'
import { runRuleTester, test } from '../utils/rule-tester'
import rule from '../../src/rules/no-get-by-title.js'
import { runRuleTester, test } from '../utils/rule-tester.js'

const messageId = 'noGetByTitle'

Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-get-by-title.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isPageMethod } from '../utils/ast'
import { createRule } from '../utils/createRule'
import { isPageMethod } from '../utils/ast.js'
import { createRule } from '../utils/createRule.js'

export default createRule({
create(context) {
Expand Down
4 changes: 2 additions & 2 deletions src/rules/no-hooks.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rule from '../../src/rules/no-hooks'
import { runRuleTester } from '../utils/rule-tester'
import rule from '../../src/rules/no-hooks.js'
import { runRuleTester } from '../utils/rule-tester.js'

const messageId = 'unexpectedHook'

Expand Down
Loading

0 comments on commit 0f4b7b2

Please sign in to comment.