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

feat: add new build-config package #9292

Merged
merged 23 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
{
"matchPackageNames": [
"chai",
"mocha",
"qunit-dom",
"sinon",
"ember-exam",
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
key: failed-test-log_${{ github.sha }}

- name: Development
run: timeout $BROWSER_TIMEOUT pnpm test
run: timeout $BROWSER_TIMEOUT pnpm run test
env:
TESTEM_CI_LAUNCHER: ${{ matrix.launcher }}
CI: true
Expand Down
19 changes: 1 addition & 18 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,7 @@ dist
dist-*
tmp
unstable-preview-types
# packages/-ember-data/addon
packages/active-record/addon
packages/adapter/addon
packages/core-types/addon
packages/data-worker/addon
# packages/debug/addon
packages/graph/addon
packages/json-api/addon
packages/legacy-compat/addon
packages/model/addon
packages/request-utils/addon
packages/request/addon
packages/rest/addon
packages/schema-record/addon/
packages/serializer/addon
packages/store/addon
packages/tracking/addon
packages/ember/addon
packages/*/addon

# dependencies
bower_components
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

# generated files
pnpm-lock.yaml
dist
unstable-preview-types
preview-types

# we disagree with prettier and we are even more opinionated than they are
*.hbs
Expand Down
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"eslint.format.enable": true,
"eslint.workingDirectories": [{ "mode": "auto" }, "packages/*", "tests/*"],
"eslint.options": { "reportUnusedDisableDirectives": "error" },
"eslint.useFlatConfig": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
Expand Down Expand Up @@ -40,5 +40,6 @@
"editor.tabSize": 4
},
"typescript.preferences.importModuleSpecifier": "project-relative",
"bun.debugTerminal.enabled": true
"bun.debugTerminal.enabled": true,
"eslint.debug": true
}
35 changes: 35 additions & 0 deletions config/babel/fix-mjs.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = function () {
const addonLocation = process.env.ADDON_LOCATION;
const pkgPath = addonLocation + '/package.json';
const pkg = require(pkgPath);
const isV1Addon = !pkg['ember-addon'] || pkg['ember-addon'].version === 1;

function replaceExt(node) {
if (node.value.endsWith('.mjs')) {
node.value = node.value.replace('.mjs', '.js');
}
if (isV1Addon) {
if (node.value.endsWith('.js')) {
node.value = node.value.replace('.js', '');
}
}
}

return {
name: '@warp-drive/internal-config/fix-mjs',
visitor: {
Program(path) {
path.node.body.forEach((node) => {
if (node.type === 'ImportDeclaration' || (node.type === 'ExportNamedDeclaration' && node.source)) {
replaceExt(node.source);
}
});
},
CallExpression(path) {
if (path.node.callee.type === 'Import') {
replaceExt(path.node.arguments[0]);
}
},
},
};
};
50 changes: 0 additions & 50 deletions config/eslint/base.cjs

This file was deleted.

54 changes: 54 additions & 0 deletions config/eslint/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// @ts-check
import js from '@eslint/js';
import prettier from 'eslint-config-prettier';
import * as imports from './imports.js';
import * as isolation from './isolation.js';
import * as ts from './typescript.js';

// function resolve(name) {
// const fullPath = import.meta.resolve(name);
// if (fullPath.startsWith('file://')) {
// return fullPath.slice(7);
// }
// }

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
);
}

/** @returns {import('eslint').Linter.FlatConfig} */
export function browser(config = {}) {
config.files = Array.isArray(config.files) ? config.files : ['**/*.{js,gjs}'];
const base = ts.browser(config);
// @ts-expect-error
base.languageOptions.parserOptions.project = null;
base.rules = rules(config);
base.plugins = imports.plugins();

return base;
}
53 changes: 0 additions & 53 deletions config/eslint/diagnostic.cjs

This file was deleted.

23 changes: 23 additions & 0 deletions config/eslint/diagnostic.js
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;
}
34 changes: 34 additions & 0 deletions config/eslint/gts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import noop from 'ember-eslint-parser/noop';
import emberEslintParser from 'ember-eslint-parser';
import * as ts from './typescript.js';

export function browser(config) {
config.files = config.files ?? ['**/*.{gts,gjs}'];
const base = ts.browser(config);

const parser = Object.assign(
{
meta: {
name: 'ember-eslint-parser',
version: '*',
},
},
emberEslintParser
);

base.languageOptions.parser = parser;
base.processor = 'ember/noop';
base.plugins = Object.assign({}, base.plugins, {
ember: {
meta: {
name: 'ember',
version: '*',
},
processors: {
noop,
},
},
});

return base;
}
38 changes: 0 additions & 38 deletions config/eslint/ignore.cjs

This file was deleted.

Loading
Loading