From 0959d494dead576a218576a0aac2b53ae324d422 Mon Sep 17 00:00:00 2001 From: strawberry-choco Date: Tue, 3 Dec 2024 13:42:29 +0100 Subject: [PATCH] finishing touch for v1 release (#254) Signed-off-by: Kangrui Johann Ye --- package.json | 2 +- packages/eslint-plugin-angular/package.json | 2 +- packages/eslint-plugin-node/package.json | 2 +- .../eslint-plugin-node/src/configs/node.ts | 2 + packages/eslint-plugin-react/package.json | 2 +- .../eslint-plugin-typescript/package.json | 2 +- .../src/configs/custom.ts | 2 - .../src/rules/index.ts | 2 - .../src/rules/typescript/no-moment-js.spec.ts | 37 --------------- .../src/rules/typescript/no-moment-js.ts | 47 ------------------- packages/eslint-plugin-vue/package.json | 2 +- 11 files changed, 8 insertions(+), 94 deletions(-) delete mode 100644 packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.spec.ts delete mode 100644 packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.ts diff --git a/package.json b/package.json index a33fa8d..b6f44fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cloudflight/eslint-plugin", - "version": "1.0.0-rc14", + "version": "1.0.0", "private": true, "volta": { "node": "20.18.0", diff --git a/packages/eslint-plugin-angular/package.json b/packages/eslint-plugin-angular/package.json index 9e3c035..cc60db8 100644 --- a/packages/eslint-plugin-angular/package.json +++ b/packages/eslint-plugin-angular/package.json @@ -1,6 +1,6 @@ { "name": "@cloudflight/eslint-plugin-angular", - "version": "1.0.0-rc14", + "version": "1.0.0", "description": "Cloudflight eslint-plugin & eslint-config for angular", "volta": { "extends": "../../package.json" diff --git a/packages/eslint-plugin-node/package.json b/packages/eslint-plugin-node/package.json index 4e9d6b8..e8a0b20 100644 --- a/packages/eslint-plugin-node/package.json +++ b/packages/eslint-plugin-node/package.json @@ -1,6 +1,6 @@ { "name": "@cloudflight/eslint-plugin-node", - "version": "1.0.0-rc14", + "version": "1.0.0", "description": "Cloudflight eslint-plugin & eslint-config for node", "volta": { "extends": "../../package.json" diff --git a/packages/eslint-plugin-node/src/configs/node.ts b/packages/eslint-plugin-node/src/configs/node.ts index df22694..ddb6581 100644 --- a/packages/eslint-plugin-node/src/configs/node.ts +++ b/packages/eslint-plugin-node/src/configs/node.ts @@ -21,4 +21,6 @@ export const nodeRules: TSESLint.Linter.RulesRecord = { // we use typescript, so node-builtins are typed and checked via TS 'n/no-unsupported-features/node-builtins': 'off', + + 'n/prefer-node-protocol': 'error', }; diff --git a/packages/eslint-plugin-react/package.json b/packages/eslint-plugin-react/package.json index f70af5a..bb4ec50 100644 --- a/packages/eslint-plugin-react/package.json +++ b/packages/eslint-plugin-react/package.json @@ -1,6 +1,6 @@ { "name": "@cloudflight/eslint-plugin-react", - "version": "1.0.0-rc14", + "version": "1.0.0", "description": "Cloudflight eslint-plugin & eslint-config for React", "volta": { "extends": "../../package.json" diff --git a/packages/eslint-plugin-typescript/package.json b/packages/eslint-plugin-typescript/package.json index 3310666..9b519a8 100644 --- a/packages/eslint-plugin-typescript/package.json +++ b/packages/eslint-plugin-typescript/package.json @@ -1,6 +1,6 @@ { "name": "@cloudflight/eslint-plugin-typescript", - "version": "1.0.0-rc14", + "version": "1.0.0", "description": "Cloudflight eslint-plugin & eslint-config for typescript", "volta": { "extends": "../../package.json" diff --git a/packages/eslint-plugin-typescript/src/configs/custom.ts b/packages/eslint-plugin-typescript/src/configs/custom.ts index ddd9060..86e3d84 100644 --- a/packages/eslint-plugin-typescript/src/configs/custom.ts +++ b/packages/eslint-plugin-typescript/src/configs/custom.ts @@ -1,11 +1,9 @@ import type {TSESLint} from '@typescript-eslint/utils'; -import {NoMomentJsRuleName} from '../rules/typescript/no-moment-js'; import {NoOnEventAssignName} from '../rules/typescript/no-on-event-assign'; const pluginPrefix = '@cloudflight/typescript'; export const customRules: TSESLint.Linter.RulesRecord = { - [`${pluginPrefix}/${NoMomentJsRuleName}`]: ['error'], [`${pluginPrefix}/${NoOnEventAssignName}`]: ['error'], }; diff --git a/packages/eslint-plugin-typescript/src/rules/index.ts b/packages/eslint-plugin-typescript/src/rules/index.ts index c9e774b..1d4b8ad 100644 --- a/packages/eslint-plugin-typescript/src/rules/index.ts +++ b/packages/eslint-plugin-typescript/src/rules/index.ts @@ -1,10 +1,8 @@ import {TSESLint} from '@typescript-eslint/utils'; -import {NoMomentJsRule, NoMomentJsRuleName} from './typescript/no-moment-js'; import {NoOnEventAssign, NoOnEventAssignName} from './typescript/no-on-event-assign'; const rules: Record> = { - [NoMomentJsRuleName]: NoMomentJsRule, [NoOnEventAssignName]: NoOnEventAssign, }; diff --git a/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.spec.ts b/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.spec.ts deleted file mode 100644 index 1673812..0000000 --- a/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.spec.ts +++ /dev/null @@ -1,37 +0,0 @@ -import {AST_NODE_TYPES, TSESLint} from '@typescript-eslint/utils'; - -import {NoMomentJsRule, NoMomentJsRuleName} from './no-moment-js'; - -const ruleTester = new TSESLint.RuleTester({ - parser: require.resolve('@typescript-eslint/parser'), -}); - -ruleTester.run(NoMomentJsRuleName, NoMomentJsRule, { - valid: ["import('foo').then()", "import { fn } from 'foo'", "const { fn } = require('foo')"], - invalid: [ - { - code: "import('moment').then(()=>{})", - errors: [{type: AST_NODE_TYPES.ImportExpression, messageId: 'noMomentJs'}], - }, - { - code: "const fn = await import('moment')", - errors: [{type: AST_NODE_TYPES.ImportExpression, messageId: 'noMomentJs'}], - }, - { - code: "import moment from 'moment'", - errors: [{type: AST_NODE_TYPES.ImportDeclaration, messageId: 'noMomentJs'}], - }, - { - code: "import * as moment from 'moment'", - errors: [{type: AST_NODE_TYPES.ImportDeclaration, messageId: 'noMomentJs'}], - }, - { - code: "const moment = require('moment')", - errors: [{type: AST_NODE_TYPES.CallExpression, messageId: 'noMomentJs'}], - }, - { - code: "const format = require('moment').format", - errors: [{type: AST_NODE_TYPES.CallExpression, messageId: 'noMomentJs'}], - }, - ], -}); diff --git a/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.ts b/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.ts deleted file mode 100644 index f3444c6..0000000 --- a/packages/eslint-plugin-typescript/src/rules/typescript/no-moment-js.ts +++ /dev/null @@ -1,47 +0,0 @@ -import {createRule} from '../../util/create-rule'; - -export const NoMomentJsRuleName = 'no-moment-js'; -/** - * Comment needed to prevent type declaration generation, which is broken. - * @internal - */ -export const NoMomentJsRule = createRule<[], 'noMomentJs'>({ - name: NoMomentJsRuleName, - meta: { - type: 'problem', - fixable: 'code', - docs: { - description: 'Enforces that all packages have absolute versions.', - }, - schema: [], - messages: { - noMomentJs: 'Momentjs is deprecated. It is recommended to use luxon or date-fns instead.', - }, - }, - defaultOptions: [], - create(context) { - return { - ImportExpression(node) { - if (node.source.type === 'Literal' && node.source.value === 'moment') { - context.report({node, messageId: 'noMomentJs'}); - } - }, - ImportDeclaration(node) { - if (node.source.type === 'Literal' && node.source.value === 'moment') { - context.report({node, messageId: 'noMomentJs'}); - } - }, - CallExpression(node) { - if (node.callee.type !== 'Identifier' || node.callee.name !== 'require') { - return; - } - - const sourceToRequire = node.arguments[0]; - - if (sourceToRequire?.type === 'Literal' && sourceToRequire.value === 'moment') { - context.report({node, messageId: 'noMomentJs'}); - } - }, - }; - }, -}); diff --git a/packages/eslint-plugin-vue/package.json b/packages/eslint-plugin-vue/package.json index 80a4364..1c614e6 100644 --- a/packages/eslint-plugin-vue/package.json +++ b/packages/eslint-plugin-vue/package.json @@ -1,6 +1,6 @@ { "name": "@cloudflight/eslint-plugin-vue", - "version": "1.0.0-rc14", + "version": "1.0.0", "description": "Cloudflight eslint-plugin & eslint-config for vue", "volta": { "extends": "../../package.json"