From 46fd5e190205411a392ec3b32b15406da84f0e04 Mon Sep 17 00:00:00 2001 From: mizdra Date: Thu, 23 Dec 2021 01:37:11 +0900 Subject: [PATCH 1/2] chore(BREAKING CHANGES): convert cjs to esm --- .eslintrc.js => .eslintrc.cjs | 4 +++- lib/index.js | 6 ++++-- lib/rules/require-size-attributes.js | 5 +++-- package.json | 3 ++- tests/lib/rules/require-size-attributes.js | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) rename .eslintrc.js => .eslintrc.cjs (69%) diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 69% rename from .eslintrc.js rename to .eslintrc.cjs index d9ff460..c98d89b 100644 --- a/.eslintrc.js +++ b/.eslintrc.cjs @@ -4,5 +4,7 @@ module.exports = { env: { node: true, }, - rules: {}, + rules: { + 'import/no-default-export': 'off', + }, }; diff --git a/lib/index.js b/lib/index.js index d6d2128..22193ba 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,8 @@ -module.exports = { +import requireSizeAttributes from './rules/require-size-attributes.js'; + +export default { rules: { - 'require-size-attributes': require('./rules/require-size-attributes'), + 'require-size-attributes': requireSizeAttributes, }, configs: { recommended: { diff --git a/lib/rules/require-size-attributes.js b/lib/rules/require-size-attributes.js index ec25949..392a044 100644 --- a/lib/rules/require-size-attributes.js +++ b/lib/rules/require-size-attributes.js @@ -1,11 +1,12 @@ // @ts-check -const { elementType, hasProp } = require('jsx-ast-utils'); +import pkg from 'jsx-ast-utils'; +const { elementType, hasProp } = pkg; const MEDIA_ELEMENTS = ['img']; /** @type import('eslint').Rule.RuleModule */ -module.exports = { +export default { meta: { docs: { description: 'Forbid media element without an explicit size attributes', diff --git a/package.json b/package.json index f514b54..9f90fe6 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "private": false, "license": "MIT", "author": "mizdra", - "main": "lib/index.js", + "type": "module", + "exports": "./lib/index.js", "scripts": { "check": "run-p -l check:*", "check:eslint": "eslint '**/*.js'", diff --git a/tests/lib/rules/require-size-attributes.js b/tests/lib/rules/require-size-attributes.js index 4b8d6f1..cde6268 100644 --- a/tests/lib/rules/require-size-attributes.js +++ b/tests/lib/rules/require-size-attributes.js @@ -1,7 +1,7 @@ // @ts-check -const { RuleTester } = require('eslint'); -const rule = require('../../../lib/rules/require-size-attributes'); +import { RuleTester } from 'eslint'; +import rule from '../../../lib/rules/require-size-attributes.js'; /** @type import('eslint').Linter.ParserOptions */ const parserOptions = { From 2a97ffba28749d0311f068f2eacd96180686bf40 Mon Sep 17 00:00:00 2001 From: mizdra Date: Sat, 25 Dec 2021 01:51:24 +0900 Subject: [PATCH 2/2] ci: drop node 12 --- .github/workflows/nodejs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index bb3aa9f..5734c25 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -28,7 +28,7 @@ jobs: test: strategy: matrix: - node: [10, 12, 14] + node: [14, 16] eslint: [3, 4, 5, 6, 7] runs-on: ubuntu-latest steps: