-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
559 changed files
with
8,235 additions
and
9,079 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
// @ts-check | ||
import js from '@eslint/js'; | ||
import prettier from 'eslint-config-prettier'; | ||
import globals from 'globals'; | ||
// @ts-expect-error | ||
import babelParser from '@babel/eslint-parser'; | ||
import * as imports from './imports.js'; | ||
import * as isolation from './isolation.js'; | ||
|
||
// function resolve(name) { | ||
// const fullPath = import.meta.resolve(name); | ||
// if (fullPath.startsWith('file://')) { | ||
// return fullPath.slice(7); | ||
// } | ||
// } | ||
|
||
export function languageOptions(opts = {}) { | ||
const options = { | ||
parser: babelParser, | ||
/** @type {2022} */ | ||
ecmaVersion: 2022, | ||
/** @type {'module'} */ | ||
sourceType: 'module', | ||
parserOptions: { | ||
requireConfigFile: false, | ||
babelOptions: { | ||
babelrc: false, | ||
configFile: false, | ||
plugins: [ | ||
'classProperties', | ||
'classPrivateProperties', | ||
'classStaticBlock', | ||
opts.enableTypescript ? ['typescript', {}] : false, | ||
opts.enableDecorators ? ['decorators', {}] : false, | ||
].filter(Boolean), | ||
// \eslint-disable-next-line n/no-unpublished-require | ||
// plugins: [[resolve('@babel/plugin-proposal-decorators'), { legacy: true }]], | ||
}, | ||
}, | ||
globals: Object.assign({}, globals.nodeBuiltin), | ||
}; | ||
|
||
return options; | ||
} | ||
|
||
export function rules(config = {}) { | ||
const ourRules = { | ||
eqeqeq: 'error', | ||
'new-cap': ['error', { capIsNew: false }], | ||
'no-caller': 'error', | ||
'no-cond-assign': ['error', 'except-parens'], | ||
'no-console': 'error', // no longer recommended in eslint v6, this restores it | ||
'no-eq-null': 'error', | ||
'no-eval': 'error', | ||
'no-unused-vars': ['error', { args: 'none' }], | ||
|
||
// Too many false positives | ||
// See https://github.com/eslint/eslint/issues/11899 and similar | ||
'require-atomic-updates': 'off', | ||
|
||
'prefer-rest-params': 'off', | ||
'prefer-const': 'error', | ||
}; | ||
|
||
return Object.assign( | ||
{}, | ||
js.configs.recommended.rules, | ||
prettier.rules, | ||
imports.rules(), | ||
isolation.rules(config), | ||
ourRules | ||
); | ||
} | ||
|
||
function constructFileGlobs(srcDirs, files) { | ||
const globs = []; | ||
|
||
for (const dir of srcDirs) { | ||
const hasSlash = dir.endsWith('/'); | ||
for (const file of files) { | ||
const needsSlash = !hasSlash && !file.startsWith('/'); | ||
globs.push(`${dir}${needsSlash ? '/' : ''}${file}`); | ||
} | ||
} | ||
|
||
return globs; | ||
} | ||
|
||
/** @returns {import('eslint').Linter.FlatConfig} */ | ||
export function browser(config = {}) { | ||
config.enableDecorators = typeof config.enableDecorators === 'boolean' ? config.enableDecorators : true; | ||
const baseFiles = Array.isArray(config.files) ? config.files : ['**/*.{js,gjs}']; | ||
const files = Array.isArray(config.srcDirs) ? constructFileGlobs(config.srcDirs, baseFiles) : baseFiles; | ||
|
||
const finalized = { | ||
files, | ||
languageOptions: languageOptions(config), | ||
rules: rules(config), | ||
plugins: imports.plugins(), | ||
}; | ||
|
||
return finalized; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import * as isolation from './isolation.js'; | ||
import * as qunit from './qunit.js'; | ||
|
||
const QUNIT_BANNED_IMPORTS = ['ember-qunit', 'qunit', 'ember-exam']; | ||
|
||
/** @returns {import('eslint').Linter.FlatConfig} */ | ||
export function browser(config = {}) { | ||
const base = qunit.ember(config); | ||
base.rules = Object.assign( | ||
base.rules, | ||
{ | ||
'qunit/no-assert-equal': 'off', | ||
}, | ||
isolation.rules({ | ||
allowedImports: ['@ember/test-helpers', '@ember/test-waiters', ...(config.allowedImports ?? [])].filter( | ||
(v) => !QUNIT_BANNED_IMPORTS.includes(v) | ||
), | ||
}), | ||
config.rules ?? {} | ||
); | ||
|
||
return base; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const RULES = [ | ||
// # unconventional js | ||
'blueprints/*', | ||
'!./tests/blueprints/*', | ||
'vendor/*', | ||
|
||
// # Declaration files | ||
'**/*.d.ts', | ||
|
||
// # compiled output | ||
'dist/*', | ||
'dist-*/*', | ||
'addon/*', | ||
'tmp/*', | ||
'tmp*/*', | ||
'DEBUG/*', | ||
'DEBUG*/*', | ||
'.git/*', | ||
'.broccoli-cache/*', | ||
'unstable-preview-types/*', | ||
|
||
// # Special Cases | ||
'docs/*', | ||
'coverage/*', | ||
'node_modules/*', | ||
'.node_modules.ember-try/*', | ||
'package.json.ember-try', | ||
]; | ||
|
||
export function ignoreRules() { | ||
return RULES.slice(); | ||
} | ||
|
||
export function globalIgnores(additionalIgnores) { | ||
return { | ||
ignores: ignoreRules().concat(additionalIgnores ?? []), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.