Skip to content

Commit

Permalink
Add rules for hybrid Node.js and browser environments (#242)
Browse files Browse the repository at this point in the history
* Add package for hybrid Node.js and browser environments

* Add default message to every item

* Fix changelog formatting

* Use existing no-undef and import/no-nodejs-modules rules

* Fix yarn.lock

* Add env

* Add env to test
  • Loading branch information
Mrtenz committed Nov 15, 2022
1 parent 817d7ab commit e2f8302
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .eslintrc.js
@@ -1,6 +1,10 @@
module.exports = {
root: true,

env: {
node: true,
},

parserOptions: {
ecmaVersion: 2018,
},
Expand All @@ -13,6 +17,7 @@ module.exports = {

rules: {
'import/no-dynamic-require': 'off',
'import/no-nodejs-modules': 'off',
'node/global-require': 'off',
'node/no-process-exit': 'off',
'node/no-sync': 'off',
Expand Down
1 change: 1 addition & 0 deletions packages/base/rules-snapshot.json
Expand Up @@ -119,6 +119,7 @@
"import/no-named-as-default": "error",
"import/no-named-as-default-member": "error",
"import/no-named-default": "error",
"import/no-nodejs-modules": "error",
"import/no-self-import": "error",
"import/no-unassigned-import": "error",
"import/no-unresolved": [
Expand Down
1 change: 1 addition & 0 deletions packages/base/src/index.js
Expand Up @@ -313,6 +313,7 @@ module.exports = {
'import/no-named-as-default': 'error',
'import/no-named-as-default-member': 'error',
'import/no-named-default': 'error',
'import/no-nodejs-modules': 'error',
'import/no-self-import': 'error',
'import/no-unassigned-import': 'error',
'import/no-unresolved': [
Expand Down
2 changes: 1 addition & 1 deletion packages/typescript/rules-snapshot.json
Expand Up @@ -101,7 +101,7 @@
"no-shadow": "off",
"no-this-before-super": "off",
"no-throw-literal": "off",
"no-undef": "off",
"no-undef": "error",
"no-unreachable": "off",
"no-unsafe-negation": "off",
"no-unused-expressions": "off",
Expand Down
1 change: 1 addition & 0 deletions packages/typescript/src/index.js
Expand Up @@ -32,6 +32,7 @@ module.exports = {
'import/no-unresolved': 'off',

// Our rules
'no-undef': 'error',
'@typescript-eslint/array-type': 'error',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
Expand Down
5 changes: 5 additions & 0 deletions packages/typescript/src/index.test.js
Expand Up @@ -6,6 +6,11 @@ describe('index', () => {
it('is a valid ESLint config', async () => {
const api = new ESLint({
baseConfig: config,
overrideConfig: {
env: {
node: true,
},
},
useEslintrc: false,
});

Expand Down

0 comments on commit e2f8302

Please sign in to comment.