Skip to content

Commit

Permalink
Add optional rxjsConfig() for @smarttools/eslint-plugin-rxjs
Browse files Browse the repository at this point in the history
  • Loading branch information
amikheychik committed Dec 8, 2024
1 parent cede1d0 commit 1fbd2bc
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 5 deletions.
8 changes: 7 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
const perfectiveEslintConfig = require('./dist');
const { cypressConfig } = require('./dist/cypress');
const { rxjsConfig } = require('./dist/rxjs');

module.exports = perfectiveEslintConfig.default;
module.exports = [
...perfectiveEslintConfig.default,
cypressConfig(),
rxjsConfig(),
];
4 changes: 4 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ exports.default = gulp.series(
require: './rules.js',
types: './rules.d.ts',
},
'./rxjs': {
require: './rxjs.js',
types: './rxjs.d.ts',
},
},
}),
build.copy([
Expand Down
3 changes: 0 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { jsdocConfig } from './rules/jsdoc';
import { nConfig } from './rules/n';
import { preferArrowConfig } from './rules/prefer-arrow';
import { promiseConfig } from './rules/promise';
import { rxjsConfig } from './rules/rxjs';
import { securityConfig } from './rules/security';
import { simpleImportSortConfig } from './rules/simple-import-sort';
import { stylisticJsConfig } from './rules/stylistic/js';
Expand Down Expand Up @@ -135,7 +134,6 @@ export default [
plugins: {
...typescriptEslintConfig.plugins,
...stylisticTsConfig.plugins,
...hasEslintPlugin('@smarttools/rxjs') ? rxjsConfig.plugins : {},
},
settings: {
'import/parsers': {
Expand All @@ -154,7 +152,6 @@ export default [
rules: {
...typescriptEslintConfig.rules,
...stylisticTsConfig.rules,
...hasEslintPlugin('@smarttools/rxjs') ? rxjsConfig.rules : {},
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion src/rules/import/rules/no-extraneous-dependencies.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { describe, expect, it } from '@jest/globals';
import {
cypressImportNoExtraneousDependencies,
ImportNoExtraneousDependencies,
importNoExtraneousDependencies, jestImportNoExtraneousDependencies,
importNoExtraneousDependencies,
jestImportNoExtraneousDependencies,
jsImportNoExtraneousDependencies,
} from './no-extraneous-dependencies';

Expand Down
36 changes: 36 additions & 0 deletions src/rxjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// eslint-disable-next-line import/no-extraneous-dependencies -- ESLint parser used only during development
import * as tsEslint from 'typescript-eslint';

import { rxjsConfig as rxjsPluginConfig } from './rules/rxjs';

/**
* Configuration for @smarttools/eslint-plugin-rxjs.
*
* @param files - A list of globs with the files to lint.
*/
export function rxjsConfig(files: string[] = ['**/*.ts?(x)']): Record<string, unknown> {
return {
files,
languageOptions: {
parser: tsEslint.parser,
parserOptions: {
// Parser options have to be duplicated when the parser is overridden
ecmaVersion: 6,
ecmaFeatures: {
globalReturn: false,
impliedStrict: true,
},
sourceType: 'module',
// TypeScript ESLint Parser
project: './tsconfig.json',
warnOnUnsupportedTypeScriptVersion: true,
},
},
plugins: {
...rxjsPluginConfig.plugins,
},
rules: {
...rxjsPluginConfig.rules,
},
};
}

0 comments on commit 1fbd2bc

Please sign in to comment.