Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: merge staging to master #5

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/tmp
/dist
/lib
.env*
!.env.example
# nix
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@
shellHook = ''
echo "Entering $(npm pkg get name)"
set -o allexport
. <(polykey secrets env js-logger)
. <(polykey secrets env js-eslint)
set +o allexport
set -v
${lib.optionalString ci ''
63 changes: 0 additions & 63 deletions lib/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion lib/index.d.ts.map

This file was deleted.

7 changes: 0 additions & 7 deletions lib/index.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/index.js.map

This file was deleted.

58 changes: 0 additions & 58 deletions lib/rules/no-aliased-imports.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion lib/rules/no-aliased-imports.d.ts.map

This file was deleted.

107 changes: 0 additions & 107 deletions lib/rules/no-aliased-imports.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/rules/no-aliased-imports.js.map

This file was deleted.

1 change: 0 additions & 1 deletion lib/tsbuildinfo

This file was deleted.

7,819 changes: 2,073 additions & 5,746 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 8 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
{
"name": "@matrixai/matrix-eslint",
"name": "@matrixai/eslint-plugin",
"version": "0.0.1",
"author": "Roger Qiu",
"description": "Org wide custom eslint rules",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/MatrixAI/js-logger.git"
"url": "https://github.com/MatrixAI/js-eslint.git"
},
"type": "module",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"exports": {
"import": "./lib/index.js",
"require": "./lib/index.cjs",
"types": "./lib/index.d.ts"
"import": "./lib/index.js"
},
"./package.json": "./package.json",
"scripts": {
"prepare": "tsc -p ./tsconfig.build.json",
"build": "shx rm -rf ./dist && tsc -p ./tsconfig.build.json",
"build": "shx rm -rf ./lib && tsc -p ./tsconfig.build.json",
"postversion": "npm install --package-lock-only --ignore-scripts --silent",
"tsx": "tsx",
"test": "node ./scripts/test.mjs",
@@ -31,25 +28,22 @@
},
"devDependencies": {
"@swc/core": "1.3.82",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.2",
"@types/node": "^20.5.7",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"benny": "^3.7.1",
"@typescript-eslint/utils": "^8.26.1",
"common-tags": "^1.8.2",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^5.0.0-alpha.2",
"jest": "^29.6.2",
"jest-extended": "^4.0.0",
"jest-junit": "^16.0.0",
"prettier": "^3.0.0",
"shx": "^0.3.4",
"systeminformation": "^5.18.5",
"tsx": "^3.12.7",
"typedoc": "^0.24.8",
"typescript": "^5.1.6"
},
"peerDependencies": {
"eslint": ">=9.0.0"
}
}
12 changes: 12 additions & 0 deletions src/configs/recommended.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const recommended = {
rules: {
'@matrixai/no-aliased-imports': [
'error',
{
aliases: [{ prefix: '#', target: 'src' }],
includeFolders: ['src'],
autoFix: false,
},
],
},
};
18 changes: 16 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import { noAliasedImportsRule } from './rules/no-aliased-imports.js';
import noAliasedImportsRule from './rules/no-aliased-imports.js';
import { recommended } from './configs/recommended.js';

export default {
export const plugin = {
meta: {
name: 'eslint-plugin-matrixai',
version: '0.0.1',
},
rules: {
'no-aliased-imports': noAliasedImportsRule,
},
configs: {
recommended: recommended,
},
};

Object.assign(plugin.configs, {
recommended: recommended,
});

export default plugin;
24 changes: 20 additions & 4 deletions src/rules/no-aliased-imports.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import type { RuleModule } from '@typescript-eslint/utils/ts-eslint';
import path from 'node:path';

export const noAliasedImportsRule = {
export const noAliasedImportsRule: RuleModule<
'noAlias' | 'noAliasNoAutofix',
[
{
aliases: { prefix: string; target: string }[];
includeFolders: string[];
autoFix: boolean;
},
]
> = {
meta: {
type: 'suggestion',
fixable: 'code',
@@ -48,14 +58,18 @@ export const noAliasedImportsRule = {
{
aliases: [{ prefix: '#', target: 'src' }],
includeFolders: ['src'],
autoFix: true,
autoFix: false,
},
],
create(context) {
const options = context.options[0] || {};
const { aliases, includeFolders, autoFix } = options;
const {
aliases = [{ prefix: '#', target: 'src' }],
includeFolders = ['src'],
autoFix = false,
} = options;
return {
importDeclaration(node) {
ImportDeclaration(node) {
const importPath = node.source.value;

// The absolute path of the current file being linted
@@ -125,3 +139,5 @@ export const noAliasedImportsRule = {
};
},
};

export default noAliasedImportsRule;