Skip to content

Commit

Permalink
adjust rules, fix type checked rules being disabled (#242)
Browse files Browse the repository at this point in the history
Signed-off-by: Kangrui Johann Ye <[email protected]>
  • Loading branch information
strawberry-choco authored Oct 14, 2024
1 parent db5b3ef commit 896fc97
Show file tree
Hide file tree
Showing 29 changed files with 44 additions and 208 deletions.
12 changes: 5 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ export default tseslint.config(
'packages/eslint-plugin-angular/src/configs/format-template.ts',
'packages/eslint-plugin-react/*',
'packages/eslint-plugin-typescript/src/configs/index.ts',
'packages/eslint-plugin-typescript/src/configs/recommended/*',
'packages/eslint-plugin-typescript/src/configs/recommended-json/*',
'packages/eslint-plugin-typescript/src/configs/recommended-package/*',
'packages/eslint-plugin-typescript/src/configs/recommended-typescript/recommended-typescript.config.ts',
'packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/format.ts',
'packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/import.ts',
'packages/eslint-plugin-typescript/src/configs/recommended-typescript/rules/rxjs.ts',
'packages/eslint-plugin-typescript/src/configs/json.ts',
'packages/eslint-plugin-typescript/src/configs/package.ts',
'packages/eslint-plugin-typescript/src/configs/format.ts',
'packages/eslint-plugin-typescript/src/configs/import.ts',
'packages/eslint-plugin-typescript/src/configs/rxjs.ts',
'packages/eslint-plugin-typescript/src/rules/package/*',
'packages/eslint-plugin-typescript/src/rules/ts-config/*',
'packages/eslint-plugin-typescript/src/rules/typescript/*.spec.ts',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin",
"version": "1.0.0-rc4",
"version": "1.0.0-rc5",
"private": true,
"volta": {
"node": "20.12.2",
Expand Down
7 changes: 3 additions & 4 deletions packages/eslint-plugin-angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,16 @@ import { includeIgnoreFile } from '@eslint/compat';
import { dirname, normalize, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const gitignorePath = normalize(resolve(__dirname, '.gitignore'));
const directory = dirname(fileURLToPath(import.meta.url));
const gitignorePath = normalize(resolve(directory, '.gitignore'));

export default [
includeIgnoreFile(gitignorePath),
...cloudflightAngularConfig,
{
languageOptions: {
parserOptions: {
project: ['tsconfig.*?.json'],
project: ['tsconfig*(.*).json'],
tsconfigRootDir: import.meta.dirname,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-angular",
"version": "1.0.0-rc4",
"version": "1.0.0-rc5",
"description": "Cloudflight eslint-plugin & eslint-config for angular",
"volta": {
"extends": "../../package.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {angularEslintRules} from './configs/angular-eslint';
import {angularTemplateEslintRules} from './configs/angular-eslint-template';

export const cloudflightAngularTypescriptConfig = tseslint.config(
...cloudflightTypescriptConfig,
{
files: ['**/*.{ts,mts,cts}'],
extends: [
...cloudflightTypescriptConfig,
...angular.configs.tsRecommended,
],
processor: angular.processInlineTemplates,
Expand Down
7 changes: 3 additions & 4 deletions packages/eslint-plugin-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@ import { includeIgnoreFile } from '@eslint/compat';
import { dirname, normalize, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const gitignorePath = normalize(resolve(__dirname, '.gitignore'));
const directory = dirname(fileURLToPath(import.meta.url));
const gitignorePath = normalize(resolve(directory, '.gitignore'));

export default [
includeIgnoreFile(gitignorePath),
...cloudflightNodeConfig,
{
languageOptions: {
parserOptions: {
project: ['tsconfig.*?.json'],
project: ['tsconfig*(.*).json'],
tsconfigRootDir: import.meta.dirname,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-node",
"version": "1.0.0-rc4",
"version": "1.0.0-rc5",
"description": "Cloudflight eslint-plugin & eslint-config for node",
"volta": {
"extends": "../../package.json"
Expand Down
9 changes: 2 additions & 7 deletions packages/eslint-plugin-node/src/configs/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@ export const nodeRules: TSESLint.Linter.RulesRecord = {
// require all requires be top-level
'n/global-require': 'error',

// allow typescript files
'n/no-missing-import': [
'error',
{
tryExtensions: ['.js', '.ts', '.json', '.node'],
},
],
// disabled because of https://github.com/eslint-community/eslint-plugin-n/issues/349
'n/no-missing-import': 'off',

// disallow use of new operator with the require function
'n/no-new-require': 'error',
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import {securityRules} from './configs/security';
import {nodeRules} from './configs/node';

export const cloudflightNodeConfig = tseslint.config(
...cloudflightTypescriptConfig,
{
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
extends: [
...cloudflightTypescriptConfig,
pluginNode.configs['flat/recommended'],
nounsanitized.configs.recommended,
pluginSecurity.configs.recommended,
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-react",
"version": "1.0.0-rc4",
"version": "1.0.0-rc5",
"description": "Cloudflight eslint-plugin & eslint-config for React",
"volta": {
"extends": "../../package.json"
Expand Down
9 changes: 4 additions & 5 deletions packages/eslint-plugin-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The Cloudflight ESLint Plugin Typescript provides a configuration of ESLint rules recommended by Cloudflight.

You can find the directory of all rules including their reasoning [here](src/configs/recommended-typescript/rules).
You can find the directory of all rules including their reasoning [here](src/configs).

## Dependencies

Expand Down Expand Up @@ -32,17 +32,16 @@ import { includeIgnoreFile } from '@eslint/compat';
import { dirname, normalize, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const gitignorePath = normalize(resolve(__dirname, '.gitignore'));
const directory = dirname(fileURLToPath(import.meta.url));
const gitignorePath = normalize(resolve(directory, '.gitignore'));

export default [
includeIgnoreFile(gitignorePath),
...cloudflightTypescriptConfig,
{
languageOptions: {
parserOptions: {
project: ['tsconfig.*?.json'],
project: ['tsconfig*(.*).json'],
tsconfigRootDir: import.meta.dirname,
},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudflight/eslint-plugin-typescript",
"version": "1.0.0-rc4",
"version": "1.0.0-rc5",
"description": "Cloudflight eslint-plugin & eslint-config for typescript",
"volta": {
"extends": "../../package.json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {TSESLint} from '@typescript-eslint/utils';

import {NoMomentJsRuleName} from '../../../rules/typescript/no-moment-js';
import {NoOnEventAssignName} from '../../../rules/typescript/no-on-event-assign';
import {NoMomentJsRuleName} from '../rules/typescript/no-moment-js';
import {NoOnEventAssignName} from '../rules/typescript/no-on-event-assign';

const pluginPrefix = '@cloudflight/typescript';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const eslintRules: TSESLint.Linter.RulesRecord = {
'default-case': 'off',
eqeqeq: ['error', 'always', {null: 'ignore'}],
'max-classes-per-file': ['error', 1],
'new-parens': ['error'],
'no-async-promise-executor': ['error'],
'no-bitwise': ['error'],
'no-console': ['error'],
Expand Down Expand Up @@ -52,7 +51,6 @@ export const eslintRules: TSESLint.Linter.RulesRecord = {
'no-proto': ['error'],
'no-implied-eval': ['error'],
'no-iterator': ['error'],
'no-floating-decimal': ['error'],
'no-caller': ['error'],
'no-empty-pattern': ['error'],
'no-extend-native': ['error'],
Expand All @@ -70,16 +68,13 @@ export const eslintRules: TSESLint.Linter.RulesRecord = {
'no-compare-neg-zero': ['error'],
'no-cond-assign': ['error', 'always'],
'no-nested-ternary': ['error'],
'no-new-object': ['error'],
'no-lonely-if': ['error'],
'no-shadow-restricted-names': ['error'],
'no-undef-init': ['error'],
'no-multi-assign': ['error'],
'no-multi-str': ['error'],
'no-useless-computed-key': ['error'],
'no-case-declarations': ['error'],
'no-tabs': ['error'],
'semi-style': ['error', 'last'],
'default-case-last': ['error'],
'unicode-bom': ['error', 'never'],
'for-direction': ['error'],
Expand All @@ -105,21 +100,13 @@ export const eslintRules: TSESLint.Linter.RulesRecord = {
'symbol-description': ['error'],
strict: ['error', 'never'],
yoda: ['error'],
'quote-props': ['error', 'as-needed'],
radix: ['error'],
'require-yield': ['error'],
'use-isnan': ['error'],
'func-style': ['error', 'declaration'],
'func-names': ['warn'],
'one-var': ['error', 'never'],
'one-var-declaration-per-line': ['error', 'always'],
'nonblock-statement-body-position': [
'error',
'beside',
{
overrides: {},
},
],
camelcase: [
'error',
{
Expand Down Expand Up @@ -290,55 +277,6 @@ export const eslintRules: TSESLint.Linter.RulesRecord = {
defaultAssignment: false,
},
],
'no-mixed-operators': [
'error',
{
groups: [
[
'%',
'**',
],
[
'%',
'+',
],
[
'%',
'-',
],
[
'%',
'*',
],
[
'%',
'/',
],
[
'/',
'*',
],
[
'&',
'|',
'<<',
'>>',
'>>>',
],
[
'==',
'!=',
'===',
'!==',
],
[
'&&',
'||',
],
],
allowSamePrecedence: false,
},
],
'no-restricted-globals': [
'error',
{
Expand Down Expand Up @@ -414,13 +352,6 @@ export const eslintRules: TSESLint.Linter.RulesRecord = {
allowImplicit: true,
},
],
'no-confusing-arrow': [
'error',
{
allowParens: true,
onlyOneSimpleParam: false,
},
],
'no-useless-rename': [
'error',
{
Expand Down
14 changes: 0 additions & 14 deletions packages/eslint-plugin-typescript/src/configs/index.ts

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 896fc97

Please sign in to comment.