-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adapt to new config format * moved test and react config into default config * moved typescript-react config into typescript config * removed `all`, `test`, `react` and `typescript-react` and separate configs
- Loading branch information
Showing
22 changed files
with
2,496 additions
and
1,333 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
const fs = require("fs"); | ||
const getRules = require("./rules"); | ||
const globals = require("globals"); | ||
|
||
const eslintPluginN = require("eslint-plugin-n"); | ||
const eslintPluginImport = require("eslint-plugin-import"); | ||
const eslintPluginTypescriptRules = require("@bonniernews/eslint-plugin-typescript-rules"); | ||
|
||
// This will take care of potential symlinks | ||
const appDir = fs.realpathSync(process.cwd()); | ||
|
||
const isModuleProject = require(path.resolve(appDir, "package.json")).type === "module"; | ||
const hasES2022Support = parseInt(process.versions.node.split(".").shift(), 10) >= 16; | ||
|
||
const moduleConfig = { | ||
languageOptions: { | ||
ecmaVersion: hasES2022Support ? 2022 : 2021, | ||
globals: { ...globals.node }, | ||
sourceType: "module", | ||
}, | ||
plugins: { | ||
n: eslintPluginN, | ||
import: eslintPluginImport, | ||
"@bonniernews/typescript-rules": eslintPluginTypescriptRules, | ||
}, | ||
}; | ||
|
||
const commonjsConfig = { | ||
languageOptions: { | ||
ecmaVersion: 2021, | ||
sourceType: "commonjs", | ||
globals: { ...globals.node }, | ||
}, | ||
plugins: { | ||
n: eslintPluginN, | ||
"@bonniernews/typescript-rules": eslintPluginTypescriptRules, | ||
}, | ||
}; | ||
|
||
const baseConfig = { | ||
ignores: [ | ||
"tmp/", | ||
"public/", | ||
"submodule/**", | ||
"logs/", | ||
"docs/", | ||
], | ||
...(isModuleProject ? moduleConfig : commonjsConfig), | ||
rules: getRules(isModuleProject), | ||
}; | ||
|
||
module.exports = baseConfig; |
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,6 @@ | ||
"use strict"; | ||
|
||
module.exports = [ | ||
{ ignores: [ "test/data/**/*" ] }, | ||
...require("./index.js"), | ||
]; |
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 |
---|---|---|
@@ -1,44 +1,27 @@ | ||
"use strict"; | ||
|
||
const path = require("path"); | ||
const fs = require("fs"); | ||
const getRules = require("./rules"); | ||
const reactPlugin = require("eslint-plugin-react"); | ||
const reactRules = require("./react-rules"); | ||
const baseConfig = require("./base-config"); | ||
const testConfig = require("./test"); | ||
|
||
// This will take care of potential symlinks | ||
const appDir = fs.realpathSync(process.cwd()); | ||
|
||
const isModuleProject = require(path.resolve(appDir, "package.json")).type === "module"; | ||
const hasES2022Support = parseInt(process.versions.node.split(".").shift(), 10) >= 16; | ||
|
||
const moduleConfig = { | ||
parserOptions: { | ||
ecmaVersion: hasES2022Support ? 2022 : 2021, | ||
sourceType: "module", | ||
module.exports = [ | ||
baseConfig, | ||
{ | ||
...baseConfig, | ||
files: [ "**/*.jsx" ], | ||
languageOptions: { | ||
...baseConfig.languageOptions, | ||
parserOptions: { ecmaFeatures: { jsx: true } }, | ||
}, | ||
plugins: { ...baseConfig.plugins, react: reactPlugin }, | ||
rules: { ...baseConfig.rules, ...reactRules }, | ||
}, | ||
env: { | ||
node: true, | ||
...(hasES2022Support ? { es2022: true } : { es6: true }), | ||
{ | ||
...baseConfig, | ||
languageOptions: { ...baseConfig.languageOptions, ...testConfig.languageOptions }, | ||
plugins: { ...baseConfig.plugins, ...testConfig.plugins }, | ||
rules: { ...baseConfig.rules, ...testConfig.rules }, | ||
files: [ "test/**/*.js" ], | ||
}, | ||
plugins: [ "eslint-plugin-n", "import", "@bonniernews/typescript-rules" ], | ||
}; | ||
|
||
const commonjsConfig = { | ||
parserOptions: { ecmaVersion: 2021 }, | ||
env: { | ||
node: true, | ||
es6: true, | ||
}, | ||
plugins: [ "eslint-plugin-n", "@bonniernews/typescript-rules" ], | ||
}; | ||
|
||
module.exports = { | ||
ignorePatterns: [ | ||
"tmp/", | ||
"public/", | ||
"submodule/**", | ||
"logs/", | ||
"docs/", | ||
], | ||
...(isModuleProject ? moduleConfig : commonjsConfig), | ||
rules: getRules(isModuleProject), | ||
}; | ||
]; |
Oops, something went wrong.