@gossi/config-eslint
Advanced tools
Comparing version 0.7.0 to 0.8.0
'use strict'; | ||
const { hasDep, configFor, pipe, merge, forFiles } = require('./-utils'); | ||
const { typescriptParserOptions } = require('./parsers/typescript'); | ||
@@ -42,6 +43,3 @@ /** | ||
{ | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaVersion: 'latest' | ||
}, | ||
parserOptions: typescriptParserOptions, | ||
env: { | ||
@@ -88,6 +86,3 @@ browser: false, | ||
{ | ||
parserOptions: { | ||
sourceType: 'script', | ||
ecmaVersion: 'latest' | ||
}, | ||
parserOptions: typescriptParserOptions, | ||
env: { | ||
@@ -94,0 +89,0 @@ browser: false, |
@@ -8,2 +8,3 @@ 'use strict'; | ||
const emberConventions = require('./naming-conventions/ember'); | ||
const { typescriptParserOptions } = require('./parsers/typescript'); | ||
@@ -19,5 +20,8 @@ /** | ||
// Project Files | ||
forFiles('**/*.gts', applyNamingConventions(config.modules.browser.gts, componentsConventions)), | ||
forFiles('**/*.gjs', applyNamingConventions(config.modules.browser.gjs, componentsConventions)), | ||
forFiles( | ||
[ | ||
'{src,app,addon,addon-test-support,tests}/**/*.{gjs,js}', | ||
'{src,app,addon,addon-test-support,tests}/**/*.js', | ||
'tests/dummy/config/deprecation-workflow.js' | ||
@@ -41,15 +45,14 @@ ], | ||
), | ||
forFiles( | ||
'{src,app,addon,addon-test-support,tests,types}/**/*.gts', | ||
applyNamingConventions(config.modules.browser.ts, componentsConventions) | ||
), | ||
forFiles('**/*.d.ts', config.modules.browser.declarations), | ||
forFiles( | ||
'{types,src}/template-registry.{d.ts,ts}', | ||
applyNamingConventions(config.modules.browser.ts, templateRegistryConventions) | ||
'**/*.d.ts', | ||
applyNamingConventions( | ||
config.modules.browser.declarations, | ||
componentsConventions, | ||
templateRegistryConventions | ||
) | ||
), | ||
forFiles(['./**/stories.{js,gjs}', './**/*.stories.{js,gjs}'], config.modules.stories.js), | ||
forFiles(['./**/stories.{ts,gts}', './**/*.stories.{ts,gts}'], config.modules.stories.ts), | ||
forFiles(['./**/stories.js', './**/*.stories.js,'], config.modules.stories.js), | ||
forFiles(['./**/stories.ts', './**/*.stories.ts,'], config.modules.stories.ts), | ||
@@ -59,4 +62,6 @@ // ---------------------- | ||
forFiles('tests/**/*-test.{gjs,js}', config.modules.tests.js), | ||
forFiles('tests/**/*-test.{gts,ts}', config.modules.tests.ts), | ||
forFiles('tests/**/*-test.js', config.modules.tests.js), | ||
forFiles('tests/**/*-test.ts', config.modules.tests.ts), | ||
forFiles('tests/**/*-test.gjs', config.modules.tests.gjs), | ||
forFiles('tests/**/*-test.gts', config.modules.tests.gts), | ||
@@ -126,3 +131,4 @@ // ---------------------- | ||
browser: true | ||
} | ||
}, | ||
parserOptions: typescriptParserOptions | ||
}, | ||
@@ -135,3 +141,16 @@ (config) => merge(config, personalPreferences), | ||
}, | ||
get declarations() { | ||
get gjs() { | ||
return pipe( | ||
{ | ||
parser: 'ember-eslint-parser', | ||
env: { | ||
browser: true | ||
} | ||
}, | ||
(config) => merge(config, personalPreferences), | ||
(config) => merge(config, require('./rules/ember')), | ||
(config) => merge(config, require('./rules/ember-gjs')) | ||
); | ||
}, | ||
get gts() { | ||
if (!hasTypeScript) return; | ||
@@ -141,2 +160,3 @@ | ||
{ | ||
parser: 'ember-eslint-parser', | ||
env: { | ||
@@ -147,2 +167,18 @@ browser: true | ||
(config) => merge(config, personalPreferences), | ||
(config) => merge(config, require('./rules/ember')), | ||
(config) => merge(config, require('./rules/ember-gts')), | ||
(config) => applyNamingConventions(config, emberConventions) | ||
); | ||
}, | ||
get declarations() { | ||
if (!hasTypeScript) return; | ||
return pipe( | ||
{ | ||
env: { | ||
browser: true | ||
}, | ||
parserOptions: typescriptParserOptions | ||
}, | ||
(config) => merge(config, personalPreferences), | ||
(config) => merge(config, require('./rules/typescript-declarations')), | ||
@@ -178,6 +214,3 @@ (config) => applyNamingConventions(config, emberConventions) | ||
{ | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaVersion: 'latest' | ||
}, | ||
parserOptions: typescriptParserOptions, | ||
env: { | ||
@@ -218,3 +251,4 @@ browser: false, | ||
browser: true | ||
} | ||
}, | ||
parserOptions: typescriptParserOptions | ||
}, | ||
@@ -241,2 +275,14 @@ (config) => merge(config, personalPreferences), | ||
return pipe(browserTS, (config) => merge(config, require('./rules/qunit'))); | ||
}, | ||
get gjs() { | ||
let browserJS = configBuilder.modules.browser.gjs; | ||
return pipe(browserJS, (config) => merge(config, require('./rules/qunit'))); | ||
}, | ||
get gts() { | ||
if (!hasTypeScript) return; | ||
let browserTS = configBuilder.modules.browser.gts; | ||
return pipe(browserTS, (config) => merge(config, require('./rules/qunit'))); | ||
} | ||
@@ -243,0 +289,0 @@ } |
@@ -38,2 +38,10 @@ /** | ||
{ | ||
selector: 'import', | ||
format: ['camelCase', 'PascalCase'] | ||
}, | ||
{ | ||
selector: 'typeAlias', | ||
format: ['PascalCase'] | ||
}, | ||
{ | ||
selector: 'interface', | ||
@@ -40,0 +48,0 @@ format: ['PascalCase'], |
@@ -6,2 +6,3 @@ 'use strict'; | ||
const { hasDep, configFor, pipe, merge, forFiles } = require('./-utils'); | ||
const { typescriptParserOptions } = require('./parsers/typescript'); | ||
@@ -46,6 +47,3 @@ /** | ||
{ | ||
parserOptions: { | ||
sourceType: 'module', | ||
ecmaVersion: 'latest' | ||
}, | ||
parserOptions: typescriptParserOptions, | ||
env: { | ||
@@ -63,2 +61,3 @@ browser: false, | ||
(config) => merge(config, require('./rules/typescript')), | ||
(config) => merge(config, require('./rules/typescript-typed')), | ||
(config) => merge(config, require('./rules/typescript-imports')) | ||
@@ -95,6 +94,3 @@ ); | ||
{ | ||
parserOptions: { | ||
sourceType: 'script', | ||
ecmaVersion: 'latest' | ||
}, | ||
parserOptions: typescriptParserOptions, | ||
env: { | ||
@@ -101,0 +97,0 @@ browser: false, |
@@ -11,164 +11,144 @@ 'use strict'; | ||
plugins: ['@typescript-eslint'], | ||
extends: ['plugin:@typescript-eslint/recommended'], | ||
rules: { | ||
// this isn't C# | ||
'@typescript-eslint/interface-name-prefix': 'off', | ||
extends: ['plugin:@typescript-eslint/recommended'] | ||
// rules: { | ||
// // this isn't C# | ||
// '@typescript-eslint/interface-name-prefix': 'off', | ||
// Having an empty interface is plausable when iterating on types, | ||
// extending from an existing type and "planning" to update. | ||
'@typescript-eslint/no-empty-interface': 'off', | ||
// // Having an empty interface is plausable when iterating on types, | ||
// // extending from an existing type and "planning" to update. | ||
// '@typescript-eslint/no-empty-interface': 'off', | ||
// type imports are removed in builds | ||
'@typescript-eslint/consistent-type-imports': 'error', | ||
// // type imports are removed in builds | ||
// '@typescript-eslint/consistent-type-imports': 'error', | ||
// prefer inference, but it is recommended to declare | ||
// return types around public API | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
// // prefer inference, but it is recommended to declare | ||
// // return types around public API | ||
// '@typescript-eslint/explicit-function-return-type': 'off', | ||
// '@typescript-eslint/explicit-module-boundary-types': 'off', | ||
// Unless a type actively harms the intellisense experience, | ||
// it's not worth banning types. Sure other types could provide | ||
// better intellisense experiences, but it doesn't mean that | ||
// using 'object' for example, or 'Function' is inherently bad. | ||
'@typescript-eslint/ban-types': 'off', | ||
// // much concise | ||
// '@typescript-eslint/prefer-optional-chain': 'error', | ||
// much concise | ||
'@typescript-eslint/prefer-optional-chain': 'error', | ||
// // Maximum strictness | ||
// '@typescript-eslint/no-non-null-assertion': 'error', | ||
// Maximum strictness | ||
'@typescript-eslint/no-non-null-assertion': 'error', | ||
// // Allows placeholder args to still be defined for | ||
// // documentation or "for later" purposes | ||
// '@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], | ||
// Allows placeholder args to still be defined for | ||
// documentation or "for later" purposes | ||
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }], | ||
// // no unnecessary comma | ||
// '@typescript-eslint/comma-dangle': ['error'], | ||
// no unnecessary comma | ||
'@typescript-eslint/comma-dangle': ['error'], | ||
// // Prettier already takes care of indentation | ||
// // indent: 'off', | ||
// '@typescript-eslint/indent': 'off', | ||
// Prettier already takes care of indentation | ||
// indent: 'off', | ||
'@typescript-eslint/indent': 'off', | ||
// '@typescript-eslint/consistent-type-assertions': [ | ||
// 'error', | ||
// { | ||
// assertionStyle: 'as', | ||
// objectLiteralTypeAssertions: 'allow-as-parameter' | ||
// } | ||
// ], | ||
'@typescript-eslint/consistent-type-assertions': [ | ||
'error', | ||
{ | ||
assertionStyle: 'as', | ||
objectLiteralTypeAssertions: 'allow-as-parameter' | ||
} | ||
], | ||
// // 'no-useless-constructor': 'off', | ||
// '@typescript-eslint/no-useless-constructor': 'error', | ||
// 'no-useless-constructor': 'off', | ||
'@typescript-eslint/no-useless-constructor': 'error', | ||
// '@typescript-eslint/prefer-for-of': 'error', | ||
'@typescript-eslint/prefer-for-of': 'error', | ||
'@typescript-eslint/prefer-as-const': 'error', | ||
// // 'dot-notation': 'warn', | ||
// '@typescript-eslint/dot-notation': 'off', | ||
// 'dot-notation': 'warn', | ||
'@typescript-eslint/dot-notation': 'off', | ||
// // 'init-declarations': 'off', | ||
// '@typescript-eslint/init-declarations': 'warn', | ||
// 'init-declarations': 'off', | ||
'@typescript-eslint/init-declarations': 'warn', | ||
// // 'no-use-before-define': 'off', | ||
// '@typescript-eslint/no-use-before-define': 'error', | ||
// 'no-use-before-define': 'off', | ||
'@typescript-eslint/no-use-before-define': 'error', | ||
// // 'no-invalid-this': 'off', | ||
// '@typescript-eslint/no-invalid-this': 'error', | ||
// 'no-invalid-this': 'off', | ||
'@typescript-eslint/no-invalid-this': 'error', | ||
// // 'lines-between-class-members': 'off', | ||
// '@typescript-eslint/lines-between-class-members': [ | ||
// 'error', | ||
// 'always', | ||
// { exceptAfterSingleLine: true } | ||
// ], | ||
// 'lines-between-class-members': 'off', | ||
'@typescript-eslint/lines-between-class-members': [ | ||
'error', | ||
'always', | ||
{ exceptAfterSingleLine: true } | ||
], | ||
// /** | ||
// * This allows short-circuit idioms, like: | ||
// * | ||
// * ```js | ||
// * this.super && this.super(...arguments); | ||
// * | ||
// * this.someAction ? this.someAction() : this.fallback(); | ||
// * ``` | ||
// * | ||
// * It disabled the eslint version and instead enables the TS version, to | ||
// * properly support optional chaining. | ||
// */ | ||
// // 'no-unused-expressions': 'off', | ||
// '@typescript-eslint/no-unused-expressions': [ | ||
// 'error', | ||
// { allowShortCircuit: true, allowTernary: true } | ||
// ], | ||
// Use real types | ||
'@typescript-eslint/no-explicit-any': 'error', | ||
// // 'default-param-last': 'off', | ||
// '@typescript-eslint/default-param-last': 'error', | ||
/** | ||
* This allows short-circuit idioms, like: | ||
* | ||
* ```js | ||
* this.super && this.super(...arguments); | ||
* | ||
* this.someAction ? this.someAction() : this.fallback(); | ||
* ``` | ||
* | ||
* It disabled the eslint version and instead enables the TS version, to | ||
* properly support optional chaining. | ||
*/ | ||
// 'no-unused-expressions': 'off', | ||
'@typescript-eslint/no-unused-expressions': [ | ||
'error', | ||
{ allowShortCircuit: true, allowTernary: true } | ||
], | ||
// // 'no-dupe-class-members': 'off', | ||
// '@typescript-eslint/no-dupe-class-members': 'error', | ||
// 'default-param-last': 'off', | ||
'@typescript-eslint/default-param-last': 'error', | ||
// // 'no-loop-func': 'off', | ||
// '@typescript-eslint/no-loop-func': 'error', | ||
// 'no-dupe-class-members': 'off', | ||
'@typescript-eslint/no-dupe-class-members': 'error', | ||
// // 'no-redeclare': 'off', | ||
// '@typescript-eslint/no-redeclare': 'error', | ||
// 'no-duplicate-imports': 'off', | ||
'@typescript-eslint/no-duplicate-imports': 'error', | ||
// // 'no-shadow': 'off', | ||
// '@typescript-eslint/no-shadow': 'error', | ||
// 'no-loop-func': 'off', | ||
'@typescript-eslint/no-loop-func': 'error', | ||
// /** | ||
// * @note Requires parser services and is thus disabled. | ||
// * | ||
// * @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md | ||
// */ | ||
// // 'no-implied-eval': 'off', | ||
// '@typescript-eslint/no-implied-eval': 'off', | ||
// 'no-redeclare': 'off', | ||
'@typescript-eslint/no-redeclare': 'error', | ||
// // 'no-magic-numbers': 'off', | ||
// '@typescript-eslint/no-magic-numbers': 'off', | ||
// 'no-shadow': 'off', | ||
'@typescript-eslint/no-shadow': 'error', | ||
// /** | ||
// * Disallow throwing strings. | ||
// * | ||
// * @note Requires parser services and is thus disabled. | ||
// * | ||
// * @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-throw-literal.md | ||
// */ | ||
// // 'no-throw-literal': 'off', | ||
// '@typescript-eslint/no-throw-literal': 'off', | ||
/** | ||
* @note Requires parser services and is thus disabled. | ||
* | ||
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-implied-eval.md | ||
*/ | ||
// 'no-implied-eval': 'off', | ||
'@typescript-eslint/no-implied-eval': 'off', | ||
// /** | ||
// * Asynchronous functions that don’t use await might not need to be | ||
// * asynchronous functions and could be the unintentional result of | ||
// * refactoring. | ||
// * | ||
// * @note Requires parser services and is thus disabled. | ||
// * | ||
// * @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/require-await.md | ||
// */ | ||
// // 'require-await': 'off', | ||
// '@typescript-eslint/require-await': 'off', | ||
// 'no-magic-numbers': 'off', | ||
'@typescript-eslint/no-magic-numbers': 'off', | ||
// '@typescript-eslint/array-type': 'error', | ||
/** | ||
* Disallow throwing strings. | ||
* | ||
* @note Requires parser services and is thus disabled. | ||
* | ||
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-throw-literal.md | ||
*/ | ||
// 'no-throw-literal': 'off', | ||
'@typescript-eslint/no-throw-literal': 'off', | ||
/** | ||
* Asynchronous functions that don’t use await might not need to be | ||
* asynchronous functions and could be the unintentional result of | ||
* refactoring. | ||
* | ||
* @note Requires parser services and is thus disabled. | ||
* | ||
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/require-await.md | ||
*/ | ||
// 'require-await': 'off', | ||
'@typescript-eslint/require-await': 'off', | ||
'@typescript-eslint/array-type': 'error', | ||
/** | ||
* Adds support for numeric separators to the base rule. | ||
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-loss-of-precision.md | ||
*/ | ||
// 'no-loss-of-precision': 'off', | ||
'@typescript-eslint/no-loss-of-precision': 'error', | ||
/** | ||
* @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md#enforce-the-codebase-follows-eslints-camelcase-conventions | ||
*/ | ||
// camelcase: 'off', | ||
'@typescript-eslint/naming-convention': ['error', ...baseNamingConventions] | ||
} | ||
// /** | ||
// * @see https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/naming-convention.md#enforce-the-codebase-follows-eslints-camelcase-conventions | ||
// */ | ||
// // camelcase: 'off', | ||
// '@typescript-eslint/naming-convention': ['error', ...baseNamingConventions] | ||
// } | ||
}; | ||
module.exports = { rule }; |
{ | ||
"name": "@gossi/config-eslint", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"repository": "https://github.com/gossi/frontend-configs", | ||
@@ -19,4 +19,4 @@ "dependencies": { | ||
"@babel/eslint-parser": "^7.22.5", | ||
"@typescript-eslint/eslint-plugin": "^5.59.9", | ||
"@typescript-eslint/parser": "^5.59.9", | ||
"@typescript-eslint/eslint-plugin": "^5.59.9 || ^6.0.0", | ||
"@typescript-eslint/parser": "^5.59.9 || ^6.0.0", | ||
"eslint": "^7.0.0 || ^8.0.0", | ||
@@ -51,17 +51,16 @@ "eslint-plugin-ember": "^11.10.0", | ||
"devDependencies": { | ||
"@babel/core": "^7.23.9", | ||
"@babel/eslint-parser": "^7.23.10", | ||
"@babel/preset-env": "^7.23.9", | ||
"@tsconfig/node18": "^18.2.2", | ||
"@tsconfig/strictest": "^2.0.2", | ||
"@types/node": "^20.11.16", | ||
"@typescript-eslint/eslint-plugin": "^5.62.0", | ||
"@typescript-eslint/parser": "^5.62.0", | ||
"eslint": "^8.56.0", | ||
"eslint-plugin-ember": "^11.12.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"@babel/core": "^7.24.4", | ||
"@babel/eslint-parser": "^7.24.1", | ||
"@babel/preset-env": "^7.24.4", | ||
"@tsconfig/node18": "^18.2.4", | ||
"@tsconfig/strictest": "^2.0.5", | ||
"@types/node": "^20.12.2", | ||
"@typescript-eslint/eslint-plugin": "^7.5.0", | ||
"@typescript-eslint/parser": "^7.5.0", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-ember": "^12.0.2", | ||
"eslint-plugin-qunit": "^7.3.4", | ||
"eslint-plugin-storybook": "^0.6.15", | ||
"eslint-plugin-storybook": "^0.8.0", | ||
"prettier": "^3.2.5", | ||
"typescript": "^5.3.3" | ||
"typescript": "^5.4.4" | ||
}, | ||
@@ -74,2 +73,2 @@ "engines": { | ||
} | ||
} | ||
} |
58055
14
40
1787