Skip to content

Commit

Permalink
Merge pull request #12 from atom-community/build-strict
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Feb 3, 2021
2 parents 7e000f6 + 473a319 commit 4987b16
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 255 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ package-lock.json

# Build directories
dist

strict.js
strict-react.js
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"repository": "https://github.com/atom-ide-community/eslint-config-atomic",
"license": "MIT",
"scripts": {
"build.strict": "node ./scripts/build.strict.js",
"prepare": "npm run build.strict",
"bump": "ncu -u -x coffeescript"
},
"dependencies": {
Expand Down
100 changes: 19 additions & 81 deletions react.js
Original file line number Diff line number Diff line change
@@ -1,87 +1,25 @@
const base = require("./index.js")

let overrides = base.overrides
overrides[0] = {
"plugins": ["react", "@typescript-eslint", "only-warn"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/react"
],
rules: overrides[0].rules
}

module.exports = {
// JS Files
"root": true,
"env": {
"atomtest": true,
"es6": true,
"node": true,
"browser": true,
"jasmine": true
},
"globals": {
"atom": "readonly",
"measure": "readonly"
},
"parser": "babel-eslint",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 2018,
"sourceType": "module"
},
...base,
"plugins": ["react", "only-warn"],
"extends": ["eslint:recommended", "plugin:react/recommended", "prettier", "prettier/react"],
"ignorePatterns": ["node_modules/"],
"overrides": [
{
// Bundled node version with atom has an old ESLint
// TypeScript files
"files": ["**/*.ts", "**/*.tsx"],
"parser": "@typescript-eslint/parser",
"plugins": ["react", "@typescript-eslint", "only-warn"],
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint",
"prettier/react"
],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/member-delimiter-style": "off"
}
},
{
// JSON files
"files": ["*.json"],
"plugins": ["json"],
"extends": ["prettier", "plugin:json/recommended"],
"rules": {
"json/*": [
"error",
{
"allowComments": true
}
]
}
},
{
// CoffeeScript files
"files": ["**/*.coffee"],
"parser": "eslint-plugin-coffee",
"plugins": ["coffee", "only-warn"],
"extends": ["plugin:coffee/eslint-recommended"]
},
{
// YAML files
"files": ["*.yaml", "*.yml"],
"plugins": ["yaml"],
"extends": ["plugin:yaml/recommended"]
},
// CSON files (use coffee)
{
"files": ["**/*.cson"],
"parser": "eslint-plugin-coffee",
"plugins": ["coffee", "only-warn"],
"extends": ["plugin:coffee/eslint-recommended"]
}
],
"overrides": overrides,
"settings": {
"react": {
"version": "detect"
Expand Down
22 changes: 22 additions & 0 deletions scripts/build.strict.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// script to generate the strict versions (without only-warn)

const { readFile, writeFile } = require("fs").promises
const { join, dirname, basename } = require("path")

const fileMap = {
"index.js": "strict.js",
"react.js": "strict-react.js"
}

;(async function main(){
const root = dirname(__dirname)
const files = ["index.js", "react.js"]

const filesPaths = files.map((file) => join(root, file))

filesPaths.forEach(async (filePath) => {
const text = (await readFile(filePath)).toString()
const newText = text.replace(/"only-warn"/g, "").replace("index.js", "strict.js")
await writeFile(join(root, fileMap[basename(filePath)]), newText)
})
})()
90 changes: 0 additions & 90 deletions strict-react.js

This file was deleted.

84 changes: 0 additions & 84 deletions strict.js

This file was deleted.

0 comments on commit 4987b16

Please sign in to comment.