@2digits/eslint-plugin 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -11
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
3
|
declare const plugin: {
|
|
4
4
|
rules: {
|
|
5
|
-
'type-param-names': RuleModule<"prefix" | "initial" | "remainder" | "regex", [], RuleListener>;
|
|
5
|
+
'type-param-names': _typescript_eslint_utils_ts_eslint.RuleModule<"prefix" | "initial" | "remainder" | "regex", [], _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
6
6
|
};
|
|
7
7
|
configs: {
|
|
8
8
|
recommended: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
2
|
|
|
3
3
|
declare const plugin: {
|
|
4
4
|
rules: {
|
|
5
|
-
'type-param-names': RuleModule<"prefix" | "initial" | "remainder" | "regex", [], RuleListener>;
|
|
5
|
+
'type-param-names': _typescript_eslint_utils_ts_eslint.RuleModule<"prefix" | "initial" | "remainder" | "regex", [], _typescript_eslint_utils_ts_eslint.RuleListener>;
|
|
6
6
|
};
|
|
7
7
|
configs: {
|
|
8
8
|
recommended: {
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var utils = require('@typescript-eslint/utils');
|
|
|
4
4
|
var magicRegexp = require('magic-regexp');
|
|
5
5
|
var tsPattern = require('ts-pattern');
|
|
6
6
|
|
|
7
|
-
var c="@2digits/eslint-plugin";var g="1.0.
|
|
7
|
+
var c="@2digits/eslint-plugin";var g="1.0.5",f={url:"https://github.com/2digits-agency/configs",directory:"packages/eslint-plugin"};var u=utils.ESLintUtils.RuleCreator(r=>`${f.url}/blob/${c}@${g}/packages/eslint/src/rules/${r}.ts`);var y={plugins:["@2digits"],rules:{"@2digits/type-param-names":"error"}};var i=magicRegexp.anyOf("T","$").at.lineStart(),p=magicRegexp.letter.uppercase,h=magicRegexp.oneOrMore(magicRegexp.letter),j=magicRegexp.digit.times.any().at.lineEnd(),k=magicRegexp.createRegExp(i),M=magicRegexp.createRegExp(i,p),$=magicRegexp.createRegExp(i,p,h),b=magicRegexp.createRegExp(i,p,h,j),a={prefix:"prefix",initial:"initial",remainder:"remainder",regex:"regex"},T=u({name:__filename,meta:{type:"suggestion",docs:{description:"Enforce giving proper names to type parameters when there are two or more",recommended:"recommended"},schema:[],messages:{prefix:'Type parameter {{name}} should have a prefix of "T" or "$"',initial:"Type parameter {{name}}'s name should start with an uppercase letter",remainder:"Type parameter {{name}}'s name should contain at least one lowercase letter",regex:"Type parameter {{name}} should match the regex {{regex}}"}},defaultOptions:[],create(r){return {TSTypeParameterDeclaration(w){let{params:n}=w;if(!(n.length===1&&n.at(0)?.name.name==="T"))for(let m of n){let{name:d}=m.name,l=tsPattern.match(d).with(tsPattern.P.string.regex(b),()=>!1).with(tsPattern.P.not(tsPattern.P.string.regex(k)),()=>a.prefix).with(tsPattern.P.not(tsPattern.P.string.regex(M)),()=>a.initial).with(tsPattern.P.not(tsPattern.P.string.regex($)),()=>a.remainder).otherwise(()=>!1);l&&r.report({node:m,messageId:l,data:{name:d}});}}}}});var R={"type-param-names":T};var L={rules:R,configs:{recommended:y}},Q=L;
|
|
8
8
|
|
|
9
9
|
module.exports = Q;
|
|
10
10
|
//# sourceMappingURL=out.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/index.ts","../package.json","../src/configs/recommended.ts","../src/rules/type-param-names.ts","../src/rules/index.ts","../src/index.ts"],"names":["ESLintUtils","name","version","repository","createRule","rule","recommended","anyOf","createRegExp","digit","letter","oneOrMore","match","P","prefix","initial","remainder","digits","PrefixRegex","InitialRegex","RemainderRegex","TypeParamRegex","MessageId","typeParamNames","context","node","params","param","messageId","rules","plugin","src_default"],"mappings":"AAAA,OAAS,eAAAA,MAAmB,2BCC1B,IAAAC,EAAQ,yBAER,IAAAC,EAAW,QACXC,EAAc,CACZ,IAAO,4CACP,UAAa,wBACf,EDFK,IAAMC,EAAaJ,EAAY,YACnCK,GAAS,GAAGF,EAAW,GAAG,SAASF,CAAI,IAAIC,CAAO,8BAA8BG,CAAI,KACvF,EEFO,IAAMC,EAA2B,CACtC,QAAS,CAAC,UAAU,EACpB,MAAO,CACL,4BAA6B,OAC/B,CACF,ECRA,OAAS,SAAAC,EAAO,gBAAAC,EAAc,SAAAC,EAAO,UAAAC,EAAQ,aAAAC,MAAiB,eAC9D,OAAS,SAAAC,EAAO,KAAAC,MAAS,
|
|
1
|
+
{"version":3,"sources":["../src/utils/index.ts","../package.json","../src/configs/recommended.ts","../src/rules/type-param-names.ts","../src/rules/index.ts","../src/index.ts"],"names":["ESLintUtils","name","version","repository","createRule","rule","recommended","anyOf","createRegExp","digit","letter","oneOrMore","match","P","prefix","initial","remainder","digits","PrefixRegex","InitialRegex","RemainderRegex","TypeParamRegex","MessageId","typeParamNames","context","node","params","param","messageId","rules","plugin","src_default"],"mappings":"AAAA,OAAS,eAAAA,MAAmB,2BCC1B,IAAAC,EAAQ,yBAER,IAAAC,EAAW,QACXC,EAAc,CACZ,IAAO,4CACP,UAAa,wBACf,EDFK,IAAMC,EAAaJ,EAAY,YACnCK,GAAS,GAAGF,EAAW,GAAG,SAASF,CAAI,IAAIC,CAAO,8BAA8BG,CAAI,KACvF,EEFO,IAAMC,EAA2B,CACtC,QAAS,CAAC,UAAU,EACpB,MAAO,CACL,4BAA6B,OAC/B,CACF,ECRA,O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O,MAAMO,CAAc,CAAC,EAAG,IAAME,EAAU,SAAS,EACrE,UAAU,IAAM,EAAc,EAEjCM,GACEJ,EAAQ,OAAO,CACb,KAAMG,EACN,UAAAC,EACA,KAAM,CAAE,KAAA3B,CAAK,CACf,CAAC,CACL,CACF,CACF,CACF,CACF,CAAC,ECjEM,IAAM4B,EAAQ,CACnB,mBAAmCN,CACrC,ECHA,IAAMO,EAAS,CACb,MAAaD,EACb,QAAS,CACP,YAAAvB,CACF,CACF,EAEOyB,EAAQD","sourcesContent":["import { ESLintUtils } from '@typescript-eslint/utils';\nimport type { ESLintConfig } from 'eslint-define-config';\n\nimport { name, repository, version } from '../../package.json';\n\nexport const createRule = ESLintUtils.RuleCreator(\n (rule) => `${repository.url}/blob/${name}@${version}/packages/eslint/src/rules/${rule}.ts`,\n);\n\nexport function defineConfig<TConfig extends ESLintConfig>(config: TConfig): TConfig {\n return config;\n}\n","{\n \"name\": \"@2digits/eslint-plugin\",\n \"description\": \"An eslint plugin that provides a set of rules to enforce best practices for 2digits projects\",\n \"version\": \"1.0.5\",\n \"repository\": {\n \"url\": \"https://github.com/2digits-agency/configs\",\n \"directory\": \"packages/eslint-plugin\"\n },\n \"license\": \"MIT\",\n \"public\": true,\n \"sideEffects\": false,\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"import\": {\n \"default\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\"\n },\n \"require\": {\n \"default\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n }\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint --ignore-path ../../.gitignore .\",\n \"types\": \"tsc --noEmit\",\n \"test\": \"vitest --run\"\n },\n \"keywords\": [\n \"eslint\",\n \"eslint-plugin\",\n \"2digits\"\n ],\n \"files\": [\n \"dist\"\n ],\n \"dependencies\": {\n \"@typescript-eslint/utils\": \"7.1.0\",\n \"eslint\": \"^8.57.0\",\n \"magic-regexp\": \"^0.7.0\",\n \"ts-pattern\": \"^5.0.8\"\n },\n \"devDependencies\": {\n \"@2digits/tsconfig\": \"0.3.4\",\n \"@typescript-eslint/rule-tester\": \"7.1.0\",\n \"eslint-define-config\": \"^2.1.0\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.3.3\",\n \"vitest\": \"^1.3.1\"\n },\n \"eslintConfig\": {\n \"ignorePatterns\": [\n \"fixtures\"\n ]\n }\n}\n","import type { Rules } from 'eslint-define-config';\n\nimport type { rules } from '../rules';\nimport { defineConfig } from '../utils';\n\nexport const recommended = defineConfig({\n plugins: ['@2digits'],\n rules: {\n '@2digits/type-param-names': 'error',\n } satisfies Record<`@2digits/${keyof typeof rules}`, Rules[string]>,\n});\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type _ from '@typescript-eslint/utils/ts-eslint';\nimport { anyOf, createRegExp, digit, letter, oneOrMore } from 'magic-regexp';\nimport { match, P } from 'ts-pattern';\n\nimport { createRule } from '../utils';\n\nconst prefix = anyOf('T', '$').at.lineStart();\nconst initial = letter.uppercase;\nconst remainder = oneOrMore(letter);\nconst digits = digit.times.any().at.lineEnd();\n\nconst PrefixRegex = createRegExp(prefix);\nconst InitialRegex = createRegExp(prefix, initial);\nconst RemainderRegex = createRegExp(prefix, initial, remainder);\nconst TypeParamRegex = createRegExp(prefix, initial, remainder, digits);\n\ntype MessageId = (typeof MessageId)[keyof typeof MessageId];\nconst MessageId = {\n prefix: 'prefix',\n initial: 'initial',\n remainder: 'remainder',\n regex: 'regex',\n} as const;\n\nexport const typeParamNames = createRule<[], MessageId>({\n name: __filename,\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Enforce giving proper names to type parameters when there are two or more',\n recommended: 'recommended',\n },\n schema: [],\n messages: {\n prefix: 'Type parameter {{name}} should have a prefix of \"T\" or \"$\"',\n initial: \"Type parameter {{name}}'s name should start with an uppercase letter\",\n remainder: \"Type parameter {{name}}'s name should contain at least one lowercase letter\",\n regex: 'Type parameter {{name}} should match the regex {{regex}}',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n TSTypeParameterDeclaration(node) {\n const { params } = node;\n\n if (params.length === 1 && params.at(0)?.name.name === 'T') return;\n\n for (const param of params) {\n const { name } = param.name;\n\n const messageId = match(name)\n .with(P.string.regex(TypeParamRegex), () => false as const)\n .with(P.not(P.string.regex(PrefixRegex)), () => MessageId.prefix)\n .with(P.not(P.string.regex(InitialRegex)), () => MessageId.initial)\n .with(P.not(P.string.regex(RemainderRegex)), () => MessageId.remainder)\n .otherwise(() => false as const);\n\n messageId &&\n context.report({\n node: param,\n messageId,\n data: { name },\n });\n }\n },\n };\n },\n});\n","import * as typeParamNames from './type-param-names';\n\nexport type * from './type-param-names';\n\nexport const rules = {\n 'type-param-names': typeParamNames.typeParamNames,\n};\n","import { recommended } from './configs/recommended';\nimport * as rules from './rules';\n\nconst plugin = {\n rules: rules.rules,\n configs: {\n recommended,\n },\n};\n\nexport default plugin;\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
3
3
|
import { anyOf, letter, oneOrMore, digit, createRegExp } from 'magic-regexp';
|
|
4
4
|
import { match, P } from 'ts-pattern';
|
|
5
5
|
|
|
6
|
-
var C=()=>fileURLToPath(import.meta.url);var t=C();var g="@2digits/eslint-plugin";var f="1.0.
|
|
6
|
+
var C=()=>fileURLToPath(import.meta.url);var t=C();var g="@2digits/eslint-plugin";var f="1.0.5",u={url:"https://github.com/2digits-agency/configs",directory:"packages/eslint-plugin"};var x=ESLintUtils.RuleCreator(n=>`${u.url}/blob/${g}@${f}/packages/eslint/src/rules/${n}.ts`);var y={plugins:["@2digits"],rules:{"@2digits/type-param-names":"error"}};var r=anyOf("T","$").at.lineStart(),m=letter.uppercase,T=oneOrMore(letter),$=digit.times.any().at.lineEnd(),b=createRegExp(r),S=createRegExp(r,m),_=createRegExp(r,m,T),L=createRegExp(r,m,T,$),p={prefix:"prefix",initial:"initial",remainder:"remainder",regex:"regex"},R=x({name:t,meta:{type:"suggestion",docs:{description:"Enforce giving proper names to type parameters when there are two or more",recommended:"recommended"},schema:[],messages:{prefix:'Type parameter {{name}} should have a prefix of "T" or "$"',initial:"Type parameter {{name}}'s name should start with an uppercase letter",remainder:"Type parameter {{name}}'s name should contain at least one lowercase letter",regex:"Type parameter {{name}} should match the regex {{regex}}"}},defaultOptions:[],create(n){return {TSTypeParameterDeclaration(P$1){let{params:o}=P$1;if(!(o.length===1&&o.at(0)?.name.name==="T"))for(let d of o){let{name:l}=d.name,c=match(l).with(P.string.regex(L),()=>!1).with(P.not(P.string.regex(b)),()=>p.prefix).with(P.not(P.string.regex(S)),()=>p.initial).with(P.not(P.string.regex(_)),()=>p.remainder).otherwise(()=>!1);c&&n.report({node:d,messageId:c,data:{name:l}});}}}}});var w={"type-param-names":R};var O={rules:w,configs:{recommended:y}},Z=O;
|
|
7
7
|
|
|
8
8
|
export { Z as default };
|
|
9
9
|
//# sourceMappingURL=out.js.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.0.
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.0.2_postcss@8.4.35_typescript@5.3.3/node_modules/tsup/assets/esm_shims.js","../src/utils/index.ts","../package.json","../src/configs/recommended.ts","../src/rules/type-param-names.ts","../src/rules/index.ts","../src/index.ts"],"names":["fileURLToPath","getFilename","__filename","ESLintUtils","name","version","repository","createRule","rule","recommended","anyOf","createRegExp","digit","letter","oneOrMore","match","P","prefix","initial","remainder","digits","PrefixRegex","InitialRegex","RemainderRegex","TypeParamRegex","MessageId","typeParamNames","context","node","params","param","messageId","rules","plugin","src_default"],"mappings":"AACA,OAAS,iBAAAA,MAAqB,MAG9B,IAAMC,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KAEvD,QAAWC,KAASD,EAAQ,CAC1B,GAAM,CAAE,KAAAzB,CAAK,EAAI0B,EAAM,KAEjBC,EAAYhB,EAAMX,CAAI,EACzB,KAAKY,EAAE,OAAO,MAAMQ,CAAc,EAAG,IAAM,EAAc,EACzD,KAAKR,EAAE,IAAIA,EAAE,OAAO,MAAMK,CAAW,CAAC,EAAG,IAAMI,EAAU,MAAM,EAC/D,KAAKT,EAAE,IAAIA,EAAE,OAAO,MAAMM,CAAY,CAAC,EAAG,IAAMG,EAAU,OAAO,EACjE,KAAKT,EAAE,IAAIA,EAAE,OAAO,MAAMO,CAAc,CAAC,EAAG,IAAME,EAAU,SAAS,EACrE,UAAU,IAAM,EAAc,EAEjCM,GACEJ,EAAQ,OAAO,CACb,KAAMG,EACN,UAAAC,EACA,KAAM,CAAE,KAAA3B,CAAK,CACf,CAAC,CACL,CACF,CACF,CACF,CACF,CAAC,ECjEM,IAAM4B,EAAQ,CACnB,mBAAmCN,CACrC,ECHA,IAAMO,EAAS,CACb,MAAaD,EACb,QAAS,CACP,YAAAvB,CACF,CACF,EAEOyB,EAAQD","sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n","import { ESLintUtils } from '@typescript-eslint/utils';\nimport type { ESLintConfig } from 'eslint-define-config';\n\nimport { name, repository, version } from '../../package.json';\n\nexport const createRule = ESLintUtils.RuleCreator(\n (rule) => `${repository.url}/blob/${name}@${version}/packages/eslint/src/rules/${rule}.ts`,\n);\n\nexport function defineConfig<TConfig extends ESLintConfig>(config: TConfig): TConfig {\n return config;\n}\n","{\n \"name\": \"@2digits/eslint-plugin\",\n \"description\": \"An eslint plugin that provides a set of rules to enforce best practices for 2digits projects\",\n \"version\": \"1.0.5\",\n \"repository\": {\n \"url\": \"https://github.com/2digits-agency/configs\",\n \"directory\": \"packages/eslint-plugin\"\n },\n \"license\": \"MIT\",\n \"public\": true,\n \"sideEffects\": false,\n \"exports\": {\n \"./package.json\": \"./package.json\",\n \".\": {\n \"import\": {\n \"default\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\"\n },\n \"require\": {\n \"default\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\"\n }\n }\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.mts\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"lint\": \"eslint --ignore-path ../../.gitignore .\",\n \"types\": \"tsc --noEmit\",\n \"test\": \"vitest --run\"\n },\n \"keywords\": [\n \"eslint\",\n \"eslint-plugin\",\n \"2digits\"\n ],\n \"files\": [\n \"dist\"\n ],\n \"dependencies\": {\n \"@typescript-eslint/utils\": \"7.1.0\",\n \"eslint\": \"^8.57.0\",\n \"magic-regexp\": \"^0.7.0\",\n \"ts-pattern\": \"^5.0.8\"\n },\n \"devDependencies\": {\n \"@2digits/tsconfig\": \"0.3.4\",\n \"@typescript-eslint/rule-tester\": \"7.1.0\",\n \"eslint-define-config\": \"^2.1.0\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.3.3\",\n \"vitest\": \"^1.3.1\"\n },\n \"eslintConfig\": {\n \"ignorePatterns\": [\n \"fixtures\"\n ]\n }\n}\n","import type { Rules } from 'eslint-define-config';\n\nimport type { rules } from '../rules';\nimport { defineConfig } from '../utils';\n\nexport const recommended = defineConfig({\n plugins: ['@2digits'],\n rules: {\n '@2digits/type-param-names': 'error',\n } satisfies Record<`@2digits/${keyof typeof rules}`, Rules[string]>,\n});\n","// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type _ from '@typescript-eslint/utils/ts-eslint';\nimport { anyOf, createRegExp, digit, letter, oneOrMore } from 'magic-regexp';\nimport { match, P } from 'ts-pattern';\n\nimport { createRule } from '../utils';\n\nconst prefix = anyOf('T', '$').at.lineStart();\nconst initial = letter.uppercase;\nconst remainder = oneOrMore(letter);\nconst digits = digit.times.any().at.lineEnd();\n\nconst PrefixRegex = createRegExp(prefix);\nconst InitialRegex = createRegExp(prefix, initial);\nconst RemainderRegex = createRegExp(prefix, initial, remainder);\nconst TypeParamRegex = createRegExp(prefix, initial, remainder, digits);\n\ntype MessageId = (typeof MessageId)[keyof typeof MessageId];\nconst MessageId = {\n prefix: 'prefix',\n initial: 'initial',\n remainder: 'remainder',\n regex: 'regex',\n} as const;\n\nexport const typeParamNames = createRule<[], MessageId>({\n name: __filename,\n meta: {\n type: 'suggestion',\n docs: {\n description: 'Enforce giving proper names to type parameters when there are two or more',\n recommended: 'recommended',\n },\n schema: [],\n messages: {\n prefix: 'Type parameter {{name}} should have a prefix of \"T\" or \"$\"',\n initial: \"Type parameter {{name}}'s name should start with an uppercase letter\",\n remainder: \"Type parameter {{name}}'s name should contain at least one lowercase letter\",\n regex: 'Type parameter {{name}} should match the regex {{regex}}',\n },\n },\n defaultOptions: [],\n create(context) {\n return {\n TSTypeParameterDeclaration(node) {\n const { params } = node;\n\n if (params.length === 1 && params.at(0)?.name.name === 'T') return;\n\n for (const param of params) {\n const { name } = param.name;\n\n const messageId = match(name)\n .with(P.string.regex(TypeParamRegex), () => false as const)\n .with(P.not(P.string.regex(PrefixRegex)), () => MessageId.prefix)\n .with(P.not(P.string.regex(InitialRegex)), () => MessageId.initial)\n .with(P.not(P.string.regex(RemainderRegex)), () => MessageId.remainder)\n .otherwise(() => false as const);\n\n messageId &&\n context.report({\n node: param,\n messageId,\n data: { name },\n });\n }\n },\n };\n },\n});\n","import * as typeParamNames from './type-param-names';\n\nexport type * from './type-param-names';\n\nexport const rules = {\n 'type-param-names': typeParamNames.typeParamNames,\n};\n","import { recommended } from './configs/recommended';\nimport * as rules from './rules';\n\nconst plugin = {\n rules: rules.rules,\n configs: {\n recommended,\n },\n};\n\nexport default plugin;\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@2digits/eslint-plugin",
|
|
3
3
|
"description": "An eslint plugin that provides a set of rules to enforce best practices for 2digits projects",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/2digits-agency/configs",
|
|
7
7
|
"directory": "packages/eslint-plugin"
|
|
@@ -34,23 +34,20 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
39
|
-
"eslint": "^8.56.0",
|
|
37
|
+
"@typescript-eslint/utils": "7.1.0",
|
|
38
|
+
"eslint": "^8.57.0",
|
|
40
39
|
"magic-regexp": "^0.7.0",
|
|
41
|
-
"ts-pattern": "^5.0.
|
|
40
|
+
"ts-pattern": "^5.0.8"
|
|
42
41
|
},
|
|
43
42
|
"devDependencies": {
|
|
44
|
-
"@2digits/tsconfig": "0.3.
|
|
45
|
-
"@typescript-eslint/rule-tester": "
|
|
43
|
+
"@2digits/tsconfig": "0.3.4",
|
|
44
|
+
"@typescript-eslint/rule-tester": "7.1.0",
|
|
46
45
|
"eslint-define-config": "^2.1.0",
|
|
47
|
-
"tsup": "^8.0.
|
|
48
|
-
"turbo": "^1.11.3",
|
|
46
|
+
"tsup": "^8.0.2",
|
|
49
47
|
"typescript": "^5.3.3",
|
|
50
|
-
"vitest": "^1.
|
|
48
|
+
"vitest": "^1.3.1"
|
|
51
49
|
},
|
|
52
50
|
"eslintConfig": {
|
|
53
|
-
"extends": "@2digits",
|
|
54
51
|
"ignorePatterns": [
|
|
55
52
|
"fixtures"
|
|
56
53
|
]
|